<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/116242>116242</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Different attribute positions for 'noderef' has surprising behaviors
</td>
</tr>
<tr>
<th>Labels</th>
<td>
bug,
clang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AaronBallman
</td>
</tr>
</table>
<pre>
While working on an unrelated crash, I noticed that the `noderef` attribute is highly sensitive to syntactic position as a GNU-style attribute, and the behavior seems inconsistent.
```
// When written before the declaration, it works.
__attribute__((noderef)) int * a;
int w = *a;
// When written in this location on the type, it works.
int __attribute__((noderef)) * b;
int x = *b;
// But when written in this location on the type, it gets loudly ignored.
int * __attribute__((noderef)) c;
int y = *c;
// And when written on the declarator, it gets quietly ignored, but only
// sort of (note the AST dump).
int * d __attribute__((noderef));
int z = *d;
```
https://godbolt.org/z/hesz5M4K8
I'm mostly surprised by the behavior of `c` and `d`. I would expect `c` to work because the attribute is written on a pointer type and I would sort of expect `d` to ignore the attribute loudly because it's a type attribute written on a declarator (I could also see "sliding" the attribute to the type because this is a GNU-style spelling).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlV-P6jYQxT-N8zJalDghwEMe2IuoVlX70lb3ceU_k8Stsak9WS776SsHAmS11epKSIAdzvzO-HgQMZrOITZs-cyWu0wM1PvQbEXw7llYexAuk16fm--9sQgnH_4xrgPvQDgYXEArCDWoIGLP-Dd4AefJKNRAvSCgHoHVufMaA7aszkEQBSMHQjARetP19gwRXTRk3hDIQzw7EoqMgqNPq6lUBAG__P7XU6SzxbtEKiicHqtI7MWb8QEi4iGCccq7aCKhowXLdyzfsjq_vi5f-Z7xPXzv0cEpGCJ0ILH1AUc9jcqKIFL9VMbQ6D1etV5fbxCvr4yvGV9PHvmG8Q0YR8D4FgQrny8_SSsnYOUurd-X_x_GOKDeRLBejRip6YmMzk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