]> granicus.if.org Git - clang/commitdiff
[OPENMP50]Mark declare variant attribute as inheritable.
authorAlexey Bataev <a.bataev@hotmail.com>
Mon, 30 Sep 2019 20:39:29 +0000 (20:39 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Mon, 30 Sep 2019 20:39:29 +0000 (20:39 +0000)
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
test/OpenMP/declare_variant_ast_print.cpp

index 6c71011ff2ba2fcf6e5a7e200693ce3bf37e7cc8..14834a1f54143c31d31833cde740fb09e925e97e 100644 (file)
@@ -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">,
index a8c18f68228560a8c9e8fedf2a4c4111ee703074..1760751c803499b44edc618112dda57dbb11b538 100644 (file)
@@ -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() {}