https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/194546

>From b7a7f568251bfbbcbf2239bc59434de4cd9c81f2 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu <[email protected]>
Date: Tue, 28 Apr 2026 13:35:18 +0800
Subject: [PATCH 1/2] [C++20] [Modules] Don't check redeclaration for
 TagUseKind::Reference kind declaration

Close https://github.com/llvm/llvm-project/issues/72038

The reason of the issue is ISO forbids redeclaration between GMF and the
module purview.

But "struct kevent evt;" was thought to be declaration than triggers
the above issue.

In this patch, we simply not checking for cases of TagUseKind::Reference
declaration.
---
 clang/lib/Sema/SemaDecl.cpp     | 2 +-
 clang/test/Modules/pr72038.cppm | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Modules/pr72038.cppm

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 36538e18f297c..36cb218160937 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -18933,7 +18933,7 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind 
TUK, SourceLocation KWLoc,
   if (!Invalid && SearchDC->isRecord())
     SetMemberAccessSpecifier(New, PrevDecl, AS);
 
-  if (PrevDecl)
+  if (PrevDecl && TUK != TagUseKind::Reference)
     CheckRedeclarationInModule(New, PrevDecl);
 
   if (TUK == TagUseKind::Definition) {
diff --git a/clang/test/Modules/pr72038.cppm b/clang/test/Modules/pr72038.cppm
new file mode 100644
index 0000000000000..bd1cdc002b0ff
--- /dev/null
+++ b/clang/test/Modules/pr72038.cppm
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++20 %s -fsyntax-only -verify
+
+// expected-no-diagnostics
+module;
+struct kevent { };
+void kevent(int x);
+export module my_mod;
+struct kevent evt;

>From 09529ef3b629a81e88a8ddb963e2cd6782974a86 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu <[email protected]>
Date: Mon, 21 Sep 2026 16:56:25 +0800
Subject: [PATCH 2/2] Add comment

---
 clang/lib/Sema/SemaDecl.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 36cb218160937..975dc266ea0b6 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -18933,6 +18933,11 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind 
TUK, SourceLocation KWLoc,
   if (!Invalid && SearchDC->isRecord())
     SetMemberAccessSpecifier(New, PrevDecl, AS);
 
+  // FIXME: An elaborated-type-specifier referring to an existing tag should
+  // ideally not introduce a redeclaration. ActOnTag currently creates one, so
+  // avoid diagnosing it as a redeclaration across module boundaries.
+  //
+  // See https://github.com/llvm/llvm-project/pull/194546 for full background.
   if (PrevDecl && TUK != TagUseKind::Reference)
     CheckRedeclarationInModule(New, PrevDecl);
 

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to