blob: 7301412db2eda96521705f426deb07819348285d [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
Dimitry Andricb1aa87e2016-01-03 15:55:40 +00008
Aaron Ballmanb0573602019-05-21 22:43:48 +00009void no_analyze() NO_SANITIZE_MEMORY;
Dimitry Andricb1aa87e2016-01-03 15:55:40 +000010
Aaron Ballmanb0573602019-05-21 22:43:48 +000011void no_analyze_alt() __attribute__((__no_sanitize_memory__));
Dimitry Andricb1aa87e2016-01-03 15:55:40 +000012
Aaron Ballmanb0573602019-05-21 22:43:48 +000013void no_analyze_args() __attribute__((no_sanitize_memory(1))); // \
Dimitry Andricb1aa87e2016-01-03 15:55:40 +000014 // expected-error {{'no_sanitize_memory' attribute takes no arguments}}
15
Aaron Ballmanb0573602019-05-21 22:43:48 +000016int no_analyze_testfn(int y) NO_SANITIZE_MEMORY;
Kostya Serebryany4c0fc992013-02-26 06:58:27 +000017
Aaron Ballmanb0573602019-05-21 22:43:48 +000018int no_analyze_testfn(int y) {
Kostya Serebryany4c0fc992013-02-26 06:58:27 +000019 int x NO_SANITIZE_MEMORY = y; // \
Aaron Ballman981ba242014-05-20 14:10:53 +000020 // expected-error {{'no_sanitize_memory' attribute only applies to functions}}
Kostya Serebryany4c0fc992013-02-26 06:58:27 +000021 return x;
22}
23
Aaron Ballmanb0573602019-05-21 22:43:48 +000024int no_analyze_test_var NO_SANITIZE_MEMORY; // \
Aaron Ballman981ba242014-05-20 14:10:53 +000025 // expected-error {{'no_sanitize_memory' attribute only applies to functions}}
Kostya Serebryany4c0fc992013-02-26 06:58:27 +000026
Aaron Ballmanb0573602019-05-21 22:43:48 +000027class NoAnalyzeFoo {
Kostya Serebryany4c0fc992013-02-26 06:58:27 +000028 private:
29 int test_field NO_SANITIZE_MEMORY; // \
Aaron Ballman981ba242014-05-20 14:10:53 +000030 // expected-error {{'no_sanitize_memory' attribute only applies to functions}}
Kostya Serebryany4c0fc992013-02-26 06:58:27 +000031 void test_method() NO_SANITIZE_MEMORY;
32};
33
Aaron Ballmanb0573602019-05-21 22:43:48 +000034class NO_SANITIZE_MEMORY NoAnalyzeTestClass { // \
Aaron Ballman981ba242014-05-20 14:10:53 +000035 // expected-error {{'no_sanitize_memory' attribute only applies to functions}}
Kostya Serebryany4c0fc992013-02-26 06:58:27 +000036};
37
Aaron Ballmanb0573602019-05-21 22:43:48 +000038void no_analyze_params(int lvar NO_SANITIZE_MEMORY); // \
Aaron Ballman981ba242014-05-20 14:10:53 +000039 // expected-error {{'no_sanitize_memory' attribute only applies to functions}}