Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 362976

Summary: Assignment in if statement parsed incorrectly
Product: [Tools] CDT Reporter: Nathan Ridge <zeratul976>
Component: cdt-parserAssignee: Markus Schorn <mschorn.eclipse>
Status: RESOLVED FIXED QA Contact: Markus Schorn <mschorn.eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug, viridia
Version: 8.0.1   
Target Milestone: 8.1.0   
Hardware: All   
OS: All   
Whiteboard:

Description Nathan Ridge CLA 2011-11-05 23:27:44 EDT
An assignment inside an if statement seems to be parsed incorrectly when the right-hand side of the assignment is a call to a template function, and the if statement itself occurs in a template function:

template <int>
void* foo(int);

template <typename T>
void f(T t)
{
    if (T* i = foo<0>(0))  // ERROR HERE
        return 0;
}

The error on the indicated line is:

"Symbol 'i' could not be resolved"

The code compiles just fine with GCC.
Comment 1 Markus Schorn CLA 2011-11-07 09:01:36 EST
Thanks! Added testcase and fix.
Comment 2 CDT Genie CLA 2011-11-07 09:23:03 EST
*** cdt git genie on behalf of Markus Schorn ***

    Bug 362976: Directly nested ambiguity node.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=0ebca71a1d033d48e706a847f113a4c8c86951de
Comment 3 Nathan Ridge CLA 2016-12-22 18:49:41 EST
*** Bug 353265 has been marked as a duplicate of this bug. ***