Fix assertion failure in TransformOpaqueValueExpr

Summary:
`OpaqueValueExpr`s may not have a source expression (as in the case when
they are created due to a default argument error).
This can cause an assertion failure in `TransformOpaqueValueExpr` during
template instantiation.

This patch fixes the assertion failure.

Reviewers: hfinkel, rsmith

Subscribers: fraggamuffin, cfe-commits

Differential Revision: http://reviews.llvm.org/D11582

Patch by Rachel Craik!

llvm-svn: 246600
This commit is contained in:
Hubert Tong 2015-09-01 22:50:31 +00:00
parent 9772c6342e
commit 2cded44d82
2 changed files with 7 additions and 1 deletions

View File

@ -7806,7 +7806,7 @@ TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
template<typename Derived>
ExprResult
TreeTransform<Derived>::TransformOpaqueValueExpr(OpaqueValueExpr *E) {
assert(getDerived().AlreadyTransformed(E->getType()) &&
assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
"opaque value expression requires transformation");
return E;
}

View File

@ -166,3 +166,9 @@ namespace NondefDecls {
}
template void f1<int>(); // expected-note{{in instantiation of function template specialization 'NondefDecls::f1<int>' requested here}}
}
template <typename T>
struct C {
C(T t = ); // expected-error {{expected expression}}
};
C<int> obj;