complex-int.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // RUN: %clang_cc1 %s -verify -fsyntax-only
  2. void a() {
  3. __complex__ int arr;
  4. __complex__ short brr;
  5. __complex__ unsigned xx;
  6. __complex__ signed yy;
  7. __complex__ int result;
  8. int ii;
  9. int aa = 1 + 1.0iF;
  10. int bb = 0;
  11. bb += 1i;
  12. result = arr*ii;
  13. result = ii*brr;
  14. result = arr*brr;
  15. result = xx*yy;
  16. switch (arr) { // expected-error{{statement requires expression of integer type ('_Complex int' invalid)}}
  17. case brr: ; // expected-error{{expression is not an integer constant expression}}
  18. case xx: ; // expected-error{{expression is not an integer constant expression}}
  19. }
  20. }
  21. void Tester() {
  22. __complex short a1;
  23. __complex int a2;
  24. __complex float a3;
  25. __complex double a4;
  26. short a5;
  27. int a6;
  28. float a7;
  29. double a8;
  30. #define TestPair(m,n) int x##m##n = a##m+a##n;
  31. #define TestPairs(m) TestPair(m,1) TestPair(m,2) \
  32. TestPair(m,3) TestPair(m,4) \
  33. TestPair(m,5) TestPair(m,6) \
  34. TestPair(m,7) TestPair(m,8)
  35. TestPairs(1); TestPairs(2);
  36. TestPairs(3); TestPairs(4);
  37. TestPairs(5); TestPairs(6);
  38. TestPairs(7); TestPairs(8);
  39. }
  40. // rdar://6097730
  41. void test3(_Complex int *x) {
  42. *x = ~*x;
  43. }
  44. void test4(_Complex float *x) {
  45. *x = ~*x;
  46. }
  47. void test5(_Complex int *x) {
  48. (*x)++;
  49. }
  50. int i1[(2+3i)*(5+7i) == 29i-11 ? 1 : -1];
  51. int i2[(29i-11)/(5+7i) == 2+3i ? 1 : -1];
  52. int i3[-(2+3i) == +(-3i-2) ? 1 : -1];
  53. int i4[~(2+3i) == 2-3i ? 1 : -1];
  54. int i5[(3i == -(-3i) ? ((void)3, 1i - 1) : 0) == 1i - 1 ? 1 : -1];
  55. int f1[(2.0+3.0i)*(5.0+7.0i) == 29.0i-11.0 ? 1 : -1];
  56. int f2[(29.0i-11.0)/(5.0+7.0i) == 2.0+3.0i ? 1 : -1];
  57. int f3[-(2.0+3.0i) == +(-3.0i-2.0) ? 1 : -1];
  58. int f4[~(2.0+3.0i) == 2.0-3.0i ? 1 : -1];
  59. int f5[(3.0i == -(-3.0i) ? ((void)3.0, __extension__ (1.0i - 1.0)) : 0) == 1.0i - 1.0 ? 1 : -1];