| 1 |
// RUN: %clang_cc1 -fsyntax-only -Wignored-attributes -verify -std=c23 %s |
| 2 |
// RUN: %clang_cc1 -fsyntax-only -Wignored-attributes -verify -x c++ %s |
| 3 |
// RUN: %clang_cc1 -fsyntax-only -ast-dump %s | FileCheck %s |
| 4 |
|
| 5 |
inline int frob(int x) { return x; } |
| 6 |
|
| 7 |
[[deprecated]] int frob(int); // expected-note 2 {{'frob' has been explicitly marked deprecated here}} |
| 8 |
|
| 9 |
void use1() { |
| 10 |
// Using this should give a deprecation warning, but not a nodiscard warning. |
| 11 |
frob(0); // expected-warning {{'frob' is deprecated}} |
| 12 |
} |
| 13 |
|
| 14 |
[[nodiscard]] int frob(int); |
| 15 |
|
| 16 |
void use2() { |
| 17 |
// This should give both warnings. |
| 18 |
frob(0); // expected-warning {{'frob' is deprecated}} \ |
| 19 |
expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} |
| 20 |
} |
| 21 |
|
| 22 |
[[maybe_unused]] int frob(int); |
| 23 |
|
| 24 |
// Currently, this is only allowed for the standard spelling of the attributes. |
| 25 |
void blob() {} // expected-note {{previous definition is here}} |
| 26 |
__attribute__((deprecated)) void blob(); // expected-warning {{attribute declaration must precede definition}} |
| 27 |
|
| 28 |
// CHECK: FunctionDecl {{.*}} frob |
| 29 |
|
| 30 |
// CHECK: FunctionDecl {{.*}} prev {{.*}} frob |
| 31 |
// CHECK: DeprecatedAttr |
| 32 |
|
| 33 |
// CHECK: FunctionDecl {{.*}} prev {{.*}} frob |
| 34 |
// CHECK: DeprecatedAttr |
| 35 |
// CHECK: WarnUnusedResultAttr |
| 36 |
|
| 37 |
// CHECK: FunctionDecl {{.*}} prev {{.*}} frob |
| 38 |
// CHECK: DeprecatedAttr |
| 39 |
// CHECK: WarnUnusedResultAttr |
| 40 |
// CHECK: UnusedAttr |
| 41 |
|