xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/warn-unused-label-error.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -verify %s
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc static int unused_local_static;
4*0a6a1f1dSLionel Sambuc 
5*0a6a1f1dSLionel Sambuc namespace PR8455 {
f()6*0a6a1f1dSLionel Sambuc   void f() {
7*0a6a1f1dSLionel Sambuc     A: // expected-warning {{unused label 'A'}}
8*0a6a1f1dSLionel Sambuc       __attribute__((unused)) int i; // attribute applies to variable
9*0a6a1f1dSLionel Sambuc     B: // attribute applies to label
10*0a6a1f1dSLionel Sambuc       __attribute__((unused)); int j; // expected-warning {{unused variable 'j'}}
11*0a6a1f1dSLionel Sambuc   }
12*0a6a1f1dSLionel Sambuc 
g()13*0a6a1f1dSLionel Sambuc   void g() {
14*0a6a1f1dSLionel Sambuc     C: // unused label 'C' will not appear here because an error has occurred
15*0a6a1f1dSLionel Sambuc       __attribute__((unused))
16*0a6a1f1dSLionel Sambuc       #pragma weak unused_local_static  // expected-error {{expected ';' after __attribute__}}
17*0a6a1f1dSLionel Sambuc       ;
18*0a6a1f1dSLionel Sambuc   }
19*0a6a1f1dSLionel Sambuc 
h()20*0a6a1f1dSLionel Sambuc   void h() {
21*0a6a1f1dSLionel Sambuc     D: // expected-warning {{unused label 'D'}}
22*0a6a1f1dSLionel Sambuc       #pragma weak unused_local_static
23*0a6a1f1dSLionel Sambuc       __attribute__((unused))  // expected-warning {{declaration does not declare anything}}
24*0a6a1f1dSLionel Sambuc       ;
25*0a6a1f1dSLionel Sambuc   }
26*0a6a1f1dSLionel Sambuc }
27