Kostya Serebryany | 85aee96 | 2013-02-26 06:58:27 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | |
| 3 | #define NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) |
| 4 | |
| 5 | #if !__has_attribute(no_sanitize_address) |
| 6 | #error "Should support no_sanitize_address" |
| 7 | #endif |
| 8 | |
| 9 | void noanal_fun() NO_SANITIZE_ADDRESS; |
| 10 | |
| 11 | void noanal_fun_args() __attribute__((no_sanitize_address(1))); // \ |
Aaron Ballman | baec778 | 2013-07-23 19:30:11 +0000 | [diff] [blame] | 12 | // expected-error {{'no_sanitize_address' attribute takes no arguments}} |
Kostya Serebryany | 85aee96 | 2013-02-26 06:58:27 +0000 | [diff] [blame] | 13 | |
| 14 | int noanal_testfn(int y) NO_SANITIZE_ADDRESS; |
| 15 | |
| 16 | int noanal_testfn(int y) { |
| 17 | int x NO_SANITIZE_ADDRESS = y; // \ |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 18 | // expected-error {{'no_sanitize_address' attribute only applies to functions}} |
Kostya Serebryany | 85aee96 | 2013-02-26 06:58:27 +0000 | [diff] [blame] | 19 | return x; |
| 20 | } |
| 21 | |
| 22 | int noanal_test_var NO_SANITIZE_ADDRESS; // \ |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 23 | // expected-error {{'no_sanitize_address' attribute only applies to functions}} |
Kostya Serebryany | 85aee96 | 2013-02-26 06:58:27 +0000 | [diff] [blame] | 24 | |
| 25 | class NoanalFoo { |
| 26 | private: |
| 27 | int test_field NO_SANITIZE_ADDRESS; // \ |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 28 | // expected-error {{'no_sanitize_address' attribute only applies to functions}} |
Kostya Serebryany | 85aee96 | 2013-02-26 06:58:27 +0000 | [diff] [blame] | 29 | void test_method() NO_SANITIZE_ADDRESS; |
| 30 | }; |
| 31 | |
| 32 | class NO_SANITIZE_ADDRESS NoanalTestClass { // \ |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 33 | // expected-error {{'no_sanitize_address' attribute only applies to functions}} |
Kostya Serebryany | 85aee96 | 2013-02-26 06:58:27 +0000 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | void noanal_fun_params(int lvar NO_SANITIZE_ADDRESS); // \ |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 37 | // expected-error {{'no_sanitize_address' attribute only applies to functions}} |