3

C2X has introduced "Attribute specifier sequence", which can be of these forms:

1) standard attribute, such as [[fallthrough]]
2) attribute with a namespace, such as [[gnu::unused]]
3) standard attribute with arguments, such as [[deprecated("reason")]]
4) attribute with both a namespace and an argument list, such as [[gnu::nonnull(1)]]

What happens when an implementation sees an attribute it doesn't recognize? Is it required to print an error, or ignore it, or print some diagnostic information?

1 Answer 1

5

The ISO C Standard explicitly states that any attribute token that is not supported by an implementation is ignored.

From the latest draft, 6.7.13 Attributes:

6.7.13.1 Introduction

1 Attributes specify additional information for various source constructs such as types, objects, identifiers, or blocks. They are identified by an attribute token, which can either be a attribute prefixed token (for implementation-specific attributes) or a standard attribute specified by an identifier (for attributes specified in this document). 2 Support for any of the standard attributes specified in this document is implementation-defined and optional. For an attribute token (including an attribute prefixed token) not specified in this document, the behavior is implementation-defined. Any attribute token that is not supported by the implementation is ignored.

Not the answer you're looking for? Browse other questions tagged or ask your own question.