llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Eric Astor (ericastor) <details> <summary>Changes</summary> Start propagating attributes on (e.g.) labels inside of templated functions to their instances. --- Full diff: https://github.com/llvm/llvm-project/pull/115924.diff 2 Files Affected: - (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+13-3) - (modified) clang/test/SemaCXX/attr-mode-tmpl.cpp (+2-2) ``````````diff diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 5a001843e2ba46..bfc5913dbafd0f 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -990,6 +990,7 @@ Decl * TemplateDeclInstantiator::VisitLabelDecl(LabelDecl *D) { LabelDecl *Inst = LabelDecl::Create(SemaRef.Context, Owner, D->getLocation(), D->getIdentifier()); + SemaRef.InstantiateAttrs(TemplateArgs, D, Inst, LateAttrs, StartingScope); Owner->addDecl(Inst); return Inst; } @@ -1009,6 +1010,7 @@ TemplateDeclInstantiator::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { D->getQualifierLoc(), D->getTargetNameLoc(), D->getNamespace()); + SemaRef.InstantiateAttrs(TemplateArgs, D, Inst, LateAttrs, StartingScope); Owner->addDecl(Inst); return Inst; } @@ -1095,15 +1097,21 @@ Decl *TemplateDeclInstantiator::InstantiateTypedefNameDecl(TypedefNameDecl *D, Decl *TemplateDeclInstantiator::VisitTypedefDecl(TypedefDecl *D) { Decl *Typedef = InstantiateTypedefNameDecl(D, /*IsTypeAlias=*/false); - if (Typedef) + if (Typedef) { + SemaRef.InstantiateAttrs(TemplateArgs, D, Typedef, LateAttrs, + StartingScope); Owner->addDecl(Typedef); + } return Typedef; } Decl *TemplateDeclInstantiator::VisitTypeAliasDecl(TypeAliasDecl *D) { Decl *Typedef = InstantiateTypedefNameDecl(D, /*IsTypeAlias=*/true); - if (Typedef) + if (Typedef) { + SemaRef.InstantiateAttrs(TemplateArgs, D, Typedef, LateAttrs, + StartingScope); Owner->addDecl(Typedef); + } return Typedef; } @@ -1160,8 +1168,10 @@ Decl *TemplateDeclInstantiator::InstantiateTypeAliasTemplateDecl( Decl * TemplateDeclInstantiator::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { Decl *Inst = InstantiateTypeAliasTemplateDecl(D); - if (Inst) + if (Inst) { + SemaRef.InstantiateAttrs(TemplateArgs, D, Inst, LateAttrs, StartingScope); Owner->addDecl(Inst); + } return Inst; } diff --git a/clang/test/SemaCXX/attr-mode-tmpl.cpp b/clang/test/SemaCXX/attr-mode-tmpl.cpp index f665b1ba491237..58266f947051c5 100644 --- a/clang/test/SemaCXX/attr-mode-tmpl.cpp +++ b/clang/test/SemaCXX/attr-mode-tmpl.cpp @@ -9,7 +9,7 @@ void CheckEnumerations() { // Check that non-vector 'mode' attribute is OK with enumeration types. typedef T __attribute__((mode(QI))) T1; typedef T T2 __attribute__((mode(HI))); - typedef T __attribute__((mode(V8SI))) T3; // expected-error{{mode 'V8SI' is not supported for enumeration types}} + typedef T __attribute__((mode(V8SI))) T3; // expected-error2{{mode 'V8SI' is not supported for enumeration types}} // expected-warning@-1{{specifying vector types with the 'mode' attribute is deprecated}} typedef enum __attribute__((mode(HI))) { A4, B4 } T4; @@ -62,7 +62,7 @@ struct TemplatedStruct { // Check typedefs. typedef T __attribute__((mode(DI))) T1; - typedef T __attribute__((mode(V8DI))) T2; // expected-error{{mode 'V8DI' is not supported for enumeration types}} + typedef T __attribute__((mode(V8DI))) T2; // expected-error2{{mode 'V8DI' is not supported for enumeration types}} // expected-warning@-1{{deprecated}} // Check parameters. `````````` </details> https://github.com/llvm/llvm-project/pull/115924 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits