65 lines · cpp
1// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -verify2 3[[gsl::suppress("globally")]];4 5namespace N {6[[gsl::suppress("in-a-namespace")]];7}8 9[[gsl::suppress("readability-identifier-naming")]] void f_() {10 int *p;11 [[gsl::suppress("type", "bounds")]] {12 p = reinterpret_cast<int *>(7);13 }14 15 [[gsl::suppress]] int x; // expected-error {{'gsl::suppress' attribute takes at least 1 argument}}16 [[gsl::suppress()]] int y; // expected-error {{'gsl::suppress' attribute takes at least 1 argument}}17 int [[gsl::suppress("r")]] z; // expected-error {{'gsl::suppress' attribute cannot be applied to types}}18 [[gsl::suppress(f_)]] float f; // expected-error {{expected string literal as argument of 'suppress' attribute}}19}20 21union [[gsl::suppress("type.1")]] U {22 int i;23 float f;24};25 26// This doesn't really suppress anything but why not?27[[clang::suppress]];28 29namespace N {30[[clang::suppress("in-a-namespace")]];31} // namespace N32 33[[clang::suppress]] int global = 42;34 35[[clang::suppress]] void foo() {36 [[clang::suppress]] int *p;37 38 [[clang::suppress]] int a = 0; // no-warning39 [[clang::suppress()]] int b = 1; // no-warning40 [[clang::suppress("a")]] int c = a + b; // no-warning41 [[clang::suppress("a", "b")]] b = c - a; // no-warning42 43 [[clang::suppress("a", "b")]] if (b == 10) a += 4; // no-warning44 [[clang::suppress]] while (true) {} // no-warning45 [[clang::suppress]] switch (a) { // no-warning46 default:47 c -= 10;48 }49 50 int [[clang::suppress("r")]] z;51 // expected-error@-1 {{'clang::suppress' attribute cannot be applied to types}}52 [[clang::suppress(foo)]] float f;53 // expected-error@-1 {{expected string literal as argument of 'suppress' attribute}}54}55 56class [[clang::suppress("type.1")]] V {57 int i;58 float f;59};60 61// FIXME: There's no good reason why we shouldn't support this case.62// But it doesn't look like clang generally supports such attributes yet.63class W : [[clang::suppress]] public V { // expected-error{{'clang::suppress' attribute cannot be applied to a base specifier}}64};65