[cfe-commits] r167749 - in /cfe/trunk: lib/Sema/AnalysisBasedWarnings.cpp test/SemaCXX/switch-implicit-fallthrough-cxx98.cpp

Ted Kremenek kremenek at apple.com
Mon Nov 12 15:02:57 PST 2012


I merged this into the LLVM release 3.2 branch, per discussion on cfe-dev.

On Nov 12, 2012, at 1:20 PM, Ted Kremenek <kremenek at apple.com> wrote:

> Author: kremenek
> Date: Mon Nov 12 15:20:48 2012
> New Revision: 167749
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=167749&view=rev
> Log:
> Per discussion on cfe-dev, re-enable suppression of -Wimplicit-fallthrough on C, but also include dialects of C++ earlier than C++11.
> 
> There was enough consensus that we *can* get a good language solution
> to have an annotation outside of C++11, and without this annotation
> this warning doesn't quite mean's completeness criteria for this
> kind of warning.  For now, restrict this warning to C++11 (where an
> annotation exists), and make this the behavior for the LLVM 3.2 release.
> Afterwards, we will hammer out a language solution that we are all
> happy with.
> 
> Modified:
>    cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
>    cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-cxx98.cpp
> 
> Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=167749&r1=167748&r2=167749&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
> +++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Mon Nov 12 15:20:48 2012
> @@ -818,6 +818,18 @@
> 
> 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());
> 
> 
> Modified: cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-cxx98.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-cxx98.cpp?rev=167749&r1=167748&r2=167749&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-cxx98.cpp (original)
> +++ cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-cxx98.cpp Mon Nov 12 15:20:48 2012
> @@ -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) {
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list