From: David Majnemer Date: Wed, 18 Mar 2015 07:53:20 +0000 (+0000) Subject: Lex: Don't call getIdentifierInfo on annotation tokens X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d9d7196743cf769d262f45f2fe7e4a3b6e686592;p=clang Lex: Don't call getIdentifierInfo on annotation tokens These calls are usually guarded by checks for isAnnotation() but it looks like we missed a spot. This would cause the included test to crash clang. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232616 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index d45143945f..2994176dcb 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/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/test/Preprocessor/annotate_in_macro_arg.c b/test/Preprocessor/annotate_in_macro_arg.c new file mode 100644 index 0000000000..f4aa7d1582 --- /dev/null +++ b/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()