1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2 // RUN: not %clang_cc1 -std=c++11 -ast-dump %s | FileCheck --check-prefix=DUMP %s
3 // RUN: not %clang_cc1 -std=c++11 -ast-print %s | FileCheck --check-prefix=PRINT %s
5 int f1() __attribute__((no_sanitize
)); // expected-error{{'no_sanitize' attribute takes at least 1 argument}}
7 int f2() __attribute__((no_sanitize(1))); // expected-error{{expected string literal as argument of 'no_sanitize' attribute}}
9 __attribute__((no_sanitize("all"))) int global
; // expected-warning{{'no_sanitize' attribute argument 'all' not supported on a global variable}}
10 __attribute__((no_sanitize("unknown"))) int global2
; // expected-warning{{unknown sanitizer 'unknown' ignored}}
12 // DUMP-LABEL: FunctionDecl {{.*}} f3
13 // DUMP: NoSanitizeAttr {{.*}} address
14 // PRINT: int f3() __attribute__((no_sanitize("address")))
15 int f3() __attribute__((no_sanitize("address")));
17 // DUMP-LABEL: FunctionDecl {{.*}} f4
18 // DUMP: NoSanitizeAttr {{.*}} thread
19 // PRINT: {{\[\[}}clang::no_sanitize("thread")]] int f4()
20 [[clang::no_sanitize("thread")]] int f4();
22 // DUMP-LABEL: FunctionDecl {{.*}} f4
23 // DUMP: NoSanitizeAttr {{.*}} hwaddress
24 // PRINT: {{\[\[}}clang::no_sanitize("hwaddress")]] int f4()
25 [[clang::no_sanitize("hwaddress")]] int f4();
27 // DUMP-LABEL: FunctionDecl {{.*}} f5
28 // DUMP: NoSanitizeAttr {{.*}} address thread hwaddress
29 // PRINT: int f5() __attribute__((no_sanitize("address", "thread", "hwaddress")))
30 int f5() __attribute__((no_sanitize("address", "thread", "hwaddress")));
32 // DUMP-LABEL: FunctionDecl {{.*}} f6
33 // DUMP: NoSanitizeAttr {{.*}} unknown
34 // PRINT: int f6() __attribute__((no_sanitize("unknown")))
35 int f6() __attribute__((no_sanitize("unknown"))); // expected-warning{{unknown sanitizer 'unknown' ignored}}
37 // DUMP-LABEL: FunctionDecl {{.*}} f7
38 // DUMP: NoSanitizeAttr {{.*}} memtag
39 // PRINT: {{\[\[}}clang::no_sanitize("memtag")]] int f7()
40 [[clang::no_sanitize("memtag")]] int f7();