32 lines · c
1// RUN: %clang_cc1 -fsyntax-only -Wframe-address -verify %s2// RUN: %clang_cc1 -fsyntax-only -Wmost -verify %s3// RUN: %clang_cc1 -x c++ -fsyntax-only -Wframe-address -verify %s4 5void* a(unsigned x) {6return __builtin_return_address(0);7}8 9void* b(unsigned x) {10return __builtin_return_address(1); // expected-warning{{calling '__builtin_return_address' with a nonzero argument is unsafe}}11}12 13void* c(unsigned x) {14return __builtin_frame_address(0);15}16 17void* d(unsigned x) {18return __builtin_frame_address(1); // expected-warning{{calling '__builtin_frame_address' with a nonzero argument is unsafe}}19}20 21#ifdef __cplusplus22template<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 27void *foo()28{29 return RA<2>(); // expected-note{{in instantiation of function template specialization 'RA<2>' requested here}}30}31#endif32