blob: 9cbcb03d6ecf1a6d19d331f2cde8b71ebfbfcf68 [file] [log] [blame]
Kostya Serebryany4c0fc992013-02-26 06:58:27 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3#define NO_SANITIZE_MEMORY __attribute__((no_sanitize_memory))
4
5#if !__has_attribute(no_sanitize_memory)
6#error "Should support no_sanitize_memory"
7#endif
8
9void noanal_fun() NO_SANITIZE_MEMORY;
10
11void noanal_fun_args() __attribute__((no_sanitize_memory(1))); // \
Aaron Ballmanb7243382013-07-23 19:30:11 +000012 // expected-error {{'no_sanitize_memory' attribute takes no arguments}}
Kostya Serebryany4c0fc992013-02-26 06:58:27 +000013
14int noanal_testfn(int y) NO_SANITIZE_MEMORY;
15
16int noanal_testfn(int y) {
17 int x NO_SANITIZE_MEMORY = y; // \
Aaron Ballman981ba242014-05-20 14:10:53 +000018 // expected-error {{'no_sanitize_memory' attribute only applies to functions}}
Kostya Serebryany4c0fc992013-02-26 06:58:27 +000019 return x;
20}
21
22int noanal_test_var NO_SANITIZE_MEMORY; // \
Aaron Ballman981ba242014-05-20 14:10:53 +000023 // expected-error {{'no_sanitize_memory' attribute only applies to functions}}
Kostya Serebryany4c0fc992013-02-26 06:58:27 +000024
25class NoanalFoo {
26 private:
27 int test_field NO_SANITIZE_MEMORY; // \
Aaron Ballman981ba242014-05-20 14:10:53 +000028 // expected-error {{'no_sanitize_memory' attribute only applies to functions}}
Kostya Serebryany4c0fc992013-02-26 06:58:27 +000029 void test_method() NO_SANITIZE_MEMORY;
30};
31
32class NO_SANITIZE_MEMORY NoanalTestClass { // \
Aaron Ballman981ba242014-05-20 14:10:53 +000033 // expected-error {{'no_sanitize_memory' attribute only applies to functions}}
Kostya Serebryany4c0fc992013-02-26 06:58:27 +000034};
35
36void noanal_fun_params(int lvar NO_SANITIZE_MEMORY); // \
Aaron Ballman981ba242014-05-20 14:10:53 +000037 // expected-error {{'no_sanitize_memory' attribute only applies to functions}}