[PATCH] D49868: [Sema] Fix a crash by completing a type before using it

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 26 16:41:02 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC338089: [Sema] Fix a crash by completing a type before using it (authored by epilk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D49868?vs=157575&id=157606#toc

Repository:
  rC Clang

https://reviews.llvm.org/D49868

Files:
  lib/Sema/SemaInit.cpp
  test/SemaCXX/cxx1z-class-template-argument-deduction.cpp


Index: lib/Sema/SemaInit.cpp
===================================================================
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -9130,6 +9130,7 @@
       Expr *E = ListInit->getInit(0);
       auto *RD = E->getType()->getAsCXXRecordDecl();
       if (!isa<InitListExpr>(E) && RD &&
+          isCompleteType(Kind.getLocation(), E->getType()) &&
           isOrIsDerivedFromSpecializationOf(RD, Template))
         TryListConstructors = false;
     }
Index: test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===================================================================
--- test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -348,6 +348,31 @@
   };
 }
 
+namespace rdar41903969 {
+template <class T> struct A {};
+template <class T> struct B;
+template <class T> struct C {
+  C(A<T>&);
+  C(B<T>&);
+};
+
+void foo(A<int> &a, B<int> &b) {
+  (void)C{b};
+  (void)C{a};
+}
+
+template<typename T> struct X {
+  X(std::initializer_list<T>) = delete;
+  X(const X&);
+};
+
+template <class T> struct D : X<T> {};
+
+void bar(D<int>& d) {
+  (void)X{d};
+}
+}
+
 #else
 
 // expected-no-diagnostics


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49868.157606.patch
Type: text/x-patch
Size: 1202 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180726/f8c7f4a1/attachment.bin>


More information about the cfe-commits mailing list