}
/// 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);
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:
#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++) ;
}