diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-11-15 22:45:29 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-11-15 22:45:29 +0000 |
commit | a3e01cf822f7415337e5424af3c6f4c94a12c1b9 (patch) | |
tree | 33e9d9c041d05e24fa06fda646b16a327e3bb159 /clang/test/SemaCXX/warn-unused-variables.cpp | |
parent | 9c13dd027bf2c3ff8d81d60af3e893a01515f1ff (diff) | |
download | bcm5719-llvm-a3e01cf822f7415337e5424af3c6f4c94a12c1b9.tar.gz bcm5719-llvm-a3e01cf822f7415337e5424af3c6f4c94a12c1b9.zip |
PR8455: Handle an attribute between a goto label and a variable declaration per
the GNU documentation: the attribute only appertains to the label if it is
followed by a semicolon. Based on a patch by Aaron Ballman!
llvm-svn: 194869
Diffstat (limited to 'clang/test/SemaCXX/warn-unused-variables.cpp')
-rw-r--r-- | clang/test/SemaCXX/warn-unused-variables.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/warn-unused-variables.cpp b/clang/test/SemaCXX/warn-unused-variables.cpp index 00597f929b2..93d2f6f9563 100644 --- a/clang/test/SemaCXX/warn-unused-variables.cpp +++ b/clang/test/SemaCXX/warn-unused-variables.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -verify %s template<typename T> void f() { T t; t = 17; @@ -128,3 +128,26 @@ namespace ctor_with_cleanups { } #include "Inputs/warn-unused-variables.h" + +namespace PR8455 { + void f() { + A: // expected-warning {{unused label 'A'}} + __attribute__((unused)) int i; // attribute applies to variable + B: // attribute applies to label + __attribute__((unused)); int j; // expected-warning {{unused variable 'j'}} + } + + void g() { + C: // unused label 'C' will not appear here because an error occurs + __attribute__((unused)) + #pragma weak unused_local_static // expected-error {{expected ';' after __attribute__}} + ; + } + + void h() { + D: // expected-warning {{unused label 'D'}} + #pragma weak unused_local_static + __attribute__((unused)) // expected-warning {{declaration does not declare anything}} + ; + } +} |