[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Sema / builtin-returnaddress.c
blob16d2a517ac12f2eca3f9ed3ef8e01bd7678af2b4
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
5 void* a(unsigned x) {
6 return __builtin_return_address(0);
9 void* b(unsigned x) {
10 return __builtin_return_address(1); // expected-warning{{calling '__builtin_return_address' with a nonzero argument is unsafe}}
13 void* c(unsigned x) {
14 return __builtin_frame_address(0);
17 void* d(unsigned x) {
18 return __builtin_frame_address(1); // expected-warning{{calling '__builtin_frame_address' with a nonzero argument is unsafe}}
21 #ifdef __cplusplus
22 template<int N> void *RA()
24 return __builtin_return_address(N); // expected-warning{{calling '__builtin_return_address' with a nonzero argument is unsafe}}
27 void *foo()
29 return RA<2>(); // expected-note{{in instantiation of function template specialization 'RA<2>' requested here}}
31 #endif