]> granicus.if.org Git - clang/commitdiff
[Sema] Fix a crash by completing a type before using it
authorErik Pilkington <erik.pilkington@gmail.com>
Thu, 26 Jul 2018 23:40:42 +0000 (23:40 +0000)
committerErik Pilkington <erik.pilkington@gmail.com>
Thu, 26 Jul 2018 23:40:42 +0000 (23:40 +0000)
Only apply this exception on a type that we're able to check.

rdar://41903969

Differential revision: https://reviews.llvm.org/D49868

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338089 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 9b5a918b717fca1c19e8238b52e90ed5a281a91b..0dddbdc36fdc4620235e27de0d221f1bd3136e73 100644 (file)
@@ -9130,6 +9130,7 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer(
       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 de61e44a6e92b7eb7bd4843e180c42969f1d321a..f72cb886d81ad6f1089b6136ec5beb9ff2d29845 100644 (file)
@@ -348,6 +348,31 @@ namespace member_guides {
   };
 }
 
+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