[PATCH] D11582: Fix assertion failure in TransformOpaqueValueExpr

Rachel Craik rcraik at ca.ibm.com
Tue Jul 28 15:29:38 PDT 2015


rcraik created this revision.
rcraik added reviewers: rsmith, hfinkel.
rcraik added subscribers: cfe-commits, fraggamuffin.

`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.

http://reviews.llvm.org/D11582

Files:
  lib/Sema/TreeTransform.h
  test/SemaTemplate/default-arguments.cpp

Index: test/SemaTemplate/default-arguments.cpp
===================================================================
--- test/SemaTemplate/default-arguments.cpp
+++ test/SemaTemplate/default-arguments.cpp
@@ -159,3 +159,9 @@
 
   int g() { X<int>::f(0); } // expected-note {{in instantiation of template class 'DR1635::X<int>' requested here}}
 }
+
+template <typename T>
+struct C {
+  C(T t = ); // expected-error {{expected expression}}
+};
+C<int> obj;
Index: lib/Sema/TreeTransform.h
===================================================================
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -7730,7 +7730,7 @@
 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;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11582.30862.patch
Type: text/x-patch
Size: 968 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150728/7fc33677/attachment.bin>


More information about the cfe-commits mailing list