comparison clang/test/Preprocessor/ucn-pp-identifier.c @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 1d019706d866
children 1f2b6ac9f198
comparison
equal deleted inserted replaced
232:70dce7da266c 236:c4bab56944e8
1 // RUN: %clang_cc1 %s -fsyntax-only -std=c99 -pedantic -verify -Wundef 1 // RUN: %clang_cc1 %s -fsyntax-only -std=c99 -pedantic -verify=expected,ext -Wundef
2 // RUN: %clang_cc1 %s -fsyntax-only -x c++ -pedantic -verify -Wundef 2 // RUN: %clang_cc1 %s -fsyntax-only -x c++ -pedantic -verify=expected,ext -Wundef
3 // RUN: %clang_cc1 %s -fsyntax-only -x c++ -std=c++2b -pedantic -ftrigraphs -verify=expected,cxx2b -Wundef -Wpre-c++2b-compat
4 // RUN: %clang_cc1 %s -fsyntax-only -x c++ -pedantic -verify=expected,ext -Wundef -ftrigraphs -DTRIGRAPHS=1
3 // RUN: not %clang_cc1 %s -fsyntax-only -std=c99 -pedantic -Wundef 2>&1 | FileCheck -strict-whitespace %s 5 // RUN: not %clang_cc1 %s -fsyntax-only -std=c99 -pedantic -Wundef 2>&1 | FileCheck -strict-whitespace %s
4 6
5 #define \u00FC 7 #define \u00FC
6 #define a\u00FD() 0 8 #define a\u00FD() 0
7 #ifndef \u00FC 9 #ifndef \u00FC
14 16
15 #if a\U000000FD() 17 #if a\U000000FD()
16 #error "This should never happen" 18 #error "This should never happen"
17 #endif 19 #endif
18 20
21 #if a\u{FD}() // ext-warning {{extension}} cxx2b-warning {{before C++2b}}
22 #error "This should never happen"
23 #endif
24
19 #if \uarecool // expected-warning{{incomplete universal character name; treating as '\' followed by identifier}} expected-error {{invalid token at start of a preprocessor expression}} 25 #if \uarecool // expected-warning{{incomplete universal character name; treating as '\' followed by identifier}} expected-error {{invalid token at start of a preprocessor expression}}
20 #endif 26 #endif
21 #if \uwerecool // expected-warning{{\u used with no following hex digits; treating as '\' followed by identifier}} expected-error {{invalid token at start of a preprocessor expression}} 27 #if \uwerecool // expected-warning{{\u used with no following hex digits; treating as '\' followed by identifier}} expected-error {{invalid token at start of a preprocessor expression}}
22 #endif 28 #endif
23 #if \U0001000 // expected-warning{{incomplete universal character name; treating as '\' followed by identifier}} expected-error {{invalid token at start of a preprocessor expression}} 29 #if \U0001000 // expected-warning{{incomplete universal character name; treating as '\' followed by identifier}} expected-error {{invalid token at start of a preprocessor expression}}
24 #endif 30 #endif
25 31
26 // Make sure we reject disallowed UCNs 32 // Make sure we reject disallowed UCNs
27 #define \ufffe // expected-error {{macro name must be an identifier}} 33 #define \ufffe // expected-error {{macro name must be an identifier}}
28 #define \U10000000 // expected-error {{macro name must be an identifier}} 34 #define \U10000000 // expected-error {{macro name must be an identifier}}
29 #define \u0061 // expected-error {{character 'a' cannot be specified by a universal character name}} expected-error {{macro name must be an identifier}} 35 #define \u0061 // expected-error {{character 'a' cannot be specified by a universal character name}} expected-error {{macro name must be an identifier}}
36 #define \u{fffe} // expected-error {{macro name must be an identifier}} \
37 // ext-warning {{extension}} cxx2b-warning {{before C++2b}}
38 #define \N{ALERT} // expected-error {{universal character name refers to a control character}} \
39 // expected-error {{macro name must be an identifier}} \
40 // ext-warning {{extension}} cxx2b-warning {{before C++2b}}
41 #define \N{WASTEBASKET} // expected-error {{macro name must be an identifier}} \
42 // ext-warning {{extension}} cxx2b-warning {{before C++2b}}
30 43
31 #define a\u0024 44 #define a\u0024
32 45
33 #if \u0110 // expected-warning {{is not defined, evaluates to 0}} 46 #if \u0110 // expected-warning {{is not defined, evaluates to 0}}
34 #endif 47 #endif
101 // expected-warning@-1 {{incomplete universal character name}} expected-note@-1 {{did you mean to use '\u'?}} expected-warning@-1 {{whitespace}} 114 // expected-warning@-1 {{incomplete universal character name}} expected-note@-1 {{did you mean to use '\u'?}} expected-warning@-1 {{whitespace}}
102 // CHECK: note: did you mean to use '\u'? 115 // CHECK: note: did you mean to use '\u'?
103 // CHECK-NEXT: #define capital_u_\U00FC 116 // CHECK-NEXT: #define capital_u_\U00FC
104 // CHECK-NEXT: {{^ \^}} 117 // CHECK-NEXT: {{^ \^}}
105 // CHECK-NEXT: {{^ u}} 118 // CHECK-NEXT: {{^ u}}
119
120 #define \u{} // expected-warning {{empty delimited universal character name; treating as '\' 'u' '{' '}'}} expected-error {{macro name must be an identifier}}
121 #define \u{123456789} // expected-error {{hex escape sequence out of range}} expected-error {{macro name must be an identifier}}
122 #define \u{ // expected-warning {{incomplete delimited universal character name; treating as '\' 'u' '{' identifier}} expected-error {{macro name must be an identifier}}
123 #define \u{fgh} // expected-warning {{incomplete delimited universal character name; treating as '\' 'u' '{' identifier}} expected-error {{macro name must be an identifier}}
124 #define \N{ // expected-warning {{incomplete delimited universal character name; treating as '\' 'N' '{' identifier}} expected-error {{macro name must be an identifier}}
125 #define \N{} // expected-warning {{empty delimited universal character name; treating as '\' 'N' '{' '}'}} expected-error {{macro name must be an identifier}}
126 #define \N{NOTATHING} // expected-error {{'NOTATHING' is not a valid Unicode character name}} \
127 // expected-error {{macro name must be an identifier}}
128 #define \NN // expected-warning {{incomplete universal character name; treating as '\' followed by identifier}} expected-error {{macro name must be an identifier}}
129 #define \N{GREEK_SMALL-LETTERALPHA} // expected-error {{'GREEK_SMALL-LETTERALPHA' is not a valid Unicode character name}} \
130 // expected-note {{characters names in Unicode escape sequences are sensitive to case and whitespaces}}
131
132 #define CONCAT(A, B) A##B
133 int CONCAT(\N{GREEK, CAPITALLETTERALPHA}); // expected-error{{expected}} \
134 // expected-warning {{incomplete delimited universal character name}}
135
136 #ifdef TRIGRAPHS
137 int \N??<GREEK CAPITAL LETTER ALPHA??> = 0; // expected-warning{{extension}} cxx2b-warning {{before C++2b}} \
138 // expected-warning 2{{trigraph converted}}
139
140 #endif