Author: Volodymyr Sapsai Date: 2026-08-05T20:55:35-07:00 New Revision: c3a0eb4b8f4f4b5c4b705c04bc3f16e4985ddbdf
URL: https://github.com/llvm/llvm-project/commit/c3a0eb4b8f4f4b5c4b705c04bc3f16e4985ddbdf DIFF: https://github.com/llvm/llvm-project/commit/c3a0eb4b8f4f4b5c4b705c04bc3f16e4985ddbdf.diff LOG: [Modules] Don't merge attributes for namespace redeclarations. (#214361) Follow-up to #208348 which aimed to handle decl attributes on deserialization the same way as during parsing. Turned out during parsing we don't merge attributes for namespace redeclarations. Added: Modified: clang/lib/Serialization/ASTReaderDecl.cpp clang/test/Modules/decl-attr-merge2.c Removed: ################################################################################ diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 05ace69a4d999..0ad7cc47f858c 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -3910,7 +3910,7 @@ void ASTDeclReader::attachPreviousDecl(ASTReader &Reader, Decl *D, if (PreviousNonLocal) { if (Sema *S = Reader.getSema()) { - if (auto *ND = dyn_cast<NamedDecl>(D)) + if (auto *ND = dyn_cast<NamedDecl>(D); ND && !isa<NamespaceDecl>(ND)) S->mergeDeclAttributes(ND, PreviousNonLocal); } } diff --git a/clang/test/Modules/decl-attr-merge2.c b/clang/test/Modules/decl-attr-merge2.c index fc84b9df70171..6c23fb08f0c9a 100644 --- a/clang/test/Modules/decl-attr-merge2.c +++ b/clang/test/Modules/decl-attr-merge2.c @@ -2,7 +2,7 @@ // RUN: split-file %s %t // RUN: %clang_cc1 -fmodules -fimplicit-module-maps \ // RUN: -fmodules-cache-path=%t/mcache -triple arm64-apple-macosx10.7.0 \ -// RUN: -I%t/headers -fsyntax-only %t/test.c -verify +// RUN: -I%t/headers -fsyntax-only %t/test.cpp -verify // Check more cases of attribute merging across multiple modules. @@ -17,11 +17,25 @@ module Second { void additiveAttr(void) __attribute__((availability(macos,unavailable))); void exclusiveAttr(void) __attribute__((hot)); +namespace N { +inline namespace with_tag __attribute__((__abi_tag__("a"))) { + struct First {}; +} +inline namespace with_tag { +} +} + //--- headers/second.h void additiveAttr(void) __attribute__((availability(ios,introduced=4.0))); void exclusiveAttr(void) __attribute__((cold)); -//--- test.c +namespace N { +inline namespace with_tag { + struct Second {}; +} +} + +//--- test.cpp #include <first.h> #include <second.h> @@ -35,4 +49,6 @@ void test(void) { exclusiveAttr(); // [email protected]:* {{'cold' and 'hot' attributes are not compatible}} // [email protected]:* {{conflicting attribute is here}} + + N::Second second; } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
