]> granicus.if.org Git - clang/commitdiff
Lex: Don't call getIdentifierInfo on annotation tokens
authorDavid Majnemer <david.majnemer@gmail.com>
Wed, 18 Mar 2015 07:53:20 +0000 (07:53 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Wed, 18 Mar 2015 07:53:20 +0000 (07:53 +0000)
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

lib/Lex/PPMacroExpansion.cpp
test/Preprocessor/annotate_in_macro_arg.c [new file with mode: 0644]

index d45143945f9a0b29586583e3bded82027db0b784..2994176dcb27d86e98173943e71aa85f8db5727a 100644 (file)
@@ -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 (file)
index 0000000..f4aa7d1
--- /dev/null
@@ -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()