[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / attr-no-sanitize-address.cpp
blob9430bdc2a2e155b251fc81738f0f85a741ffd525
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 #define NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
5 #if !__has_attribute(no_sanitize_address)
6 #error "Should support no_sanitize_address"
7 #endif
9 void no_analyze() NO_SANITIZE_ADDRESS;
11 void no_analyze_alt() __attribute__((__no_sanitize_address__));
13 void no_analyze_args() __attribute__((no_sanitize_address(1))); // \
14 // expected-error {{'no_sanitize_address' attribute takes no arguments}}
16 int no_analyze_testfn(int y) NO_SANITIZE_ADDRESS;
18 int no_analyze_testfn(int y) {
19 int x NO_SANITIZE_ADDRESS = y; // \
20 // expected-error {{'no_sanitize_address' attribute only applies to functions}}
21 return x;
24 class NoAnalyzeFoo {
25 private:
26 int test_field NO_SANITIZE_ADDRESS; // \
27 // expected-error {{'no_sanitize_address' attribute only applies to functions}}
28 void test_method() NO_SANITIZE_ADDRESS;
31 class NO_SANITIZE_ADDRESS NoAnalyzeTestClass { // \
32 // expected-error {{'no_sanitize_address' attribute only applies to functions}}
35 void no_analyze_params(int lvar NO_SANITIZE_ADDRESS); // \
36 // expected-error {{'no_sanitize_address' attribute only applies to functions}}