[CUDA][HIP] Do not promote constexpr var with non-constant initializer
authorYaxun (Sam) Liu <yaxun.liu@amd.com>
Sat, 12 Feb 2022 04:07:46 +0000 (23:07 -0500)
committerYaxun (Sam) Liu <yaxun.liu@amd.com>
Tue, 15 Feb 2022 20:15:55 +0000 (15:15 -0500)
commit73b22935a7a863679021598db6a45fcfb62cd321
tree1679b7198e0743eb867aed038bd55aef060acf1a
parent7dad5f84f1b8a7aafd5a27ce2889bd72a1e54002
[CUDA][HIP] Do not promote constexpr var with non-constant initializer

constexpr var may be initialized with address of non-const variable.
In this case the initializer is not constant in device compilation.
This has been handled for const vars but not for constexpr vars.

This patch makes handling of const var and constexpr var
consistent.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D119615

Fixes: https://github.com/llvm/llvm-project/issues/53780
clang/lib/Sema/SemaCUDA.cpp
clang/test/SemaCUDA/constexpr-var.cu [new file with mode: 0644]