]> granicus.if.org Git - clang/commitdiff
[OPENMP]Improve handling of analysis of unsupported VLAs in reductions.
authorAlexey Bataev <a.bataev@hotmail.com>
Thu, 11 Jul 2019 20:35:31 +0000 (20:35 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Thu, 11 Jul 2019 20:35:31 +0000 (20:35 +0000)
Fixed the processing of the unsupported VLAs in the reduction clauses.
Used targetDiag if the diagnostics can be delayed and emit it
immediately if the target does not support VLAs and we're parsing target
directive with the reduction clauses.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365821 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/Sema.h
lib/Sema/SemaOpenMP.cpp
test/OpenMP/target_vla_messages.cpp

index 2e60ac9dfb08a882f048740f7895aab764fd6132..8f66cda46b65caee05950597c1d9c25f8472ed47 100644 (file)
@@ -9132,12 +9132,6 @@ public:
   }
   /// Return true inside OpenMP target region.
   bool isInOpenMPTargetExecutionDirective() const;
-  /// Return true if (un)supported features for the current target should be
-  /// diagnosed if OpenMP (offloading) is enabled.
-  bool shouldDiagnoseTargetSupportFromOpenMP() const {
-    return !getLangOpts().OpenMPIsDevice || isInOpenMPDeclareTargetContext() ||
-      isInOpenMPTargetExecutionDirective();
-  }
 
   /// Return the number of captured regions created for an OpenMP directive.
   static int getOpenMPCaptureLevels(OpenMPDirectiveKind Kind);
index 3a02b6ae02f5dba43448067b1a87ab46d78b06de..b669929e655f3ef501e15ca026c41488fee733bd 100644 (file)
@@ -12140,10 +12140,14 @@ static bool actOnOMPReductionKindClause(
     if ((OASE && !ConstantLengthOASE) ||
         (!OASE && !ASE &&
          D->getType().getNonReferenceType()->isVariablyModifiedType())) {
-      if (!Context.getTargetInfo().isVLASupported() &&
-          S.shouldDiagnoseTargetSupportFromOpenMP()) {
-        S.Diag(ELoc, diag::err_omp_reduction_vla_unsupported) << !!OASE;
-        S.Diag(ELoc, diag::note_vla_unsupported);
+      if (!Context.getTargetInfo().isVLASupported()) {
+        if (isOpenMPTargetExecutionDirective(Stack->getCurrentDirective())) {
+          S.Diag(ELoc, diag::err_omp_reduction_vla_unsupported) << !!OASE;
+          S.Diag(ELoc, diag::note_vla_unsupported);
+        } else {
+          S.targetDiag(ELoc, diag::err_omp_reduction_vla_unsupported) << !!OASE;
+          S.targetDiag(ELoc, diag::note_vla_unsupported);
+        }
         continue;
       }
       // For arrays/array sections only:
index 30a2751724264eca64c80471cb5b1b6450bf4cff..cf6a024c6ba5d11bd9d2eaa997e03aebb897e3df 100644 (file)
@@ -206,4 +206,10 @@ void for_reduction(int arg) {
 #pragma omp parallel
 #pragma omp for reduction(+: vla[0:arg])
   for (int i = 0; i < arg; i++) ;
+#ifdef NO_VLA
+  // expected-error@+3 {{cannot generate code for reduction on array section, which requires a variable length array}}
+  // expected-note@+2 {{variable length arrays are not supported for the current target}}
+#endif
+#pragma omp target reduction(+ : vla[0:arg])
+  for (int i = 0; i < arg; i++) ;
 }