Skip to content

Poor error message from control flow at global scope #34462

@davidstone

Description

@davidstone
Bugzilla Link 35114
Version trunk
OS Windows NT
CC @hfinkel

Extended Description

If you compile the following code:

while(true) {}

You get the not especially helpful error message:

<source>:1:1: error: expected unqualified-id
while(true) {}
^
1 error generated.

This came up for me in the context of calling a macro that wrapped a few statements in a do { ... } while(false); construct, and I spend a fair amount of time looking for a missing semicolon somewhere before I finally found the problem. I would have preferred to get a message along the lines of "while loops not allowed outside of functions" or something else that directly says the problem from the user's perspective.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partygood first issuehttps://github.com/llvm/llvm-project/contribute

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions