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
C++03 mode ignores the arg in [[attribute(arg)]] #82995
Comments
I noticed that |
@AaronBallman do you think it's worth back-porting a fix for this? |
If the fix is small and obviously correct, then yes, I think that's worth backporting. |
@llvm/issue-subscribers-clang-frontend Author: Amirreza Ashouri (AMP999)
https://godbolt.org/z/aPKq1sKPT
`[[gnu::assume_aligned(4)]] static void *g() { return p; }`
In `-std=c++11` mode, this code is accepted and works as expected. In `-std=c++03` mode, it seems to ignore the `(4)` argument for some reason, and I get an error:
```
<source>:5:3: error: 'assume_aligned' attribute takes at least 1 argument
5 | [[gnu::assume_aligned(4)]] static void *g() { return p; }
| ^
```
@philnik777 I think you enabled attributes in 874217f; is there something missing to enable attributes with arguments?
The problem is these lines in
This is reusing the return code of
That file is generated by |
@llvm/issue-subscribers-c-1 Author: Amirreza Ashouri (AMP999)
https://godbolt.org/z/aPKq1sKPT
`[[gnu::assume_aligned(4)]] static void *g() { return p; }`
In `-std=c++11` mode, this code is accepted and works as expected. In `-std=c++03` mode, it seems to ignore the `(4)` argument for some reason, and I get an error:
```
<source>:5:3: error: 'assume_aligned' attribute takes at least 1 argument
5 | [[gnu::assume_aligned(4)]] static void *g() { return p; }
| ^
```
@philnik777 I think you enabled attributes in 874217f; is there something missing to enable attributes with arguments?
The problem is these lines in
This is reusing the return code of
That file is generated by |
https://godbolt.org/z/aPKq1sKPT
[[gnu::assume_aligned(4)]] static void *g() { return p; }
In
-std=c++11
mode, this code is accepted and works as expected. In-std=c++03
mode, it seems to ignore the(4)
argument for some reason, and I get an error:@philnik777 I think you enabled attributes in 874217f; is there something missing to enable attributes with arguments?
The problem is these lines in
ParseCXX11AttributeArgs
.This is reusing the return code of
hasAttribute
to ask whether the attribute is recognized (a boolean). But the machine-generated code inAttrHasAttributeImpl.inc
uses the return code to say what__has_cpp_attribute
should be set to (an int), and invariably returns0
in C++03 mode. https://godbolt.org/z/casKPfdezThat file is generated by
clang/utils/TableGen/ClangAttrEmitter.cpp
. Maybe a change is needed in that generator?The text was updated successfully, but these errors were encountered: