-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new warning for compound punctuation tokens that are split across…
… macro expansions or split by whitespace. For example: #define FOO(x) (x) FOO({}); ... forms a statement-expression after macro expansion. This warning applies to '({' and '})' delimiting statement-expressions, '[[' and ']]' delimiting attributes, and '::*' introducing a pointer-to-member. The warning for forming these compound tokens across macro expansions (or across files!) is enabled by default; the warning for whitespace within the tokens is not, but is included in -Wall. Differential Revision: https://reviews.llvm.org/D86751
- Loading branch information
Showing
11 changed files
with
146 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// RUN: %clang_cc1 %s -verify | ||
// RUN: %clang_cc1 %s -verify=expected,space -Wcompound-token-split | ||
// RUN: %clang_cc1 %s -verify=expected,space -Wall | ||
|
||
#ifdef LSQUARE | ||
[ // expected-note {{second '[' token is here}} | ||
#else | ||
|
||
#define VAR(type, name, init) type name = (init) | ||
|
||
void f() { | ||
VAR(int, x, {}); // #1 | ||
// expected-warning@#1 {{'(' and '{' tokens introducing statement expression appear in different macro expansion contexts}} | ||
// expected-note-re@#1 {{{{^}}'{' token is here}} | ||
// | ||
// FIXME: It would be nice to suppress this when we already warned about the opening '({'. | ||
// expected-warning@#1 {{'}' and ')' tokens terminating statement expression appear in different macro expansion contexts}} | ||
// expected-note-re@#1 {{{{^}}')' token is here}} | ||
// | ||
// expected-error@#1 {{cannot initialize a variable of type 'int' with an rvalue of type 'void'}} | ||
} | ||
|
||
#define RPAREN ) | ||
|
||
int f2() { | ||
int n = ({ 1; }RPAREN; // expected-warning {{'}' and ')' tokens terminating statement expression appear in different macro expansion contexts}} expected-note {{')' token is here}} | ||
return n; | ||
} | ||
|
||
[ // expected-warning-re {{{{^}}'[' tokens introducing attribute appear in different source files}} | ||
#define LSQUARE | ||
#include __FILE__ | ||
noreturn ]] void g(); | ||
|
||
[[noreturn] ] void h(); // space-warning-re {{{{^}}']' tokens terminating attribute are separated by whitespace}} | ||
|
||
struct X {}; | ||
int X:: *p; // space-warning {{'::' and '*' tokens forming pointer to member type are separated by whitespace}} | ||
|
||
#endif |