1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -verify
3 [[gsl::suppress("globally")]];
6 [[gsl::suppress("in-a-namespace")]];
9 [[gsl::suppress("readability-identifier-naming")]] void f_() {
11 [[gsl::suppress("type", "bounds")]] {
12 p
= reinterpret_cast<int *>(7);
15 [[gsl::suppress
]] int x
; // expected-error {{'suppress' attribute takes at least 1 argument}}
16 [[gsl::suppress()]] int y
; // expected-error {{'suppress' attribute takes at least 1 argument}}
17 int [[gsl::suppress("r")]] z
; // expected-error {{'suppress' attribute cannot be applied to types}}
18 [[gsl::suppress(f_
)]] float f
; // expected-error {{expected string literal as argument of 'suppress' attribute}}
21 union [[gsl::suppress("type.1")]] U
{
26 // This doesn't really suppress anything but why not?
30 [[clang::suppress("in-a-namespace")]];
33 [[clang::suppress
]] int global
= 42;
35 [[clang::suppress
]] void foo() {
36 [[clang::suppress
]] int *p
;
38 [[clang::suppress
]] int a
= 0; // no-warning
39 [[clang::suppress()]] int b
= 1; // no-warning
40 [[clang::suppress("a")]] int c
= a
+ b
; // no-warning
41 [[clang::suppress("a", "b")]] b
= c
- a
; // no-warning
43 [[clang::suppress("a", "b")]] if (b
== 10) a
+= 4; // no-warning
44 [[clang::suppress
]] while (true) {} // no-warning
45 [[clang::suppress
]] switch (a
) { // no-warning
50 int [[clang::suppress("r")]] z
;
51 // expected-error@-1 {{'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}}
56 class [[clang::suppress("type.1")]] V
{
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.
63 class W
: [[clang::suppress
]] public V
{ // expected-error{{'suppress' attribute cannot be applied to a base specifier}}