Bug 61972

Summary: [Scanner] Macro expansion of "#define a b(a)" causes stack overflow
Product: [Tools] CDT Reporter: Mas Yokota <myokota>
Component: cdt-parserAssignee: John Camelon <john.camelon>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2    
Version: 2.0   
Target Milestone: 2.0   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Bug Depends on:    
Bug Blocks: 62571    
Attachments:
Description Flags
test case none

Description Mas Yokota CLA 2004-05-12 14:47:16 EDT
The test case below causes the stack overflow due to an infinite loop amongst 
scanner.expandDefinition()
scanner.getMacroParameters()
scanner.nextToken()
scanner.processKeywordOrIdentifier()

The test case is as follows:
#define a(i) i
#define b    a(b)
void main() { b; }
Comment 1 Mas Yokota CLA 2004-05-12 14:54:21 EDT
Created attachment 10561 [details]
test case
Comment 2 John Camelon CLA 2004-05-13 09:25:31 EDT
The problem is that subScanner's have their own context stack and thus have no 
idea about whether or not they are circularly recursing.  

As I fix this defect, I shall remove the subscanners, making the system more 
performant and scalable.  
Comment 3 John Camelon CLA 2004-06-04 11:04:55 EDT
Dave has submitted the work to remove the subscanners.  This problem is now 
fixed as a result.  JUnit test cases have been added to validate this in the 
scanner, QuickParser and CompleteParser.