[cfe-commits] [PATCH] Remove -Wdisabled-macro-expansion
Eli Friedman
eli.friedman at gmail.com
Mon Oct 29 17:53:00 PDT 2012
Per subject, remove -Wdisabled-macro-expansion. It's triggering on
normal uses of stdbool.h in C++ (at least, however normal it is to use
stdbool.h in C++). Because we're trying to encourage people to use
-Weverything, it isn't acceptable for it to trigger warnings for usage
of headers included with the compiler, and as far as I can tell, there
isn't any way to fix the header. (See patch for a testcase that
checks we don't trigger any warnings from stdbool.h.)
I'm planning to commit this unless someone has an alternative suggestion.
(For reference, <rdar://problem/12435773>.)
-Eli
-------------- next part --------------
Index: test/Preprocessor/warn-disabled-macro-expansion.c
===================================================================
--- test/Preprocessor/warn-disabled-macro-expansion.c (revision 166954)
+++ test/Preprocessor/warn-disabled-macro-expansion.c (working copy)
@@ -1,27 +0,0 @@
-// RUN: %clang_cc1 %s -E -Wdisabled-macro-expansion -verify
-
-#define p p
-
-#define a b
-#define b a
-
-#define f(a) a
-
-#define g(b) a
-
-#define h(x) i(x)
-#define i(y) i(y)
-
-#define c(x) x(0)
-
-p // expected-warning {{recursive macro}}
-
-a // expected-warning {{recursive macro}}
-
-f(2)
-
-g(3) // expected-warning {{recursive macro}}
-
-h(0) // expected-warning {{recursive macro}}
-
-c(c) // expected-warning {{recursive macro}}
Index: test/Headers/stdbool.cpp
===================================================================
--- test/Headers/stdbool.cpp (revision 166954)
+++ test/Headers/stdbool.cpp (working copy)
@@ -1,8 +1,14 @@
// RUN: %clang_cc1 -E -dM %s | FileCheck --check-prefix=CHECK-GNU-COMPAT %s
// RUN: %clang_cc1 -std=c++98 -E -dM %s | FileCheck --check-prefix=CHECK-CONFORMING %s
+// RUN: %clang_cc1 -Weverything -verify %s
+// expected-no-diagnostics
+
#include <stdbool.h>
#define zzz
+extern bool x;
+bool x = zzz false;
+
// CHECK-GNU-COMPAT: #define _Bool bool
// CHECK-GNU-COMPAT: #define bool bool
// CHECK-GNU-COMPAT: #define false false
Index: include/clang/Basic/DiagnosticLexKinds.td
===================================================================
--- include/clang/Basic/DiagnosticLexKinds.td (revision 166954)
+++ include/clang/Basic/DiagnosticLexKinds.td (working copy)
@@ -220,9 +220,6 @@
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: lib/Lex/Preprocessor.cpp
===================================================================
--- lib/Lex/Preprocessor.cpp (revision 166954)
+++ lib/Lex/Preprocessor.cpp (working copy)
@@ -590,10 +590,8 @@
// 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 (!DisableMacroExpansion && !Identifier.isExpandDisabled()) {
+ if (MI->isEnabled()) {
if (!HandleMacroExpandedIdentifier(Identifier, MI))
return;
} else {
@@ -601,7 +599,6 @@
// 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);
}
}
}
Index: lib/Lex/PPMacroExpansion.cpp
===================================================================
--- lib/Lex/PPMacroExpansion.cpp (revision 166954)
+++ lib/Lex/PPMacroExpansion.cpp (working copy)
@@ -453,10 +453,8 @@
// unexpandable.
if (IdentifierInfo *NewII = Identifier.getIdentifierInfo()) {
if (MacroInfo *NewMI = getMacroInfo(NewII))
- if (!NewMI->isEnabled() || NewMI == MI) {
+ if (!NewMI->isEnabled() || NewMI == MI)
Identifier.setFlag(Token::DisableExpand);
- Diag(Identifier, diag::pp_disabled_macro_expansion);
- }
}
// Since this is not an identifier token, it can't be macro expanded, so
More information about the cfe-commits
mailing list