[PATCH] D93630: [Attr] Apply GNU-style attributes to expression statements
Valeriy Savchenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 22 08:02:31 PST 2020
vsavchenko added a comment.
@aaron.ballman I totally agree, but I also would like to understand.
`__attribute__` is a GNU extension, right? Then why does it affect the grammar of C? I always thought that attributes should be somewhat transparent for parsers, but it looks like in this situation all compilers automatically assume that `__attribute__` begins a declaration.
It is unclear to me why `*x;`, `[[unknown]] *x;` (dereference of x) and `__attribute__((unknown)) *x;` (declaration of `int *`) have different meanings.
Does it essentially mean that there is no way to implement statement attributes in C/Obj-C?
Because even if we introduce some heuristics for understanding that what we parsed is a declaration attribute -> what follows must be a declaration, attributes that can be applied to both declaration and statements will cause confusion.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93630/new/
https://reviews.llvm.org/D93630
More information about the cfe-commits
mailing list