[PATCH] D40275: [CUDA] Report "unsupported VLA" errors only on device side.

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 20 17:52:29 PST 2017


rjmccall added inline comments.


================
Comment at: clang/lib/Sema/SemaType.cpp:2188
+               !Context.getTargetInfo().isVLASupported() &&
+               shouldDiagnoseTargetSupportFromOpenMP()) {
+      // Some targets don't support VLAs.
----------------
Please write this check so that it trips in an "ordinary" build on a target that just happens to not support VLAs, something like:

  else if (!Context.getTargetInfo().isVLASupported() && shouldDiagnoseTargetSupportFromOpenMP())

If you want to include the explicit OpenMP check there, it would need to be:

  else if (!Context.getTargetInfo().isVLASupported() && (!getLangOpts().OpenMP || shouldDiagnoseTargetSupportFromOpenMP()))

but I think the first looks better.

The CUDA and OpenMP paths here seem to be trying to achieve analogous things; it's unfortunate that we can't find a way to unify their approaches, even if we'd eventually want to use different diagnostic text.  I imagine that the target-environment language restrictions are basically the same, since they arise for the same fundamental reasons, so all the places using CUDADiagIfDeviceCode are likely to have a check for shouldDiagnoseTargetSupportFromOpenMP() and vice-versa.


https://reviews.llvm.org/D40275





More information about the cfe-commits mailing list