]> granicus.if.org Git - clang/commitdiff
fix a case where macro expansion should be disabled, patch by
authorChris Lattner <sabre@nondot.org>
Fri, 26 Mar 2010 17:49:16 +0000 (17:49 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 26 Mar 2010 17:49:16 +0000 (17:49 +0000)
Abramo Bagnara!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99626 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/PPMacroExpansion.cpp
test/Preprocessor/macro_disable.c

index ffae8ab6afb1d858ec9bcd614ccd48c86366752b..1c6a5ad0ebce705a7ba8a07b29a80ac6ba06696c 100644 (file)
@@ -258,10 +258,13 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier,
                                        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.
index 95f4784398ec903302fc5e3166c076273cc91a1f..d7859dca77e564f93c121b3a70f02b0551f11a26 100644 (file)
@@ -34,4 +34,10 @@ a: M_0(1)(2)(3)(4)(5);
 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