[clang] Clang/Preprocessor: Support short circuit in directive (PR #123912)

Fabian Ritter via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 22 07:03:51 PST 2025


================
@@ -23,7 +23,7 @@ template<int N> __attribute__((host, device)) int templatify(int x) {
 __attribute__((device)) const int GlobalConst = __AMDGCN_WAVEFRONT_SIZE__; // expected-warning {{macro '__AMDGCN_WAVEFRONT_SIZE__' has been marked as deprecated}}
 constexpr int GlobalConstExpr = __AMDGCN_WAVEFRONT_SIZE__; // expected-warning {{macro '__AMDGCN_WAVEFRONT_SIZE__' has been marked as deprecated}}
 
-#if defined(__HIP_DEVICE_COMPILE__) && (__AMDGCN_WAVEFRONT_SIZE__ == 64) // expected-warning {{macro '__AMDGCN_WAVEFRONT_SIZE__' has been marked as deprecated}}
+#if (__AMDGCN_WAVEFRONT_SIZE__ == 64) && defined(__HIP_DEVICE_COMPILE__) // expected-warning {{macro '__AMDGCN_WAVEFRONT_SIZE__' has been marked as deprecated}}
----------------
ritter-x2a wrote:

@AaronBallman thanks for notifying me! I think `-fcuda-is-device` isn't necessary; as far as I'm aware (I just tried) the second `RUN` line with `--offload-device-only` leads to a clang run with `__HIP_DEVICE_COMPILE__` defined to 1.

I'd prefer if we left this expression in the test as it was and changed the `expected-warning` comment behind it to an `ondevice-warning` and used `-verify=expected,ondevice` in the second `RUN` line instead, if we change preprocessing such that the deprecation warning isn't triggered due to short-circuit evaluation.

https://github.com/llvm/llvm-project/pull/123912


More information about the cfe-commits mailing list