jeff-hykin / better-cpp-syntax

💾 The source of VS Code's C++ syntax highlighting
GNU General Public License v3.0
156 stars 29 forks source link

Function __attributes__ is scoped as function calls #484

Open karljs opened 4 years ago

karljs commented 4 years ago

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

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.

matter123 commented 4 years ago

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

karljs commented 4 years ago

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

matter123 commented 4 years ago

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