[PATCH] D21176: Mark invalid RecordDecls as completed.

Erik Verbruggen via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 27 01:46:50 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL285275: Mark invalid RecordDecls as completed. (authored by erikjv).

Changed prior to commit:
  https://reviews.llvm.org/D21176?vs=60152&id=75992#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21176

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/Index/pr20320.cpp
  cfe/trunk/test/Index/pr20320.h
  cfe/trunk/test/SemaCXX/conversion-function.cpp


Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -13386,7 +13386,14 @@
   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) {
Index: cfe/trunk/test/Index/pr20320.cpp
===================================================================
--- cfe/trunk/test/Index/pr20320.cpp
+++ cfe/trunk/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"
Index: cfe/trunk/test/Index/pr20320.h
===================================================================
--- cfe/trunk/test/Index/pr20320.h
+++ cfe/trunk/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
Index: cfe/trunk/test/SemaCXX/conversion-function.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/conversion-function.cpp
+++ cfe/trunk/test/SemaCXX/conversion-function.cpp
@@ -434,8 +434,12 @@
   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 at -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 at -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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21176.75992.patch
Type: text/x-patch
Size: 2439 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161027/53c5e66c/attachment-0001.bin>


More information about the cfe-commits mailing list