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 | 123bec89ab8fd59364adcd9fea8d5b11791c6310 (patch) | |
tree | dc8789db0bab6c2a87c8f9fa6d0fdffbffaefd6f /clang | |
parent | da38930cf37c38870e9776f15dbe32b3192ff970 (diff) | |
download | bcm5719-llvm-123bec89ab8fd59364adcd9fea8d5b11791c6310.tar.gz bcm5719-llvm-123bec89ab8fd59364adcd9fea8d5b11791c6310.zip |
Added -Wdisabled-macro-expansion warning.
llvm-svn: 147418
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Basic/DiagnosticLexKinds.td | 3 | ||||
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 7 |
2 files changed, 8 insertions, 2 deletions
diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td index 41c67fb1f27..f4d867d4fe4 100644 --- a/clang/include/clang/Basic/DiagnosticLexKinds.td +++ b/clang/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/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index dea7efc7658..90b67984665 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/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); } } } |