llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Oleksandr T. (a-tarasyuk)

<details>
<summary>Changes</summary>

Fixes #<!-- -->85447

---
Full diff: https://github.com/llvm/llvm-project/pull/89850.diff


2 Files Affected:

- (modified) clang/lib/Sema/SemaDecl.cpp (+3) 
- (added) clang/test/Sema/incomplete-struct-decl.cpp (+10) 


``````````diff
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 5fed554d9e25c3..debe0d9e865362 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5789,6 +5789,9 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, 
DeclSpec &DS,
     Anon = VarDecl::Create(Context, Owner, DS.getBeginLoc(),
                            Record->getLocation(), /*IdentifierInfo=*/nullptr,
                            Context.getTypeDeclType(Record), TInfo, SC);
+    if (Invalid)
+      Anon->setInvalidDecl();
+
     ProcessDeclAttributes(S, Anon, Dc);
 
     // Default-initialize the implicit variable. This initialization will be
diff --git a/clang/test/Sema/incomplete-struct-decl.cpp 
b/clang/test/Sema/incomplete-struct-decl.cpp
new file mode 100644
index 00000000000000..21e445fa170f94
--- /dev/null
+++ b/clang/test/Sema/incomplete-struct-decl.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+template <class a> using __impl_of = a; // expected-note {{'__impl_of' 
declared here}} \
+                                           expected-note {{template is 
declared here}}
+struct {                                // expected-error {{anonymous structs 
and classes must be class members}} \
+                                           expected-note {{to match this '{'}}
+  __impl_;                              // expected-error {{no template named 
'__impl_'; did you mean '__impl_of'?}} \
+                                           expected-error {{cannot specify 
deduction guide for alias template '__impl_of'}} \
+                                           expected-error {{expected ';' after 
struct}}
+                                        // expected-error {{expected '}'}}

``````````

</details>


https://github.com/llvm/llvm-project/pull/89850
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to