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

Bug 86504

Summary: [Ambiguity] Function declarator parsed as nested declarator in parameter
Product: [Tools] CDT Reporter: Devin Steffler <devinsteffler.lists>
Component: cdt-parserAssignee: Markus Schorn <mschorn.eclipse>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: aniefer
Version: 3.0   
Target Milestone: Future   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Devin Steffler CLA 2005-02-24 12:47:57 EST
There is a StackOverflowError that is thrown on openDeclarations of g inside 
foo.

It also looks like the AST is incorrect for f's parameter.

// example code taken from CPP spec 8.2-7:
class C { };

void f(int(C)) { } // void f(int (*fp)(C c)) { }
				   // not: void f(int C);

int g(C);

void foo() {
	f(g); // openDeclarations on g causes StackOverflowError
}
Comment 1 Devin Steffler CLA 2005-02-24 12:49:01 EST
There is also a StackOverflowError thrown on openReferences on the declaration 
of g.
Comment 2 Devin Steffler CLA 2005-02-24 12:59:23 EST
John, can you let me know if this is a problem with the AST or not and if it is 
covered under 81739.  Remember that if something has 0 offset/length then it 
will not be displayed in the AST DOM View so it may be misleading.  But I 
looked at the AST for the code above and it looked like the DOM View was 
showing the actual AST (i.e. no pointer op).

Here is another example:

class C { };
void h(int *(C[10])); // void h(int *(*_fp)(C _parm[10]));
// not: void h(int *C[10]);
Comment 3 John Camelon CLA 2005-02-24 14:05:10 EST
Chances are its a physical tree problem.
Assigning to me for now.
Comment 4 John Camelon CLA 2005-05-05 10:38:14 EDT
This now works properly using the latest out of CVS HEAD.  
There are still problems w/using Search/Open Declaration on f.
Sending bug to Andrew to investigate binding.
Comment 5 Andrew Niefer CLA 2005-05-10 11:02:57 EDT
The AST is still wrong. In
void f( int (C) )
The parameter should look like:
   IASTParameterDeclaration
      IASTDeclSpecifier : void
      IASTFunctionDeclarator
           - name = ""
           - parameter: type C, name ""

instead we have a parameter named C type int.

in:  void h(int *(C[10]));
we expected for the parameter's declaration to look like
   IASTParameterDeclaration
       IASTDeclSpecifier: int
       IASTFunctionDeclarator
           - Pointers: *
           - name : ""
           - parameters: type C[10], name ""

Syntactically, there is no nested declarator for either of these.  Semantically,
the parameter behaves the same as if you said: void f( int (*fp)(C c) )
Comment 6 Andrew Niefer CLA 2005-05-10 11:05:19 EDT
oops, typo, obviously in my first example above, I meant for f's parameter to
have declSpec int
Comment 7 Doug Schaefer CLA 2007-08-21 10:57:59 EDT
Future means you commit to fix it in the Future. Inboxes can't make committments. Moving to '--'.
Comment 8 Markus Schorn CLA 2008-06-03 11:07:07 EDT
*** Bug 90715 has been marked as a duplicate of this bug. ***
Comment 9 Markus Schorn CLA 2008-06-05 07:16:46 EDT
This is essentially a duplicate of 84242, I'll make sure to add testcases for the samples provided in this bug.

*** This bug has been marked as a duplicate of bug 84242 ***