44 lines · cpp
1// RUN: %clang_cc1 %s -verify2// RUN: %clang_cc1 %s -verify=expected,space -Wcompound-token-split3 4// Ensure we get the same warnings after -frewrite-includes5// RUN: %clang_cc1 %s -E -frewrite-includes -o %t6// RUN: %clang_cc1 -x c++ %t -verify=expected,space -Wcompound-token-split7 8#ifdef LSQUARE9[10#else11 12#define VAR(type, name, init) type name = (init)13 14void f() {15 VAR(int, x, {}); // #116 // 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 28int 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 LSQUARE35#include __FILE__36 noreturn ]] void g();37 38[[noreturn] ] void h(); // space-warning-re {{{{^}}']' tokens terminating attribute are separated by whitespace}}39 40struct X {};41int X:: *p; // space-warning {{'::' and '*' tokens forming pointer to member type are separated by whitespace}}42 43#endif44