]> granicus.if.org Git - clang/commitdiff
Don't warn about disabled macro expansion if we see the name of a function-like macro...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 12 Dec 2012 02:46:14 +0000 (02:46 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 12 Dec 2012 02:46:14 +0000 (02:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169960 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/Preprocessor.cpp
test/Preprocessor/warn-disabled-macro-expansion.c

index 4f0b189c8b060a8d6ba4ab3f5ef3bf8a87712dbf..df2c98dd8ea8a4011c6b7a4e15e04a4152201570 100644 (file)
@@ -592,9 +592,7 @@ void Preprocessor::HandleIdentifier(Token &Identifier) {
   // If this is a macro to be expanded, do it.
   if (MacroInfo *MI = getMacroInfo(&II)) {
     if (!DisableMacroExpansion) {
-      if (Identifier.isExpandDisabled()) {
-        Diag(Identifier, diag::pp_disabled_macro_expansion);
-      } else if (MI->isEnabled()) {
+      if (!Identifier.isExpandDisabled() && MI->isEnabled()) {
         if (!HandleMacroExpandedIdentifier(Identifier, MI))
           return;
       } else {
@@ -602,7 +600,8 @@ void Preprocessor::HandleIdentifier(Token &Identifier) {
         // expanded, even if it's in a context where it could be expanded in the
         // future.
         Identifier.setFlag(Token::DisableExpand);
-        Diag(Identifier, diag::pp_disabled_macro_expansion);
+        if (MI->isObjectLike() || isNextPPTokenLParen())
+          Diag(Identifier, diag::pp_disabled_macro_expansion);
       }
     }
   }
index fe8e90c721d9b007ff6ec295e290451ed9041b51..b01b63f6b3f7823f498a6a08cc3fe38dfad79fb3 100644 (file)
@@ -14,6 +14,8 @@
 
 #define c(x) x(0)
 
+#define z(x) (z)(x)
+
 p // expected-warning {{recursive macro}}
 
 a // expected-warning {{recursive macro}}
@@ -25,3 +27,5 @@ g(3) // expected-warning {{recursive macro}}
 h(0) // expected-warning {{recursive macro}}
 
 c(c) // expected-warning {{recursive macro}}
+
+z(z) // ok