brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 5f715a1 Raw
41 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -Wunused -Wused-but-marked-unused -std=c++17 -Wc++17-extensions -verify %s2// RUN: %clang_cc1 -fsyntax-only -Wunused -Wused-but-marked-unused -std=c++11 -Wc++17-extensions -verify -DEXT %s3 4static_assert(__has_cpp_attribute(maybe_unused) == 201603, "");5 6struct [[maybe_unused]] S {};7 8enum E1 {9  EnumVal [[maybe_unused]],10  UsedEnumVal,11};12 13void f() {14  int x; // expected-warning {{unused variable}}15  typedef int I; // expected-warning {{unused typedef 'I'}}16  E1 e;17  switch (e) { // expected-warning {{enumeration value 'UsedEnumVal' not handled in switch}}18  }19 20  // Should not warn about these due to not being used.21  [[maybe_unused]] int y;22  typedef int maybe_unused_int [[maybe_unused]];23 24  // Should not warn about these uses.25  S s;26  maybe_unused_int test;27  y = 12;28  switch (e) {29  case UsedEnumVal:30    break;31  }32}33 34#ifdef EXT35// expected-warning@6 {{use of the 'maybe_unused' attribute is a C++17 extension}}36// expected-warning@9 {{use of the 'maybe_unused' attribute is a C++17 extension}}37// expected-warning@9 {{attributes on an enumerator declaration are a C++17 extension}}38// expected-warning@21 {{use of the 'maybe_unused' attribute is a C++17 extension}}39// expected-warning@22 {{use of the 'maybe_unused' attribute is a C++17 extension}}40#endif41