1 // RUN: %clang_cc1 -fsyntax-only -Wframe-address -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -Wmost -verify %s
3 // RUN: %clang_cc1 -x c++ -fsyntax-only -Wframe-address -verify %s
4
a(unsigned x)5 void* a(unsigned x) {
6 return __builtin_return_address(0);
7 }
8
b(unsigned x)9 void* b(unsigned x) {
10 return __builtin_return_address(1); // expected-warning{{calling '__builtin_return_address' with a nonzero argument is unsafe}}
11 }
12
c(unsigned x)13 void* c(unsigned x) {
14 return __builtin_frame_address(0);
15 }
16
d(unsigned x)17 void* d(unsigned x) {
18 return __builtin_frame_address(1); // expected-warning{{calling '__builtin_frame_address' with a nonzero argument is unsafe}}
19 }
20
21 #ifdef __cplusplus
RA()22 template<int N> void *RA()
23 {
24 return __builtin_return_address(N); // expected-warning{{calling '__builtin_return_address' with a nonzero argument is unsafe}}
25 }
26
foo()27 void *foo()
28 {
29 return RA<2>(); // expected-note{{in instantiation of function template specialization 'RA<2>' requested here}}
30 }
31 #endif
32