diff options
-rw-r--r-- | lib/Lex/MacroInfo.cpp | 11 | ||||
-rw-r--r-- | test/Preprocessor/macro_misc.c | 17 |
2 files changed, 25 insertions, 3 deletions
diff --git a/lib/Lex/MacroInfo.cpp b/lib/Lex/MacroInfo.cpp index de19ff502a..df89450f5a 100644 --- a/lib/Lex/MacroInfo.cpp +++ b/lib/Lex/MacroInfo.cpp @@ -49,9 +49,14 @@ bool MacroInfo::isIdenticalTo(const MacroInfo &Other, Preprocessor &PP) const { for (unsigned i = 0, e = ReplacementTokens.size(); i != e; ++i) { const Token &A = ReplacementTokens[i]; const Token &B = Other.ReplacementTokens[i]; - if (A.getKind() != B.getKind() || - A.isAtStartOfLine() != B.isAtStartOfLine() || - A.hasLeadingSpace() != B.hasLeadingSpace()) + if (A.getKind() != B.getKind()) + return false; + + // If this isn't the first first token, check that the whitespace and + // start-of-line characteristics match. + if (i != 0 && + (A.isAtStartOfLine() != B.isAtStartOfLine() || + A.hasLeadingSpace() != B.hasLeadingSpace())) return false; // If this is an identifier, it is easy. diff --git a/test/Preprocessor/macro_misc.c b/test/Preprocessor/macro_misc.c index 66e9e3fcf3..147e827df3 100644 --- a/test/Preprocessor/macro_misc.c +++ b/test/Preprocessor/macro_misc.c @@ -4,3 +4,20 @@ #ifdef defined #endif + + +// PR3764 + +// This should not produce a redefinition warning. +#define FUNC_LIKE(a) (a) +#define FUNC_LIKE(a)(a) + +// This either. +#define FUNC_LIKE2(a)\ +(a) +#define FUNC_LIKE2(a) (a) + +// This should. +#define FUNC_LIKE3(a) ( a) // expected-note {{previous definition is here}} +#define FUNC_LIKE3(a) (a) // expected-warning {{'FUNC_LIKE3' macro redefined}} + |