better-cpp-syntax icon indicating copy to clipboard operation
better-cpp-syntax copied to clipboard

Function __attributes__ is scoped as function calls

Open karljs opened this issue 5 years ago • 3 comments

I see several other issues related to attributes, but this one seems like a separate bug since it's marking function attributes as function calls rather than just a less preferred attribute scope.

Checklist

  • [X] This problem exists even with the setting "C_Cpp.enhancedColorization": "Disabled"
  • [ ] This bug exists for C
  • [X] This bug exists for C++
  • [ ] This bug exists for Objective-C
  • [ ] This bug exists for Objective-C++

The code with a problem is:

int foo() __attribute__((always_inline))
// or any other function attribute

It looks like:

Screenshot-20200617092048-429x27 Solarized Light theme

It should look like:

I'm not sure, but probably the blue __attribute__ should be black.

karljs avatar Jun 17 '20 16:06 karljs

I don't belive that to be valid syntax.

An attribute specifier list may, in future, be permitted to appear after the declarator in a function definition (before any old-style parameter declarations or the function body).

(from https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html#Attribute-Syntax)

Additionally, compilation fails: https://godbolt.org/z/GtgxRX

matter123 avatar Jun 17 '20 16:06 matter123

@matter123 Ah, I didn't realize this is clang-specific. Thanks for the pointer.

karljs avatar Jun 17 '20 21:06 karljs

Huh, I wonder why clang added support for attributes there.

matter123 avatar Jun 17 '20 21:06 matter123