Bug 4093

Summary: CDT parser gives NPE on simple C++ file
Product: frysk Reporter: Rick Moseley <rmoseley>
Component: generalAssignee: Rick Moseley <rmoseley>
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Bug Depends on:    
Bug Blocks: 1633    
Attachments: test c++ file that causes the problem

Description Rick Moseley 2007-02-23 18:28:53 UTC
While looking for a more robust test for the CDTParser, particularly a C++ one,
I downloaded one and used the fparser(stand-alone) utiltity to check it out to
see what sort of a DOM it created.  To my surprise it aborted the parser inside
the CDTParser code.  The following stacktrace was produced:

Exception in thread "main" java.lang.NullPointerException
   at org.eclipse.cdt.internal.core.parser.Parser.failParse(Parser.java:283)
   at org.eclipse.cdt.internal.core.parser.Parser.translationUnit(Parser.java:3059)
   at org.eclipse.cdt.internal.core.parser.Parser.parse(Parser.java:2970)
   at frysk.dom.cparser.CDTParser.parse(CDTParser.java:176)
   at fparser.main(fparser.java:199)

I will attach the file that caused the abort in an attachment.
Comment 1 Rick Moseley 2007-02-23 18:31:56 UTC
Created attachment 1579 [details]
test c++ file that causes the problem

compile with "g++ -g -o test_cpp" and run fparser on the executable.
Comment 2 Rick Moseley 2007-02-27 15:53:29 UTC
Fixed in Parser.java.  It now checks for a null LA(1) class before attempting to
access any of its methods.