r232616 - Lex: Don't call getIdentifierInfo on annotation tokens
David Majnemer
david.majnemer at gmail.com
Wed Mar 18 00:53:20 PDT 2015
Author: majnemer
Date: Wed Mar 18 02:53:20 2015
New Revision: 232616
URL: http://llvm.org/viewvc/llvm-project?rev=232616&view=rev
Log:
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.
Added:
cfe/trunk/test/Preprocessor/annotate_in_macro_arg.c
Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=232616&r1=232615&r2=232616&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed Mar 18 02:53:20 2015
@@ -598,7 +598,7 @@ MacroArgs *Preprocessor::ReadFunctionLik
// 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
Added: cfe/trunk/test/Preprocessor/annotate_in_macro_arg.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/annotate_in_macro_arg.c?rev=232616&view=auto
==============================================================================
--- cfe/trunk/test/Preprocessor/annotate_in_macro_arg.c (added)
+++ cfe/trunk/test/Preprocessor/annotate_in_macro_arg.c Wed Mar 18 02:53:20 2015
@@ -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()
More information about the cfe-commits
mailing list