diff options
author | Abramo Bagnara <abramo.bagnara@gmail.com> | 2012-01-01 22:01:04 +0000 |
---|---|---|
committer | Abramo Bagnara <abramo.bagnara@gmail.com> | 2012-01-01 22:01:04 +0000 |
commit | 163ada8a0f56a9928feaaaf11a4eb7d41f65a0e2 (patch) | |
tree | 80a9954f26a41296a1cf42b8966bc44a75f7ce1b | |
parent | dba9361891ab147b6ea658c1834bc1d660f5226b (diff) |
Added -Wdisabled-macro-expansion warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147418 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/DiagnosticLexKinds.td | 3 | ||||
-rw-r--r-- | lib/Lex/Preprocessor.cpp | 7 |
2 files changed, 8 insertions, 2 deletions
diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td index 41c67fb1f2..f4d867d4fe 100644 --- a/include/clang/Basic/DiagnosticLexKinds.td +++ b/include/clang/Basic/DiagnosticLexKinds.td @@ -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< diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index dea7efc765..90b6798466 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -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); } } } |