[clang] [clang] Redeclarations should inherit all unique SwiftAttrs (PR #217187)
John Hui via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 18 19:00:32 PDT 2026
================
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -ast-dump -ast-dump-filter=two_on_first %s \
+// RUN: | FileCheck --check-prefix=TWO --implicit-check-not=SwiftAttrAttr %s
+// RUN: %clang_cc1 -ast-dump -ast-dump-filter=split %s \
+// RUN: | FileCheck --check-prefix=SPLIT --implicit-check-not=SwiftAttrAttr %s
+// RUN: %clang_cc1 -ast-dump -ast-dump-filter=dedup %s \
+// RUN: | FileCheck --check-prefix=DEDUP --implicit-check-not=SwiftAttrAttr %s
+
+// 'swift_attr' is a bag of independent annotations identified by its string
+// argument, so a redeclaration inherits all of them, not just the first.
+
+__attribute__((swift_attr("@a"))) __attribute__((swift_attr("@b")))
+void two_on_first(void);
+void two_on_first(void);
+
+// TWO: FunctionDecl {{.*}} two_on_first
+// TWO-NEXT: SwiftAttrAttr {{.*}} "@a"
+// TWO-NEXT: SwiftAttrAttr {{.*}} "@b"
+// TWO: FunctionDecl {{.*}} prev {{.*}} two_on_first
+// TWO-NEXT: SwiftAttrAttr {{.*}} Inherited "@a"
+// TWO-NEXT: SwiftAttrAttr {{.*}} Inherited "@b"
+
+// A 'swift_attr' on the redeclaration must not suppress inheriting the
+// different ones from the previous declaration.
+__attribute__((swift_attr("@x"))) void split(void);
----------------
j-hui wrote:
Perhaps this should have two attributes, to make sure both are inherited?
https://github.com/llvm/llvm-project/pull/217187
More information about the cfe-commits
mailing list