<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/72263>72263</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[CUDA][HIP] -fgpu-defer-diag cause diags for file-scope var not emitted
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yxsamliu
</td>
</tr>
</table>
<pre>
struct A {
A(){ x = 1;}
~A() {}
int x;
};
__device__ A x;`
For the above code, clang should emit a diag that no ctor is device variable x, but it asserts at codegen when compiled with `-fgpu-defer-diag`:
https://godbolt.org/z/5EEvoqbT6
This is because deferred diags are only emitted when there is an enclosing function which is sure to be emitted.
One solution is not to defer diags for file-scope var.
@Artem-B
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0U7ty4zgQ_BowmZKKBF9iwEAyzbqL7gJfrALAIYkrENDiIcsb7LdvAZa9WldtwsfM9HRPY8Cck4tG7El9IvWQseBXY_u3m2ObkiHjZnrrnbdBeDgCaU8kH0h-BDgSeiC0I-0JbkDKAQpSnkg7fOR_3AsS5jMstYdbLEy_Mf75nZ7n84RXKfB8huN7YZM_5kdjwa8IjJsrgjATEvoEQjG9gFtNUBPgJj0wmCRbwK_MgzYgvLEgHbw3hyuzknGFcItoHjxEiHNovQPmU98FNbyuqEGY7SIVTvAq_QqkyXfzcgm7CWe0u8gSJZbHR5Wr9xcXY3QkdFzMxI3ye2MXQsfvhI718_PVfOMvzSPoZZUuauQoWHAIicDilCZxwCyC0eotzeejnCjOr2gxopgG1EIZJ_UCc9DCSxMHkGKNaRcsgjfA8QO_f-T-RyM4o0ICSQfa-FidJNz5Z2Nhlgp3TphLsvC3DqTKj9bjtjtBNvXl1JUdy7Avmq7r2rKrabb2B3YQLU51dWBNKVg5F6xqRFNwjqzsaJvJnua0LIqiKqq6K-i-ajmrZpywYlgUeU2qHDcm1V6p6xYNzaRzAfuW0qbMFOOoXNpkSjW-QkoSSuNi2z5idjwsjlS5ks67X1289Cpdgaf_hiOpB1Kf_vr7X1IP8PWw4X44f_AkOXd3OAtW9V9WQfo18L0wG6FjZL-_dhdr_kfhCR2TZkfomGb6GQAA__-0gyKb">