Peter Collingbourne | 915df99 | 2015-05-15 18:33:32 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s |
NAKAMURA Takumi | e712f0a | 2015-05-16 00:09:39 +0000 | [diff] [blame] | 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 |
Peter Collingbourne | 915df99 | 2015-05-15 18:33:32 +0000 | [diff] [blame] | 4 | |
Peter Collingbourne | 915df99 | 2015-05-15 18:33:32 +0000 | [diff] [blame] | 5 | int f1() __attribute__((no_sanitize)); // expected-error{{'no_sanitize' attribute takes at least 1 argument}} |
| 6 | |
| 7 | int 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"))) |
| 12 | int 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 Stepanov | 12817e5 | 2017-12-09 01:32:07 +0000 | [diff] [blame] | 19 | // 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 Collingbourne | 915df99 | 2015-05-15 18:33:32 +0000 | [diff] [blame] | 24 | // DUMP-LABEL: FunctionDecl {{.*}} f5 |
Evgeniy Stepanov | 12817e5 | 2017-12-09 01:32:07 +0000 | [diff] [blame] | 25 | // DUMP: NoSanitizeAttr {{.*}} address thread hwaddress |
| 26 | // PRINT: int f5() __attribute__((no_sanitize("address", "thread", "hwaddress"))) |
| 27 | int f5() __attribute__((no_sanitize("address", "thread", "hwaddress"))); |
Peter Collingbourne | 915df99 | 2015-05-15 18:33:32 +0000 | [diff] [blame] | 28 | |
| 29 | // DUMP-LABEL: FunctionDecl {{.*}} f6 |
| 30 | // DUMP: NoSanitizeAttr {{.*}} unknown |
| 31 | // PRINT: int f6() __attribute__((no_sanitize("unknown"))) |
| 32 | int f6() __attribute__((no_sanitize("unknown"))); // expected-warning{{unknown sanitizer 'unknown' ignored}} |