diff options
-rw-r--r-- | clang/lib/Lex/PPMacroExpansion.cpp | 2 | ||||
-rw-r--r-- | clang/test/Preprocessor/annotate_in_macro_arg.c | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index d45143945f9..2994176dcb2 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -598,7 +598,7 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName, // If this is a comment token in the argument list and we're just in // -C mode (not -CC mode), discard the comment. continue; - } else if (Tok.getIdentifierInfo() != nullptr) { + } else if (!Tok.isAnnotation() && Tok.getIdentifierInfo() != nullptr) { // Reading macro arguments can cause macros that we are currently // expanding from to be popped off the expansion stack. Doing so causes // them to be reenabled for expansion. Here we record whether any diff --git a/clang/test/Preprocessor/annotate_in_macro_arg.c b/clang/test/Preprocessor/annotate_in_macro_arg.c new file mode 100644 index 00000000000..f4aa7d15826 --- /dev/null +++ b/clang/test/Preprocessor/annotate_in_macro_arg.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -verify %s +#define M1() // expected-note{{macro 'M1' defined here}} + +M1( // expected-error{{unterminated function-like macro invocation}} + +#if M1() // expected-error{{expected value in expression}} +#endif +#pragma pack() |