summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Sema/SemaDecl.cpp9
-rw-r--r--clang/test/Index/pr20320.cpp2
-rw-r--r--clang/test/Index/pr20320.h14
-rw-r--r--clang/test/SemaCXX/conversion-function.cpp6
4 files changed, 29 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index e9e0f5e214d..c8973ae100e 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -13386,7 +13386,14 @@ CreateNewDecl:
OwnedDecl = true;
// In C++, don't return an invalid declaration. We can't recover well from
// the cases where we make the type anonymous.
- return (Invalid && getLangOpts().CPlusPlus) ? nullptr : New;
+ if (Invalid && getLangOpts().CPlusPlus) {
+ if (New->isBeingDefined())
+ if (auto RD = dyn_cast<RecordDecl>(New))
+ RD->completeDefinition();
+ return nullptr;
+ } else {
+ return New;
+ }
}
void Sema::ActOnTagStartDefinition(Scope *S, Decl *TagD) {
diff --git a/clang/test/Index/pr20320.cpp b/clang/test/Index/pr20320.cpp
new file mode 100644
index 00000000000..cb54cea642a
--- /dev/null
+++ b/clang/test/Index/pr20320.cpp
@@ -0,0 +1,2 @@
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local -x c++ %s
+#include "pr20320.h"
diff --git a/clang/test/Index/pr20320.h b/clang/test/Index/pr20320.h
new file mode 100644
index 00000000000..9dbb7303df2
--- /dev/null
+++ b/clang/test/Index/pr20320.h
@@ -0,0 +1,14 @@
+#ifndef pr20320_h
+#define pr20320_h
+
+template<>
+struct S< ::Number::One>
+{
+};
+
+template<>
+struct S< ::Number::Two>
+{
+};
+
+#endif
diff --git a/clang/test/SemaCXX/conversion-function.cpp b/clang/test/SemaCXX/conversion-function.cpp
index 3f494cce8ce..c725a0d5b7c 100644
--- a/clang/test/SemaCXX/conversion-function.cpp
+++ b/clang/test/SemaCXX/conversion-function.cpp
@@ -434,8 +434,12 @@ namespace PR18234 {
struct A {
operator enum E { e } (); // expected-error {{'PR18234::A::E' cannot be defined in a type specifier}}
operator struct S { int n; } (); // expected-error {{'PR18234::A::S' cannot be defined in a type specifier}}
+ // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'struct A' to 'const PR18234::A::S &' for 1st argument}}
+#if __cplusplus >= 201103L
+ // expected-note@-3 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'struct A' to 'PR18234::A::S &&' for 1st argument}}
+#endif
} a;
- A::S s = a;
+ A::S s = a; // expected-error {{no viable conversion from 'struct A' to 'A::S'}}
A::E e = a; // expected-note {{here}}
bool k1 = e == A::e; // expected-error {{no member named 'e'}}
bool k2 = e.n == 0;
OpenPOWER on IntegriCloud