Author: Chuanqi Xu Date: 2026-09-21T09:41:31Z New Revision: 9e36e5a44bb5ade74202b01246cab4231d202972
URL: https://github.com/llvm/llvm-project/commit/9e36e5a44bb5ade74202b01246cab4231d202972 DIFF: https://github.com/llvm/llvm-project/commit/9e36e5a44bb5ade74202b01246cab4231d202972.diff LOG: [C++20] [Modules] Don't check redeclaration for TagUseKind::Referencekind declaration (#194546) 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. Added: clang/test/Modules/pr72038.cppm Modified: clang/lib/Sema/SemaDecl.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index e52f99b4cd98d..db5e66cb96c3e 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -19189,7 +19189,12 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, if (!Invalid && SearchDC->isRecord()) SetMemberAccessSpecifier(New, PrevDecl, AS); - if (PrevDecl) + // 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); 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; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
