<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/82995>82995</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            C++03 mode ignores the arg in [[attribute(arg)]]
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          AMP999
      </td>
    </tr>
</table>

<pre>
    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 874217f99b; is there something missing to enable attributes with arguments?

The problem is these lines in `ParseCXX11AttributeArgs`.
```
  // If the attribute isn't known, we will not attempt to parse any
  // arguments.
  if (Form.getSyntax() != ParsedAttr::AS_Microsoft &&
 !hasAttribute(LO.CPlusPlus ? AttributeCommonInfo::Syntax::AS_CXX11
 : AttributeCommonInfo::Syntax::AS_C23,
 ScopeName, AttrName, getTargetInfo(), getLangOpts())) {
```
This is reusing the return code of `hasAttribute` to ask whether the attribute is recognized (a boolean). But the machine-generated code in `AttrHasAttributeImpl.inc` uses the return code to say what `__has_cpp_attribute` should be set to (an int), and invariably returns `0` in C++03 mode. https://godbolt.org/z/casKPfdez
```
} else if (ScopeName == "gnu") {
  return llvm::StringSwitch<int>(Name)
[...]
 .Case("assume_aligned", LangOpts.CPlusPlus11 ? 1 : 0)
```
That file is generated by `clang/utils/TableGen/ClangAttrEmitter.cpp`. Maybe a change is needed in that generator?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0Vk9zoz4S_TTtS1coEMbAwQf_iXdT85udVCWHuaU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