llvm-project/clang/test/SemaCXX/warn-unused-label-error.cpp
Timm Bäder 320311a01b [clang][parser] Unify rejecting (non) decl stmts with gnu attributes
The comment here was introduced in
a3e01cf822f7415337e5424af3c6f4c94a12c1b9 and suggests that we should
handle declaration statements and non-declaration statements the same,
but don't because ProhibitAttributes() can't handle GNU attributes. That
has recently changed, so remove the comment and handle all statements
the same.

Differential Revision: https://reviews.llvm.org/D99936
2021-04-19 12:43:55 +02:00

27 lines
782 B
C++

// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -verify %s
static int unused_local_static;
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 has occurred
__attribute__((unused)) // expected-error {{an attribute list cannot appear here}}
#pragma weak unused_local_static
;
}
void h() {
D:
#pragma weak unused_local_static
__attribute__((unused)) // expected-error {{'unused' attribute cannot be applied to a statement}}
;
}
}