Fixes PR13314, clang crashing on blocks refering to an enclosing local
when the enclosing function returns void.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160089
91177308-0d34-0410-b5e6-
96231b3b80d8
// ... the expression is the name of a non-volatile automatic object
// (other than a function or catch-clause parameter)) ...
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(E->IgnoreParens());
- if (!DR)
+ if (!DR || DR->refersToEnclosingLocal())
return 0;
const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl());
if (!VD)
-// RUN: %clang_cc1 -x objective-c++ -fblocks -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s -verify -emit-llvm -o %t
+// RUN: %clang_cc1 -x objective-c++ -fblocks -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s -verify -std=c++11 -emit-llvm -o %t
// rdar://8979379
@interface A
// Test4
struct S {
- S *(^a)() = ^{ // expected-warning {{C++11}}
+ S *(^a)() = ^{
return this;
};
};
struct X {
void f() {
^ {
- struct Nested { Nested *ptr = this; }; // expected-warning {{C++11}}
+ struct Nested { Nested *ptr = this; };
} ();
};
};
+
+// Regression test for PR13314
+class FooClass { };
+void fun() {
+ FooClass foovar;
+ ^() { // expected-warning {{expression result unused}}
+ return foovar;
+ };
+}
+void gun() {
+ FooClass foovar;
+ [=]() { // expected-warning {{expression result unused}}
+ return foovar;
+ };
+}