utf8-allowed-chars.c 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // RUN: %clang_cc1 %s -fsyntax-only -std=c99 -verify
  2. // RUN: %clang_cc1 %s -fsyntax-only -std=c11 -Wc99-compat -verify
  3. // RUN: %clang_cc1 %s -fsyntax-only -x c++ -std=c++03 -Wc++11-compat -verify
  4. // RUN: %clang_cc1 %s -fsyntax-only -x c++ -std=c++11 -Wc++98-compat -verify
  5. // Note: This file contains Unicode characters; please do not remove them!
  6. // Identifier characters
  7. extern char aǶ; // C11, C++11
  8. extern char aª; // C99, C11, C++11
  9. extern char a΄; // C++03, C11, C++11
  10. extern char a๐; // C99, C++03, C11, C++11
  11. extern char a﹅; // none
  12. extern char x̀; // C11, C++11. Note that this does not have a composed form.
  13. // Identifier initial characters
  14. extern char ๐; // C++03, C11, C++11
  15. extern char ̀; // disallowed initially in C11/C++11, always in C99/C++03
  16. #if __cplusplus
  17. # if __cplusplus >= 201103L
  18. // C++11
  19. // expected-warning@9 {{using this character in an identifier is incompatible with C++98}}
  20. // expected-warning@10 {{using this character in an identifier is incompatible with C++98}}
  21. // expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
  22. // expected-warning@14 {{using this character in an identifier is incompatible with C++98}}
  23. // expected-error@21 {{expected unqualified-id}}
  24. # else
  25. // C++03
  26. // expected-error@9 {{non-ASCII characters are not allowed outside of literals and identifiers}}
  27. // expected-error@10 {{non-ASCII characters are not allowed outside of literals and identifiers}}
  28. // expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
  29. // expected-error@14 {{non-ASCII characters are not allowed outside of literals and identifiers}}
  30. // expected-error@21 {{non-ASCII characters are not allowed outside of literals and identifiers}} expected-warning@21 {{declaration does not declare anything}}
  31. # endif
  32. #else
  33. # if __STDC_VERSION__ >= 201112L
  34. // C11
  35. // expected-warning@9 {{using this character in an identifier is incompatible with C99}}
  36. // expected-warning@11 {{using this character in an identifier is incompatible with C99}}
  37. // expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
  38. // expected-warning@14 {{using this character in an identifier is incompatible with C99}}
  39. // expected-warning@20 {{starting an identifier with this character is incompatible with C99}}
  40. // expected-error@21 {{expected identifier}}
  41. # else
  42. // C99
  43. // expected-error@9 {{non-ASCII characters are not allowed outside of literals and identifiers}}
  44. // expected-error@11 {{non-ASCII characters are not allowed outside of literals and identifiers}}
  45. // expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
  46. // expected-error@14 {{non-ASCII characters are not allowed outside of literals and identifiers}}
  47. // expected-error@20 {{expected identifier}}
  48. // expected-error@21 {{non-ASCII characters are not allowed outside of literals and identifiers}} expected-warning@21 {{declaration does not declare anything}}
  49. # endif
  50. #endif