-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Different attribute positions for 'noderef' has surprising behaviors #116242
Comments
@llvm/issue-subscribers-bug Author: Aaron Ballman (AaronBallman)
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. // But when written in this location on the type, it gets loudly ignored. // And when written on the declarator, it gets quietly ignored, but only
|
@llvm/issue-subscribers-clang-frontend Author: Aaron Ballman (AaronBallman)
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. // But when written in this location on the type, it gets loudly ignored. // And when written on the declarator, it gets quietly ignored, but only
|
Allowing typedef int * __attribute__((noderef)) p;
p a;
p *b; might be expected to interpret the attribute in completely different ways. In general, I think we should be a bit cautious about sliding the attribute from pointer to pointee when it could be meaningful in both places. We produce a warning on the declaration of Definitely makes sense to me to reject either the declaration of Though as a general concern: moving attributes to somewhere other than where they were written is a semantically horrible thing to do, and I don't think it's good for our users. Doing it for GCC's attributes makes sense for compatibility (though it'd be nice to warn when we do so), but for Clang-only attributes maybe we should not do so as a matter of policy (regardless of whether GNU attribute syntax is used)? |
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.https://godbolt.org/z/hesz5M4K8
I'm mostly surprised by the behavior of
c
andd
. I would expectc
to work because the attribute is written on a pointer type and I would sort of expectd
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).The text was updated successfully, but these errors were encountered: