blob: 02bc9a9e7f8f4bffa1f0c320403357e14a4fc530 [file] [log] [blame]
Peter Collingbourne915df992015-05-15 18:33:32 +00001// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
NAKAMURA Takumie712f0a2015-05-16 00:09:39 +00002// 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
Peter Collingbourne915df992015-05-15 18:33:32 +00004
Peter Collingbourne915df992015-05-15 18:33:32 +00005int f1() __attribute__((no_sanitize)); // expected-error{{'no_sanitize' attribute takes at least 1 argument}}
6
7int f2() __attribute__((no_sanitize(1))); // expected-error{{'no_sanitize' attribute requires a string}}
8
9// DUMP-LABEL: FunctionDecl {{.*}} f3
10// DUMP: NoSanitizeAttr {{.*}} address
11// PRINT: int f3() __attribute__((no_sanitize("address")))
12int f3() __attribute__((no_sanitize("address")));
13
14// DUMP-LABEL: FunctionDecl {{.*}} f4
15// DUMP: NoSanitizeAttr {{.*}} thread
16// PRINT: int f4() {{\[\[}}clang::no_sanitize("thread")]]
17[[clang::no_sanitize("thread")]] int f4();
18
Evgeniy Stepanov12817e52017-12-09 01:32:07 +000019// DUMP-LABEL: FunctionDecl {{.*}} f4
20// DUMP: NoSanitizeAttr {{.*}} hwaddress
21// PRINT: int f4() {{\[\[}}clang::no_sanitize("hwaddress")]]
22[[clang::no_sanitize("hwaddress")]] int f4();
23
Peter Collingbourne915df992015-05-15 18:33:32 +000024// DUMP-LABEL: FunctionDecl {{.*}} f5
Evgeniy Stepanov12817e52017-12-09 01:32:07 +000025// DUMP: NoSanitizeAttr {{.*}} address thread hwaddress
26// PRINT: int f5() __attribute__((no_sanitize("address", "thread", "hwaddress")))
27int f5() __attribute__((no_sanitize("address", "thread", "hwaddress")));
Peter Collingbourne915df992015-05-15 18:33:32 +000028
29// DUMP-LABEL: FunctionDecl {{.*}} f6
30// DUMP: NoSanitizeAttr {{.*}} unknown
31// PRINT: int f6() __attribute__((no_sanitize("unknown")))
32int f6() __attribute__((no_sanitize("unknown"))); // expected-warning{{unknown sanitizer 'unknown' ignored}}