variables.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Test this without pch.
  2. // RUN: %clang_cc1 -include %s -fsyntax-only -verify %s
  3. // Test with pch.
  4. // RUN: %clang_cc1 -emit-pch -o %t %s
  5. // RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
  6. #ifndef HEADER
  7. #define HEADER
  8. extern float y;
  9. extern int *ip, x;
  10. float z;
  11. int z2 = 17;
  12. #define MAKE_HAPPY(X) X##Happy
  13. int MAKE_HAPPY(Very);
  14. #define A_MACRO_IN_THE_PCH 492
  15. #define FUNCLIKE_MACRO(X, Y) X ## Y
  16. #define PASTE2(x,y) x##y
  17. #define PASTE1(x,y) PASTE2(x,y)
  18. #define UNIQUE(x) PASTE1(x,__COUNTER__)
  19. int UNIQUE(a); // a0
  20. int UNIQUE(a); // a1
  21. #else
  22. int *ip2 = &x;
  23. float *fp = &ip; // expected-warning{{incompatible pointer types}}
  24. double z; // expected-error{{redefinition}} expected-note@14{{previous}}
  25. int z2 = 18; // expected-error{{redefinition}} expected-note@16{{previous}}
  26. double VeryHappy; // expected-error{{redefinition}} expected-note@19{{previous definition is here}}
  27. int Q = A_MACRO_IN_THE_PCH;
  28. int R = FUNCLIKE_MACRO(A_MACRO_, IN_THE_PCH);
  29. int UNIQUE(a); // a2
  30. int *Arr[] = { &a0, &a1, &a2 };
  31. #endif