overloadable-complex.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. char *foo(float) __attribute__((__overloadable__));
  3. void test_foo_1(float fv, double dv, float _Complex fc, double _Complex dc) {
  4. char *cp1 = foo(fv);
  5. char *cp2 = foo(dv);
  6. // Note: GCC and EDG reject these two, but they are valid C99 conversions
  7. char *cp3 = foo(fc);
  8. char *cp4 = foo(dc);
  9. }
  10. int *foo(float _Complex) __attribute__((__overloadable__));
  11. void test_foo_2(float fv, double dv, float _Complex fc, double _Complex dc) {
  12. char *cp1 = foo(fv);
  13. char *cp2 = foo(dv);
  14. int *ip = foo(fc);
  15. int *lp = foo(dc);
  16. }
  17. long *foo(double _Complex) __attribute__((__overloadable__));
  18. void test_foo_3(float fv, double dv, float _Complex fc, double _Complex dc) {
  19. char *cp1 = foo(fv);
  20. char *cp2 = foo(dv);
  21. int *ip = foo(fc);
  22. long *lp = foo(dc);
  23. }
  24. char *promote_or_convert(double _Complex) __attribute__((__overloadable__)); // expected-note 2 {{candidate function}}
  25. int *promote_or_convert(long double _Complex) __attribute__((__overloadable__)); // expected-note 2 {{candidate function}}
  26. void test_promote_or_convert(float f, float _Complex fc) {
  27. char *cp = promote_or_convert(fc); // expected-error{{call to 'promote_or_convert' is ambiguous}}
  28. int *ip2 = promote_or_convert(f); // expected-error{{call to 'promote_or_convert' is ambiguous}}
  29. }
  30. char *promote_or_convert2(float) __attribute__((__overloadable__));
  31. int *promote_or_convert2(double _Complex) __attribute__((__overloadable__));
  32. void test_promote_or_convert2(float _Complex fc) {
  33. int *cp = promote_or_convert2(fc);
  34. }
  35. char *promote_or_convert3(int _Complex) __attribute__((__overloadable__));
  36. int *promote_or_convert3(long _Complex) __attribute__((__overloadable__));
  37. void test_promote_or_convert3(short _Complex sc) {
  38. char *cp = promote_or_convert3(sc);
  39. }