diff options
author | dim <dim@FreeBSD.org> | 2011-10-20 21:14:49 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-10-20 21:14:49 +0000 |
commit | 3963a48221351c61c17fb3f382341ab04809a3d3 (patch) | |
tree | ee2483e98b09cac943dc93a6969d83ca737ff139 /test/Analysis/stack-addr-ps.cpp | |
parent | 611ba3ea3300b71eb95dc4e45f20eee5dddd32e1 (diff) | |
download | FreeBSD-src-3963a48221351c61c17fb3f382341ab04809a3d3.zip FreeBSD-src-3963a48221351c61c17fb3f382341ab04809a3d3.tar.gz |
Vendor import of clang release_30 branch r142614:
http://llvm.org/svn/llvm-project/cfe/branches/release_30@142614
Diffstat (limited to 'test/Analysis/stack-addr-ps.cpp')
-rw-r--r-- | test/Analysis/stack-addr-ps.cpp | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/test/Analysis/stack-addr-ps.cpp b/test/Analysis/stack-addr-ps.cpp index 0c1ffba..b09e435 100644 --- a/test/Analysis/stack-addr-ps.cpp +++ b/test/Analysis/stack-addr-ps.cpp @@ -1,38 +1,38 @@ -// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -verify %s // FIXME: Only the stack-address checking in Sema catches this right now, and // the stack analyzer doesn't handle the ImplicitCastExpr (lvalue). const int& g() { int s; - return s; // expected-warning{{reference to stack memory associated with local variable 's' returned}} + return s; // expected-warning{{Address of stack memory associated with local variable 's' returned}} expected-warning{{reference to stack memory associated with local variable 's' returned}} } const int& g2() { int s1; int &s2 = s1; // expected-note {{binding reference variable 's2' here}} - return s2; // expected-warning {{reference to stack memory associated with local variable 's1' returned}} + return s2; // expected-warning{{Address of stack memory associated with local variable 's1' returned}} expected-warning {{reference to stack memory associated with local variable 's1' returned}} } const int& g3() { int s1; int &s2 = s1; // expected-note {{binding reference variable 's2' here}} int &s3 = s2; // expected-note {{binding reference variable 's3' here}} - return s3; // expected-warning {{reference to stack memory associated with local variable 's1' returned}} + return s3; // expected-warning{{Address of stack memory associated with local variable 's1' returned}} expected-warning {{reference to stack memory associated with local variable 's1' returned}} } int get_value(); -const int &get_reference1() { return get_value(); } // expected-warning {{returning reference to local temporary}} +const int &get_reference1() { return get_value(); } // expected-warning{{Address of stack memory associated with temporary object of type 'const int' returned}} expected-warning {{returning reference to local temporary}} const int &get_reference2() { const int &x = get_value(); // expected-note {{binding reference variable 'x' here}} - return x; // expected-warning {{returning reference to local temporary}} + return x; // expected-warning{{Address of stack memory associated with temporary object of type 'const int' returned}} expected-warning {{returning reference to local temporary}} } const int &get_reference3() { const int &x1 = get_value(); // expected-note {{binding reference variable 'x1' here}} const int &x2 = x1; // expected-note {{binding reference variable 'x2' here}} - return x2; // expected-warning {{returning reference to local temporary}} + return x2; // expected-warning{{Address of stack memory associated with temporary object of type 'const int' returned}} expected-warning {{returning reference to local temporary}} } int global_var; @@ -44,19 +44,19 @@ int *f1() { int *f2() { int x1; int &x2 = x1; // expected-note {{binding reference variable 'x2' here}} - return &x2; // expected-warning {{address of stack memory associated with local variable 'x1' returned}} + return &x2; // expected-warning{{Address of stack memory associated with local variable 'x1' returned}} expected-warning {{address of stack memory associated with local variable 'x1' returned}} } int *f3() { int x1; int *const &x2 = &x1; // expected-note {{binding reference variable 'x2' here}} - return x2; // expected-warning {{address of stack memory associated with local variable 'x1' returned}} + return x2; // expected-warning {{address of stack memory associated with local variable 'x1' returned}} expected-warning {{Address of stack memory associated with local variable 'x1' returned to caller}} } const int *f4() { const int &x1 = get_value(); // expected-note {{binding reference variable 'x1' here}} const int &x2 = x1; // expected-note {{binding reference variable 'x2' here}} - return &x2; // expected-warning {{returning address of local temporary}} + return &x2; // expected-warning{{Address of stack memory associated with temporary object of type 'const int' returned}} expected-warning {{returning address of local temporary}} } struct S { @@ -67,7 +67,7 @@ int *mf() { S s1; S &s2 = s1; // expected-note {{binding reference variable 's2' here}} int &x = s2.x; // expected-note {{binding reference variable 'x' here}} - return &x; // expected-warning {{address of stack memory associated with local variable 's1' returned}} + return &x; // expected-warning{{Address of stack memory associated with local variable 's1' returned}} expected-warning {{address of stack memory associated with local variable 's1' returned}} } void *lf() { @@ -76,14 +76,6 @@ void *lf() { return x; // expected-warning {{returning address of label, which is local}} } -typedef void (^bptr)(void); - -bptr bf(int j) { - __block int i; - const bptr &qq = ^{ i=0; }; // expected-note {{binding reference variable 'qq' here}} - return qq; // expected-error {{returning block that lives on the local stack}} -} - template <typename T> struct TS { int *get(); |