1 // RUN: %clang_cc1 -std=c23 %s -E -verify
3 // Test the parsing behavior for #embed and all of its parameters to ensure we
4 // recover from failures gracefully.
7 // expected-error@-1 {{expected "FILENAME" or <FILENAME>}}
10 // expected-error@-1 {{expected '>'}} \
11 expected
-note@
-1 {{to match
this '<'}}
14 // expected-error@-1 {{expected "FILENAME" or <FILENAME>}} \
15 expected-warning@-1 {{missing terminating '"' character}}
18 // expected-error@-1{{expected "FILENAME" or <FILENAME>}}
20 #embed "embed_parsing_errors.c" xxx
21 // expected-error@-1 {{unknown embed preprocessor parameter 'xxx'}}
23 #embed "embed_parsing_errors.c" xxx::
24 // expected-error@-1 {{expected identifier}}
26 #embed "embed_parsing_errors.c" xxx::xxx
27 // expected-error@-1 {{unknown embed preprocessor parameter 'xxx::xxx'}}
29 #embed "embed_parsing_errors.c" xxx::42
30 // expected-error@-1 {{expected identifier}}
32 #embed "embed_parsing_errors.c" limit
33 // expected-error@-1 {{expected '('}}
35 #embed "embed_parsing_errors.c" limit(
36 // expected-error@-1 {{expected value in expression}}
38 #embed "embed_parsing_errors.c" limit(xxx
39 // expected-error@-1 {{expected ')'}}
41 #embed "embed_parsing_errors.c" limit(42
42 // expected-error@-1 {{expected ')'}}
44 #embed "embed_parsing_errors.c" limit([
45 // expected-error@-1 {{invalid token at start of a preprocessor expression}}
47 #embed "embed_parsing_errors.c" limit([)
48 // expected-error@-1 {{invalid token at start of a preprocessor expression}}
50 #embed "embed_parsing_errors.c" limit(1/0)
51 // expected-error@-1 {{division by zero in preprocessor expression}}
53 #embed "embed_parsing_errors.c" clang::offset
54 // expected-error@-1 {{expected '('}}
56 #embed "embed_parsing_errors.c" clang::offset(
57 // expected-error@-1 {{expected value in expression}}
59 #embed "embed_parsing_errors.c" clang::offset(xxx
60 // expected-error@-1 {{expected ')'}}
62 #embed "embed_parsing_errors.c" clang::offset(42
63 // expected-error@-1 {{expected ')'}}
65 #embed "embed_parsing_errors.c" clang::offset([
66 // expected-error@-1 {{invalid token at start of a preprocessor expression}}
68 #embed "embed_parsing_errors.c" clang::offset([)
69 // expected-error@-1 {{invalid token at start of a preprocessor expression}}
71 #embed "embed_parsing_errors.c" clang::offset(1/0)
72 // expected-error@-1 {{division by zero in preprocessor expression}}
74 #embed "embed_parsing_errors.c" clang::offset 42
75 // expected-error@-1 {{expected '('}}
77 #embed "embed_parsing_errors.c" prefix
78 // expected-error@-1 {{expected '('}}
80 #embed "embed_parsing_errors.c" prefix(
81 // expected-error@-1 {{expected ')'}}
83 #embed "embed_parsing_errors.c" prefix(xxx
84 // expected-error@-1 {{expected ')'}}
86 #embed "embed_parsing_errors.c" prefix(1/0) // OK: emitted as tokens, not evaluated yet.
87 #embed "embed_parsing_errors.c" prefix(([{}])) // OK: delimiters balanced
88 #embed "embed_parsing_errors.c" prefix(([{)]})
89 // expected-error@-1 {{expected '}'}} expected-note@-1 {{to match this '{'}}
90 #embed "embed_parsing_errors.c" prefix(([{})})
91 // expected-error@-1 {{expected ']'}} expected-note@-1 {{to match this '['}}
92 #embed "embed_parsing_errors.c" prefix(([{}]})
93 // expected-error@-1 {{expected ')'}} expected-note@-1 {{to match this '('}}
94 #embed "embed_parsing_errors.c" prefix() // OK: tokens within parens are optional
95 #embed "embed_parsing_errors.c" prefix)
96 // expected-error@-1 {{expected '('}}
98 #embed "embed_parsing_errors.c" suffix
99 // expected-error@-1 {{expected '('}}
101 #embed "embed_parsing_errors.c" suffix(
102 // expected-error@-1 {{expected ')'}}
104 #embed "embed_parsing_errors.c" suffix(xxx
105 // expected-error@-1 {{expected ')'}}
107 #embed "embed_parsing_errors.c" suffix(1/0) // OK: emitted as tokens, not evaluated yet.
108 #embed "embed_parsing_errors.c" suffix(([{}])) // OK: delimiters balanced
109 #embed "embed_parsing_errors.c" suffix(([{)]})
110 // expected-error@-1 {{expected '}'}} expected-note@-1 {{to match this '{'}}
111 #embed "embed_parsing_errors.c" suffix(([{})})
112 // expected-error@-1 {{expected ']'}} expected-note@-1 {{to match this '['}}
113 #embed "embed_parsing_errors.c" suffix(([{}]})
114 // expected-error@-1 {{expected ')'}} expected-note@-1 {{to match this '('}}
115 #embed "embed_parsing_errors.c" suffix() // OK: tokens within parens are optional
116 #embed "embed_parsing_errors.c" suffix)
117 // expected-error@-1 {{expected '('}}
119 #embed "embed_parsing_errors.c" if_empty(1/0) // OK: emitted as tokens, not evaluated yet.
120 #embed "embed_parsing_errors.c" if_empty(([{}])) // OK: delimiters balanced
121 #embed "embed_parsing_errors.c" if_empty(([{)]})
122 // expected-error@-1 {{expected '}'}} expected-note@-1 {{to match this '{'}}
123 #embed "embed_parsing_errors.c" if_empty(([{})})
124 // expected-error@-1 {{expected ']'}} expected-note@-1 {{to match this '['}}
125 #embed "embed_parsing_errors.c" if_empty(([{}]})
126 // expected-error@-1 {{expected ')'}} expected-note@-1 {{to match this '('}}
127 #embed "embed_parsing_errors.c" if_empty() // OK: tokens within parens are optional
128 #embed "embed_parsing_errors.c" if_empty)
129 // expected-error@-1 {{expected '('}}