Skip to content

Enhancement: diagnose declaration or definition of reserved identifiers to avoid undefined behavior #57913

@pmor13

Description

@pmor13

This code:

void __x(void);

compiled with:

-std=c11 -pedantic -Wall -Wextra

leads to:

<nothing>

instead of:

warning: declaration of reserved identifier `__x`

Per C11, 7.1.3 Reserved identifiers, 2:

If the program declares or defines an identifier in a context in which it is reserved (other than as allowed by 7.1.4), or defines a reserved identifier as a macro name, the behavior is undefined.

Hence, the enhancement is: diagnose declaration or definition of reserved identifiers (all possible cases, see C11, 7.1.3 Reserved identifiers) to avoid undefined behavior.

@AaronBallman Any comments / ideas / thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerworksformeResolved as "works for me"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions