]> granicus.if.org Git - clang/commitdiff
In IsUserDefinedConversion try to recover from RequireCompleteType returning true.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 22 Apr 2011 17:45:37 +0000 (17:45 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 22 Apr 2011 17:45:37 +0000 (17:45 +0000)
Fixes an assertion later on, rdar://9122862 & http://llvm.org/PR9460.

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

lib/Sema/SemaOverload.cpp
test/SemaCXX/PR9460.cpp [new file with mode: 0644]

index 9caf6736017a600549f076f5471d07162cc40f87..9c9ff6ddea05b63319a0448cea8534ea3aefc935 100644 (file)
@@ -2230,7 +2230,11 @@ IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
          S.IsDerivedFrom(From->getType(), ToType)))
       ConstructorsOnly = true;
 
-    if (S.RequireCompleteType(From->getLocStart(), ToType, S.PDiag())) {
+    S.RequireCompleteType(From->getLocStart(), ToType, S.PDiag());
+    // RequireCompleteType may have returned true due to some invalid decl
+    // during template instantiation, but ToType may be complete enough now
+    // to try to recover.
+    if (ToType->isIncompleteType()) {
       // We're not going to find any constructors.
     } else if (CXXRecordDecl *ToRecordDecl
                  = dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
diff --git a/test/SemaCXX/PR9460.cpp b/test/SemaCXX/PR9460.cpp
new file mode 100644 (file)
index 0000000..be8dc6e
--- /dev/null
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s 
+
+// Don't crash.
+
+template<typename aT>
+struct basic_string{
+  a; // expected-error {{requires a type specifier}}
+  basic_string(aT*);
+};
+
+struct runtime_error{
+runtime_error(
+basic_string<char> struct{ // expected-error {{cannot combine with previous 'type-name' declaration specifier}}
+a(){ // expected-error {{requires a type specifier}}
+runtime_error(0);
+}
+}
+);
+};