Bug 414267 - Unresolved identifier causes mis-parse
Summary: Unresolved identifier causes mis-parse
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: Next   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-02 01:48 EDT by Nathan Ridge CLA
Modified: 2020-09-04 15:26 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Ridge CLA 2013-08-02 01:48:05 EDT
For the following (invalid) code:


int Foo(int);

struct Waldo
{
    Waldo(int);
};

int main()
{
    Waldo var(Foo(UNRESOLVED));
}


CDT parses the first statement in main() as a function declaration, with UNRESOLVED being an argument name (as indicated by the resulting syntax coloring).

This would be appropriate if Foo were a type (it would then be an example of C++'s famous "vexing parse"), but given that Foo is a function, it is not appropriate.

If UNRESOLVED is defined (as a variable or macro), the statement is parsed correctly as a variable declaration.

The appropriate thing to do if UNRESOLVED is not defined, would be to still parse the statement as a variable decalration, and mark UNRESOLVED as being unresolved. This is what gcc and clang do.