[PATCH] D95764: [OpenMP] Do not propagate match extensions to nested contexts

Johannes Doerfert via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 31 10:12:04 PST 2021


jdoerfert created this revision.
jdoerfert added reviewers: JonChesterfield, tianshilei1992.
Herald added subscribers: guansong, yaxunl.
Herald added a reviewer: bollu.
jdoerfert requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

If we have nested declare variant context, it doesn't make sense to
inherit the match extension from the parent. Instead, just skip it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95764

Files:
  clang/lib/Parse/ParseOpenMP.cpp
  clang/test/OpenMP/begin_declare_variant_nested_propagation.c


Index: clang/test/OpenMP/begin_declare_variant_nested_propagation.c
===================================================================
--- /dev/null
+++ clang/test/OpenMP/begin_declare_variant_nested_propagation.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -x c -std=c99 -fms-extensions -Wno-pragma-pack %s
+// expected-no-diagnostics
+
+#pragma omp begin declare variant match(implementation={extension(match_any)})
+#pragma omp begin declare variant match(device = {vendor(cray, ibm)})
+ this is never reached, we cannot have a cray ibm compiler hybrid, I hope.
+#pragma omp end declare variant
+#pragma omp end declare variant
Index: clang/lib/Parse/ParseOpenMP.cpp
===================================================================
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -1477,6 +1477,14 @@
           MergedSelector = true;
           for (const OMPTraitProperty &ParentProperty :
                ParentSelector.Properties) {
+            // Do not propagate match extensions to nested contexts.
+            if (ParentProperty.Kind == llvm::omp::TraitProperty::
+                                           implementation_extension_match_any ||
+                ParentProperty.Kind == llvm::omp::TraitProperty::
+                                           implementation_extension_match_all ||
+                ParentProperty.Kind == llvm::omp::TraitProperty::
+                                           implementation_extension_match_none)
+              continue;
             bool MergedProperty = false;
             for (OMPTraitProperty &Property : Selector.Properties) {
               // Ignore "equivalent" properties.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95764.320360.patch
Type: text/x-patch
Size: 1706 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210131/43ef117c/attachment.bin>


More information about the cfe-commits mailing list