r178543 - Fixed "fallthrough annotation does not directly precede switch label" warning in
Alexander Kornienko
alexfh at google.com
Tue Apr 2 10:17:54 PDT 2013
No, there are no serious reasons for this. I can move it to the main test
file for the feature. Please take a look at the patch:
Index: test/SemaCXX/switch-implicit-fallthrough-regression.cpp
===================================================================
--- test/SemaCXX/switch-implicit-fallthrough-regression.cpp (revision
178546)
+++ test/SemaCXX/switch-implicit-fallthrough-regression.cpp (working copy)
@@ -1,17 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough
%s
-
-void f() {
- class C {
- void f(int x) {
- switch (x) {
- case 0:
- x++;
- [[clang::fallthrough]]; // expected-no-diagnostics
- case 1:
- x++;
- break;
- }
- }
- };
-}
-
Index: test/SemaCXX/switch-implicit-fallthrough.cpp
===================================================================
--- test/SemaCXX/switch-implicit-fallthrough.cpp (revision 178546)
+++ test/SemaCXX/switch-implicit-fallthrough.cpp (working copy)
@@ -247,3 +247,21 @@
}
return n;
}
+
+// Fallthrough annotations in local classes used to generate "fallthrough
+// annotation does not directly precede switch label" warning.
+void fallthrough_in_local_class() {
+ class C {
+ void f(int x) {
+ switch (x) {
+ case 0:
+ x++;
+ [[clang::fallthrough]]; // expected-no-diagnostics
+ case 1:
+ x++;
+ break;
+ }
+ }
+ };
+}
+
On Tue, Apr 2, 2013 at 6:16 PM, Jordan Rose <jordan_rose at apple.com> wrote:
> Is there any reason why this can't go in one of the existing test files?
> We try not to increase the number of test files at a whim because each one
> has a nonzero startup time.
>
> On Apr 2, 2013, at 8:20 , Alexander Kornienko <alexfh at google.com> wrote:
>
> > Author: alexfh
> > Date: Tue Apr 2 10:20:32 2013
> > New Revision: 178543
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=178543&view=rev
> > Log:
> > Fixed "fallthrough annotation does not directly precede switch label"
> warning in
> > case when [[clang::fallthrough]]; is used in a method of a local class.
> >
> > Added:
> > cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-regression.cpp
> > Modified:
> > cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
> >
> > Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=178543&r1=178542&r2=178543&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
> > +++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Tue Apr 2 10:20:32 2013
> > @@ -817,6 +817,10 @@ namespace {
> > return true;
> > }
> >
> > + // We don't want to traverse local type declarations. We analyze
> their
> > + // methods separately.
> > + bool TraverseDecl(Decl *D) { return true; }
> > +
> > private:
> >
> > static const AttributedStmt *asFallThroughAttr(const Stmt *S) {
> >
> > Added: cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-regression.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-regression.cpp?rev=178543&view=auto
> >
> ==============================================================================
> > --- cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-regression.cpp
> (added)
> > +++ cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-regression.cpp
> Tue Apr 2 10:20:32 2013
> > @@ -0,0 +1,17 @@
> > +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11
> -Wimplicit-fallthrough %s
> > +
> > +void f() {
> > + class C {
> > + void f(int x) {
> > + switch (x) {
> > + case 0:
> > + x++;
> > + [[clang::fallthrough]]; // expected-no-diagnostics
> > + case 1:
> > + x++;
> > + break;
> > + }
> > + }
> > + };
> > +}
> > +
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
--
Alexander Kornienko | Software Engineer | alexfh at google.com | +49 151 221
77 957
Google Germany GmbH | Dienerstr. 12 | 80331 München
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130402/41104dea/attachment.html>
More information about the cfe-commits
mailing list