Skip to content

improve error recovery for mistyped "types" #4335

@lattner

Description

@lattner
Bugzilla Link 3963
Resolution FIXED
Resolved on Mar 12, 2010 00:57
Version unspecified
OS All

Extended Description

Consider something like this where clang doesn't know foo_t is a type:

static foo_t x = 4;

we emit:

t2.c:2:14: error: invalid token after top level declarator
static foo_t x = 4;
^
and then errors at every use of X because it wasn't declared. Similarly for things like "static foo_t *X etc.

In this case, the parser thinks it is seeing a declaration of a variable named foo_t that is implicit int. In this case (when it is in implicit int mode) it should do lookahead to see if the non-type token (which it thinks is the identifier) is followed immediately by something that is not valid, e.g. another identifier, a *, a &, etc. In this case, it should recover by parsing foo_t as a broken type. This will lead to a much better diagnostic and will squeltch the chain of bogus diagnostics at uses of X.

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