Skip to content

Clang accepts declaration in a statement other than a compound statement #92775

@AaronBallman

Description

@AaronBallman

The following code is grammatically incorrect:

void func() {
  if (1)
    int x;
}

because an iteratation statement must be followed by a secondary-block, which is a kind of statement, which does not accept declarations accept as allowed by compound-statement. GCC properly rejects this code as did Clang 17, so this is a recent regression: https://godbolt.org/z/sj3de1T74

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions