1 // RUN: %clang_cc1 %s -verify
2 // RUN: %clang_cc1 %s -verify=expected,space -Wcompound-token-split
3 
4 // Ensure we get the same warnings after -frewrite-includes
5 // RUN: %clang_cc1 %s -E -frewrite-includes -o %t
6 // RUN: %clang_cc1 -x c++ %t -verify=expected,space -Wcompound-token-split
7 
8 #ifdef LSQUARE
9 [
10 #else
11 
12 #define VAR(type, name, init) type name = (init)
13 
14 void f() {
15   VAR(int, x, {}); // #1
16   // expected-warning@#1 {{'(' and '{' tokens introducing statement expression appear in different macro expansion contexts}}
17   // expected-note-re@#1 {{{{^}}'{' token is here}}
18   //
19   // FIXME: It would be nice to suppress this when we already warned about the opening '({'.
20   // expected-warning@#1 {{'}' and ')' tokens terminating statement expression appear in different macro expansion contexts}}
21   // expected-note-re@#1 {{{{^}}')' token is here}}
22   //
23   // expected-error@#1 {{cannot initialize a variable of type 'int' with an rvalue of type 'void'}}
24 }
25 
26 #define RPAREN )
27 
28 int f2() {
29   int n = ({ 1; }RPAREN; // expected-warning {{'}' and ')' tokens terminating statement expression appear in different macro expansion contexts}} expected-note {{')' token is here}}
30   return n;
31 }
32 
33 [ // space-warning-re {{{{^}}'[' tokens introducing attribute are separated by whitespace}}
34 #define LSQUARE
35 #include __FILE__
36   noreturn ]]  void g();
37 
38 [[noreturn] ] void h(); // space-warning-re {{{{^}}']' tokens terminating attribute are separated by whitespace}}
39 
40 struct X {};
41 int X:: *p; // space-warning {{'::' and '*' tokens forming pointer to member type are separated by whitespace}}
42 
43 #endif
44