[cfe-commits] r99626 - in /cfe/trunk: lib/Lex/PPMacroExpansion.cpp test/Preprocessor/macro_disable.c
Chris Lattner
sabre at nondot.org
Fri Mar 26 10:49:17 PDT 2010
Author: lattner
Date: Fri Mar 26 12:49:16 2010
New Revision: 99626
URL: http://llvm.org/viewvc/llvm-project?rev=99626&view=rev
Log:
fix a case where macro expansion should be disabled, patch by
Abramo Bagnara!
Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/Preprocessor/macro_disable.c
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=99626&r1=99625&r2=99626&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri Mar 26 12:49:16 2010
@@ -258,10 +258,13 @@
InstantiationEnd,Identifier.getLength());
Identifier.setLocation(Loc);
- // If this is #define X X, we must mark the result as unexpandible.
- if (IdentifierInfo *NewII = Identifier.getIdentifierInfo())
- if (getMacroInfo(NewII) == MI)
- Identifier.setFlag(Token::DisableExpand);
+ // If this is a disabled macro or #define X X, we must mark the result as
+ // unexpandable.
+ if (IdentifierInfo *NewII = Identifier.getIdentifierInfo()) {
+ if (MacroInfo *NewMI = getMacroInfo(NewII))
+ if (!NewMI->isEnabled() || NewMI == MI)
+ Identifier.setFlag(Token::DisableExpand);
+ }
// Since this is not an identifier token, it can't be macro expanded, so
// we're done.
Modified: cfe/trunk/test/Preprocessor/macro_disable.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_disable.c?rev=99626&r1=99625&r2=99626&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/macro_disable.c (original)
+++ cfe/trunk/test/Preprocessor/macro_disable.c Fri Mar 26 12:49:16 2010
@@ -34,4 +34,10 @@
b: M_0(5)(4)(3)(2)(1);
// CHECK: a: 2 + M_0(3)(4)(5);
-// CHECK: b: 4 + 4 + 3 + 2 + 1 + M_0(3)(2)(1);
\ No newline at end of file
+// CHECK: b: 4 + 4 + 3 + 2 + 1 + M_0(3)(2)(1);
+
+#define n(v) v
+#define l m
+#define m l a
+c: n(m) X
+// CHECK: c: m a X
More information about the cfe-commits
mailing list