Home | History | Annotate | Download | only in Preprocessor
      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 
      6 // Identifier characters
      7 extern char a\u01F6; // C11, C++11
      8 extern char a\u00AA; // C99, C11, C++11
      9 extern char a\u0384; // C++03, C11, C++11
     10 extern char a\u0E50; // C99, C++03, C11, C++11
     11 extern char a\uFFFF; // none
     12 
     13 
     14 
     15 
     16 
     17 // Identifier initial characters
     18 extern char \u0E50; // C++03, C11, C++11
     19 extern char \u0300; // disallowed initially in C11/C++11, always in C99/C++03
     20 extern char \u0D61; // C99, C11, C++03, C++11
     21 
     22 
     23 
     24 
     25 
     26 
     27 
     28 // Disallowed everywhere
     29 #define A \u0000 // expected-error{{control character}}
     30 #define B \u001F // expected-error{{control character}}
     31 #define C \u007F // expected-error{{control character}}
     32 #define D \u009F // expected-error{{control character}}
     33 #define E \uD800 // C++03 allows UCNs representing surrogate characters!
     34 
     35 
     36 
     37 
     38 
     39 
     40 #if __cplusplus
     41 # if __cplusplus >= 201103L
     42 // C++11
     43 // expected-warning@7 {{using this character in an identifier is incompatible with C++98}}
     44 // expected-warning@8 {{using this character in an identifier is incompatible with C++98}}
     45 // expected-error@11 {{expected ';'}}
     46 // expected-error@19 {{expected unqualified-id}}
     47 // expected-error@33 {{invalid universal character}}
     48 
     49 # else
     50 // C++03
     51 // expected-error@7 {{expected ';'}}
     52 // expected-error@8 {{expected ';'}}
     53 // expected-error@11 {{expected ';'}}
     54 // expected-error@19 {{expected unqualified-id}}
     55 // expected-warning@33 {{universal character name refers to a surrogate character}}
     56 
     57 # endif
     58 #else
     59 # if __STDC_VERSION__ >= 201112L
     60 // C11
     61 // expected-warning@7 {{using this character in an identifier is incompatible with C99}}
     62 // expected-warning@9 {{using this character in an identifier is incompatible with C99}}
     63 // expected-error@11 {{expected ';'}}
     64 // expected-warning@18 {{starting an identifier with this character is incompatible with C99}}
     65 // expected-error@19 {{expected identifier}}
     66 // expected-error@33 {{invalid universal character}}
     67 
     68 # else
     69 // C99
     70 // expected-error@7 {{expected ';'}}
     71 // expected-error@9 {{expected ';'}}
     72 // expected-error@11 {{expected ';'}}
     73 // expected-error@18 {{expected identifier}}
     74 // expected-error@19 {{expected identifier}}
     75 // expected-error@33 {{invalid universal character}}
     76 
     77 # endif
     78 #endif
     79