<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/120516>120516</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [CUDA] should report error for inline __device__ variable
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          aywala
      </td>
    </tr>
</table>

<pre>
    see [CUDA - inline variable](https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#inline-variable)
A namespace scope inline variable declared with __device__ or __constant__ or __managed__ memory space specifier must have internal linkage, if the code is compiled with nvcc in whole program compilation mode.

```cpp
#include <stdio.h>

__device__ inline int a = 10;

__global__ void kernel() {
 printf("%d\n",a);
}

int main() {
    kernel<<<1,1>>>();
 cudaDeviceSynchronize();
}
```
```
nvcc report_error.cu -o report_error
report_error.cu(3): error: An inline __device__/__constant__/__managed__ variable must have internal linkage when the program is compiled in whole program mode (-rdc=false)
 __attribute__((device)) inline int a = 10;
 ^

1 error detected in the compilation of "report_error.cu".
```
but no error report with
``clang++ report_error.cu -o report_error --cuda-gpu-arch=sm_52 -L /usr/local/cuda/lib64 -lcudart -pthread``
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyEVE2PszgT_DWdSwsEdpjAgUMmvDm9t9WekbE74H2MjWyT2dlfv-Ijk_nQo5UsgXGlq7tcKRGC7i1RDcUrFM1BzHFwvhbvb8KIQ-fUex2IEIrXy5_NGRPU1mhLeBdei84QFA2wcohxCsDPwK7ArsrJkNq7Vlqk0o3ArnJWYn8kMpm8670YR237pJ-1ImBXbRX9nQ5xNMD4xpF8cLAKsvMZrRgpTEISBukm-t4KKpJGeFL4puOAbavoriW1LTqPbSudDVHY-NiPwoqeVNviSKPz77iXnkjqmyaP4xwiDuK-EEXyVhg02v4SPQG7oL5hHAilU4Q6oHTjpM2D296lRG3xbX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