diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-11-12 23:01:51 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-11-12 23:01:51 +0000 |
commit | 0f8d56a41140b434fe9f666f15990daefc8e7e9c (patch) | |
tree | 5b25943bf3c8d813af8b789beeedef999fe99531 | |
parent | 3486ee0c838935549fa9d76a95ef14eb98995ee0 (diff) | |
download | clang-0f8d56a41140b434fe9f666f15990daefc8e7e9c.tar.gz clang-0f8d56a41140b434fe9f666f15990daefc8e7e9c.tar.bz2 clang-0f8d56a41140b434fe9f666f15990daefc8e7e9c.tar.xz |
Merge in r167749, per discussion on cfe-dev that we want -Wimplicit-fallthrough to only be active for C++11
until we come up with a language annotation for this warning that works outside of C++11.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_32@167775 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/AnalysisBasedWarnings.cpp | 12 | ||||
-rw-r--r-- | test/SemaCXX/switch-implicit-fallthrough-cxx98.cpp | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp index a20817f965..801a1b1e02 100644 --- a/lib/Sema/AnalysisBasedWarnings.cpp +++ b/lib/Sema/AnalysisBasedWarnings.cpp @@ -818,6 +818,18 @@ namespace { static void DiagnoseSwitchLabelsFallthrough(Sema &S, AnalysisDeclContext &AC, bool PerFunction) { + // Only perform this analysis when using C++11. There is no good workflow + // for this warning when not using C++11. There is no good way to silence + // the warning (no attribute is available) unless we are using C++11's support + // for generalized attributes. Once could use pragmas to silence the warning, + // but as a general solution that is gross and not in the spirit of this + // warning. + // + // NOTE: This an intermediate solution. There are on-going discussions on + // how to properly support this warning outside of C++11 with an annotation. + if (!AC.getASTContext().getLangOpts().CPlusPlus0x) + return; + FallthroughMapper FM(S); FM.TraverseStmt(AC.getBody()); diff --git a/test/SemaCXX/switch-implicit-fallthrough-cxx98.cpp b/test/SemaCXX/switch-implicit-fallthrough-cxx98.cpp index 14ffcef704..8b24c4a3b1 100644 --- a/test/SemaCXX/switch-implicit-fallthrough-cxx98.cpp +++ b/test/SemaCXX/switch-implicit-fallthrough-cxx98.cpp @@ -1,5 +1,8 @@ // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -Wimplicit-fallthrough %s +// XFAIL: * +// NOTE: This test is marked XFAIL until we come up with a good language design +// for a worfklow to use this warning outside of C++11. int fallthrough(int n) { switch (n / 10) { |