• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -fsyntax-only -Wunused -Wused-but-marked-unused -std=c++1z -Wc++1z-extensions -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -Wunused -Wused-but-marked-unused -std=c++11 -Wc++1z-extensions -verify -DEXT %s
3 
4 static_assert(__has_cpp_attribute(maybe_unused) == 201603, "");
5 
6 struct [[maybe_unused]] S {};
7 
f()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++1z extension}}
24 // expected-warning@13 {{use of the 'maybe_unused' attribute is a C++1z extension}}
25 // expected-warning@14 {{use of the 'maybe_unused' attribute is a C++1z extension}}
26 #endif
27