Skip to content

Implement DR277 to reject non-object declarations in for loops pre-C23 #152216

@Halalaluyafail3

Description

@Halalaluyafail3

Clang incorrectly allows the following for loop:

for (enum fred { jim, sheila = 10 } i = jim; i < sheila; i++);

This is invalid and is mentioned specifically in DR277.

Also, I think it is worth specifically mentioning object declarations in structures with no tag here e.g.:

for(struct{int x;}x;0;);

GCC accepts this and I think it is fine, since members are objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cclang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions