forked from OSchip/llvm-project
Add a missing check before trying to evaluate a temporary. PR11595.
llvm-svn: 146813
This commit is contained in:
parent
290fa41bf6
commit
79281d1df9
|
@ -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();
|
||||
|
|
|
@ -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}}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue