Bug 49817 - Parser appears to hang on code involving for statements
Summary: Parser appears to hang on code involving for statements
Status: RESOLVED DUPLICATE of bug 55163
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 2.0   Edit
Hardware: PC All
: P3 major (vote)
Target Milestone: 2.0   Edit
Assignee: John Camelon CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-11 01:36 EST by Ryan Prichard CLA
Modified: 2004-03-22 14:19 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Prichard CLA 2004-01-11 01:36:06 EST
The CDT parser hangs on certain code involving for statements.  A sample piece
of code which causes a hang is provided below.  I have reproduced the hang with
the sample code on Eclipse 2.1.1 with CDT 1.2, and Eclipse 3.0M5 with CDT 2.0.

From my reading of the source code, the CDT parser handles the init segment of a
for statement by first treating it as a declaration, and if this fails, as an
expression.  With the sample code, the init statement is not a declaration. 
However, the CDT parser appears to process it without error, as a declaration.  

If the code in question were "for (a = 1, b = 2;;);", the CDT parser appears to
treat "a = 1, b = 2" not as an expression but as a declaration of two variables
of type "a".  The first variable has no name and is assigned to 1, and the
second variable has the name "b" and is assigned to 2.  I don't know that this
behavior causes the sample code below to hang the parser, but it seems likely.

Sample code:

int foo()
{
	int one;
	int two;
	
	for (one = 1, two = 2; 0;;);

	{
		int three;

		for (three = 3, two = 4; 0;;);
		for (two = 5; 0;;);
	
		return two + two;
	}
}
Comment 1 John Camelon CLA 2004-01-15 07:58:15 EST
This is a serious bug, as it has demonstrated a flaw in our simplification of 
the SimpleDeclaration portion of the grammar.  I'm going to take some time to 
think about how to fix this one.  
Comment 2 John Camelon CLA 2004-03-22 14:19:24 EST

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