Add a missing check before trying to evaluate a temporary. PR11595.

llvm-svn: 146813
This commit is contained in:
Eli Friedman 2011-12-17 02:24:21 +00:00
parent 290fa41bf6
commit 79281d1df9
2 changed files with 9 additions and 0 deletions

View File

@ -2066,6 +2066,9 @@ public:
return false;
BaseTy = E->getBase()->getType()->getAs<PointerType>()->getPointeeType();
} else if (E->getBase()->isRValue()) {
if (!E->getBase()->getType()->isRecordType() ||
!E->getBase()->getType()->isLiteralType())
return false;
if (!EvaluateTemporary(E->getBase(), Result, this->Info))
return false;
BaseTy = E->getBase()->getType();

View File

@ -919,3 +919,9 @@ static_assert(makeComplexWrap(1,0) == complex(1), "");
static_assert(makeComplexWrap(1,0) != complex(0, 1), "");
}
namespace PR11595 {
struct A { constexpr bool operator==(int x) { return true; } };
struct B { B(); ~B(); A& x; };
static_assert(B().x == 3, ""); // expected-error {{constant expression}}
}