| 1 | // RUN: %clang_cc1 -fsyntax-only -Wunused -Wused-but-marked-unused -std=c++17 -Wc++17-extensions -verify %s |
| 2 | // RUN: %clang_cc1 -fsyntax-only -Wunused -Wused-but-marked-unused -std=c++11 -Wc++17-extensions -verify -DEXT %s |
| 3 | |
| 4 | static_assert(__has_cpp_attribute(maybe_unused) == 201603, ""); |
| 5 | |
| 6 | struct [[maybe_unused]] S {}; |
| 7 | |
| 8 | void f() { |
| 9 | int x; // expected-warning {{unused variable}} |
| 10 | typedef int I; // expected-warning {{unused typedef 'I'}} |
| 11 | |
| 12 | // Should not warn about these due to not being used. |
| 13 | [[maybe_unused]] int y; |
| 14 | typedef int maybe_unused_int [[maybe_unused]]; |
| 15 | |
| 16 | // Should not warn about these uses. |
| 17 | S s; |
| 18 | maybe_unused_int test; |
| 19 | y = 12; |
| 20 | } |
| 21 | |
| 22 | #ifdef EXT |
| 23 | // expected-warning@6 {{use of the 'maybe_unused' attribute is a C++17 extension}} |
| 24 | // expected-warning@13 {{use of the 'maybe_unused' attribute is a C++17 extension}} |
| 25 | // expected-warning@14 {{use of the 'maybe_unused' attribute is a C++17 extension}} |
| 26 | #endif |
| 27 | |