From 6eaa86e19ed87705a189b61b7e5fe3bbb7ee04f3 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Mon, 30 Sep 2019 20:39:29 +0000 Subject: [PATCH] [OPENMP50]Mark declare variant attribute as inheritable. Attribute must be inherited by the redeclarations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@373257 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/Attr.td | 3 ++- test/OpenMP/declare_variant_ast_print.cpp | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index 6c71011ff2..14834a1f54 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -3281,11 +3281,12 @@ def OMPAllocateDecl : InheritableAttr { let Documentation = [Undocumented]; } -def OMPDeclareVariant : Attr { +def OMPDeclareVariant : InheritableAttr { let Spellings = [Pragma<"omp", "declare variant">]; let Subjects = SubjectList<[Function]>; let SemaHandler = 0; let HasCustomParsing = 1; + let InheritEvenIfAlreadyPresent = 1; let Documentation = [OMPDeclareVariantDocs]; let Args = [ ExprArgument<"VariantFuncRef">, diff --git a/test/OpenMP/declare_variant_ast_print.cpp b/test/OpenMP/declare_variant_ast_print.cpp index a8c18f6822..1760751c80 100644 --- a/test/OpenMP/declare_variant_ast_print.cpp +++ b/test/OpenMP/declare_variant_ast_print.cpp @@ -148,6 +148,8 @@ auto fn_deduced1() { return 0; } // CHECK-NEXT: #pragma omp declare variant(SpecialFuncs::bar) match(implementation={vendor(llvm)}) // CHECK-NEXT: void foo1() { // CHECK-NEXT: } +// CHECK-NEXT: #pragma omp declare variant(SpecialFuncs::baz) match(implementation={vendor(unknown)}) +// CHECK-NEXT: void xxx(); // CHECK-NEXT: } s; struct SpecialFuncs { void vd() {} @@ -162,8 +164,15 @@ struct SpecialFuncs { #pragma omp declare variant(SpecialFuncs::bar) match(implementation={vendor(ibm)}, implementation={vendor(llvm)}) #pragma omp declare variant(SpecialFuncs::baz) match(implementation={vendor(unknown)}) void foo1() {} +#pragma omp declare variant(SpecialFuncs::baz) match(implementation={vendor(unknown)}) + void xxx(); } s; +// CHECK: #pragma omp declare variant(SpecialFuncs::baz) match(implementation={vendor(unknown)}) +// CHECK-NEXT: void SpecialFuncs::xxx() { +// CHECK-NEXT: } +void SpecialFuncs::xxx() {} + // CHECK: static void static_f_variant() { // CHECK-NEXT: } static void static_f_variant() {} -- 2.40.0