[all-commits] [llvm/llvm-project] fc53b1: [CUDA][HIP] Fix init var diag in temmplate (#69081)
Yaxun (Sam) Liu via All-commits
all-commits at lists.llvm.org
Tue Oct 17 07:00:46 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: fc53b1abf7d5e54012ea77a9bc8f6ccb7b487f13
https://github.com/llvm/llvm-project/commit/fc53b1abf7d5e54012ea77a9bc8f6ccb7b487f13
Author: Yaxun (Sam) Liu <yaxun.liu at amd.com>
Date: 2023-10-17 (Tue, 17 Oct 2023)
Changed paths:
M clang/lib/Sema/SemaCUDA.cpp
M clang/test/SemaCUDA/Inputs/cuda-initializers.h
M clang/test/SemaCUDA/device-var-init.cu
Log Message:
-----------
[CUDA][HIP] Fix init var diag in temmplate (#69081)
Currently clang diagnoses the following code:
(https://godbolt.org/z/s8zK3E5P5) but nvcc
does not.
`
struct A {
constexpr A(){}
};
struct B {
A a;
int b;
};
template<typename T>
__global__ void kernel( )
{
__shared__ B x;
}
`
Clang generates an implicit trivial ctor for struct B, which should be
allowed for initializing a shared variable.
However, the body of the ctor is defined only if the template kernel is
instantiated. Clang checks the initialization of variable in
non-instantiated templates, where it cannot find the body of the ctor,
therefore diagnoses it.
This patch skips the check for non-instantiated templates.
More information about the All-commits
mailing list