1 // RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -std=c99 -Dbool=_Bool -Wno-bool-conversion %s
2 // RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -x c++ -Wno-bool-conversion %s
4 typedef __INTPTR_TYPE__
intptr_t;
8 char const str
[] = "This will change";
10 } // expected-warning{{Address of stack memory associated with local variable 'str' is still referred to by the global variable 'p' upon returning to the caller. This will be a dangling reference}}
13 char const str
[] = "This will change";
19 p
= (const char *) __builtin_alloca(12);
20 } // expected-warning{{Address of stack memory allocated by call to alloca() on line 19 is still referred to by the global variable 'p' upon returning to the caller. This will be a dangling reference}}
22 // PR 7383 - previously the stack address checker would crash on this example
23 // because it would attempt to do a direct load from 'pr7383_list'.
24 static int pr7383(__const
char *__
)
28 extern __const
char *__const pr7383_list
[];
30 // Test that we catch multiple returns via globals when analyzing a function.
31 void test_multi_return(void) {
36 } // expected-warning{{Address of stack memory associated with local variable 'x' is still referred to by the static variable 'a' upon returning}} expected-warning{{Address of stack memory associated with local variable 'x' is still referred to by the static variable 'b' upon returning}}
38 intptr_t returnAsNonLoc(void) {
40 return (intptr_t)&x
; // expected-warning{{Address of stack memory associated with local variable 'x' returned to caller}} expected-warning{{address of stack memory associated with local variable 'x' returned}}
43 bool returnAsBool(void) {
45 return &x
; // no-warning
48 void assignAsNonLoc(void) {
52 } // expected-warning{{Address of stack memory associated with local variable 'x' is still referred to by the global variable 'ip' upon returning}}
54 void assignAsBool(void) {