]> granicus.if.org Git - clang/commitdiff
Added -Wdisabled-macro-expansion warning.
authorAbramo Bagnara <abramo.bagnara@gmail.com>
Sun, 1 Jan 2012 22:01:04 +0000 (22:01 +0000)
committerAbramo Bagnara <abramo.bagnara@gmail.com>
Sun, 1 Jan 2012 22:01:04 +0000 (22:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147418 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticLexKinds.td
lib/Lex/Preprocessor.cpp

index 41c67fb1f27bb7192ed9ce1913af1d0dd2005ebd..f4d867d4fe49a0c352934d8018b4007f7f8ccc8e 100644 (file)
@@ -167,6 +167,9 @@ def pp_out_of_date_dependency : Warning<
 def pp_undef_builtin_macro : Warning<"undefining builtin macro">;
 def pp_redef_builtin_macro : Warning<"redefining builtin macro">,
   InGroup<DiagGroup<"builtin-macro-redefined">>;
+def pp_disabled_macro_expansion : Warning<
+  "disabled expansion of recursive macro">, DefaultIgnore,
+  InGroup<DiagGroup<"disabled-macro-expansion">>;
 def pp_macro_not_used : Warning<"macro is not used">, DefaultIgnore,
   InGroup<DiagGroup<"unused-macros">>;
 def warn_pp_undef_identifier : Warning<
index dea7efc7658fecfa8e9b4a8e9aac469920458cbd..90b679846650db69c02031c76bede53894e911bc 100644 (file)
@@ -509,8 +509,10 @@ void Preprocessor::HandleIdentifier(Token &Identifier) {
 
   // If this is a macro to be expanded, do it.
   if (MacroInfo *MI = getMacroInfo(&II)) {
-    if (!DisableMacroExpansion && !Identifier.isExpandDisabled()) {
-      if (MI->isEnabled()) {
+    if (!DisableMacroExpansion) {
+      if (Identifier.isExpandDisabled()) {
+        Diag(Identifier, diag::pp_disabled_macro_expansion);
+      } else if (MI->isEnabled()) {
         if (!HandleMacroExpandedIdentifier(Identifier, MI))
           return;
       } else {
@@ -518,6 +520,7 @@ 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);
       }
     }
   }