May a compiler report errors on unknown attributes? Even with scope?

C++17 adds an explicit statement that attributes not recognized by an implementation are to be ignored. Before C++17, all attribute behavior was implementation defined, so the implementation could do anything.

Part of the purpose of the attribute specification is so that compiler makers will stop cluttering the language up with special syntax and keywords. To give them a single grammar for specifying these things. It is a way to associate a compiler-defined string with a particular object or definition.


[[ vendor::attrib ]]

may be complained about by a standard conforming compiler?

Yes, especially this one should be complained about a standard conforming compiler that doesn't support the conditionally supported behavior (a diagnostic message is required).

However, I'm not sure about the others. The standard contains also this:

... If an attribute-specifier-seq that appertains to some entity or statement contains an attribute that is not allowed to apply to that entity or statement, the program is ill-formed. ...

I believe it could be read permissively, that only those attributes that surely are in violation of the rule make the program ill-formed (ie. the ones that the compiler doesn't know don't), however, I'm not quite sure. Anyway, using implementation-defined behavior does not make the program ill-formed.

Currently, gcc accepts unknown attributes with a warning, so I believe it will work like that with the new syntax, too.