r246600 - Fix assertion failure in TransformOpaqueValueExpr
Hubert Tong via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 1 15:50:31 PDT 2015
Author: hubert.reinterpretcast
Date: Tue Sep 1 17:50:31 2015
New Revision: 246600
URL: http://llvm.org/viewvc/llvm-project?rev=246600&view=rev
Log:
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!
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaTemplate/default-arguments.cpp
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=246600&r1=246599&r2=246600&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Tue Sep 1 17:50:31 2015
@@ -7806,7 +7806,7 @@ TreeTransform<Derived>::TransformOffsetO
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;
}
Modified: cfe/trunk/test/SemaTemplate/default-arguments.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-arguments.cpp?rev=246600&r1=246599&r2=246600&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/default-arguments.cpp (original)
+++ cfe/trunk/test/SemaTemplate/default-arguments.cpp Tue Sep 1 17:50:31 2015
@@ -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;
More information about the cfe-commits
mailing list