mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Applied John C's patch to fix 143502 which addresses a hang when C++ code is parsed by the C parser.
This commit is contained in:
parent
f658aea9b2
commit
7ca72c49aa
2 changed files with 55 additions and 1 deletions
|
@ -3424,4 +3424,50 @@ public class AST2Tests extends AST2BaseTest {
|
|||
tu = parse(buffer.toString(), ParserLanguage.CPP);
|
||||
assertFalse( tu.getDeclarations()[1] instanceof IASTProblemDeclaration );
|
||||
}
|
||||
|
||||
public void testBug143502() throws ParserException {
|
||||
StringBuffer buffer = new StringBuffer("NWindow NewWindowDuplicate(NWindow theWindow, bool insert)\n");
|
||||
buffer.append("{\n");
|
||||
buffer.append(" NWindow newWindow;\n");
|
||||
buffer.append(" newWindow = new GenericWindow();\n");
|
||||
buffer.append("if (newWindow == NULL)\n");
|
||||
buffer.append("return NULL;\n");
|
||||
buffer.append("TwinWindowOF(theWindow) = newWindow;\n");
|
||||
buffer.append("TwinWindowOF(newWindow) = NULL;\n");
|
||||
buffer.append("ParentWindowOF(newWindow) = ParentWindowOF(theWindow);\n");
|
||||
buffer.append("DGlobalsOF(newWindow) = DGlobalsOF(theWindow);\n");
|
||||
buffer.append("HashMapOF(newWindow) = HashMapOF(theWindow);\n");
|
||||
buffer.append("OwnerWindowOF(newWindow) = OwnerWindowOF(theWindow);\n");
|
||||
buffer.append("ChildOF(newWindow) = ChildOF(theWindow);\n");
|
||||
buffer.append(" MakeNameOF(newWindow, NameOF(theWindow));\n");
|
||||
buffer.append("KindOF(newWindow) = KindOF(theWindow);\n");
|
||||
buffer.append("IsVisibleOF(newWindow) = IsVisibleOF(theWindow);\n");
|
||||
buffer.append("FocusOF(newWindow) = FocusOF(theWindow);\n");
|
||||
buffer.append("IsFloating(newWindow) = IsFloating(theWindow);\n");
|
||||
buffer.append("HasCloseBox(newWindow) = HasCloseBox(theWindow);\n");
|
||||
buffer.append("IsSearchNB(newWindow) = IsSearchNB(theWindow);\n");
|
||||
buffer.append("IsFBWindow(newWindow) = FALSE;\n");
|
||||
buffer.append("ShellOF(newWindow) = ShellOF(theWindow);\n");
|
||||
buffer.append("DrawOnOF(newWindow) = DrawOnOF(theWindow);\n");
|
||||
buffer.append("IsBusyOF(newWindow) = IsBusyOF(theWindow);\n");
|
||||
buffer.append("InvalRgnOF(newWindow) = XCreateRegion();\n");
|
||||
buffer.append("IdleOF(newWindow) = IdleOF(theWindow);\n");
|
||||
buffer.append("ShellPainterOF(newWindow) = ShellPainterOF(theWindow);\n");
|
||||
buffer.append("CanvasPainterOF(newWindow) = CanvasPainterOF(theWindow);\n");
|
||||
buffer.append("StatusPainterOF(newWindow) = StatusPainterOF(theWindow);\n");
|
||||
buffer.append("NotebookOF(newWindow) = NotebookOF(theWindow);\n");
|
||||
buffer.append("PopupWindowOF(newWindow) = PopupWindowOF(theWindow);\n");
|
||||
buffer.append("IC_IsFromIM(theWindow) = FALSE;\n");
|
||||
buffer.append("IsDestroyPendingOF(newWindow) = FALSE;\n");
|
||||
buffer.append("if (IsNotebookWindow(newWindow))\n");
|
||||
buffer.append(" DockedWindowOF(newWindow) = NewDockedWindow(newWindow, false);\n");
|
||||
buffer.append("else\n");
|
||||
buffer.append("DockedWindowOF(newWindow) = NULL;\n");
|
||||
buffer.append("if (insert)\n");
|
||||
buffer.append("_addToListHead(newWindow);\n");
|
||||
buffer.append("return newWindow;\n");
|
||||
buffer.append("}\n");
|
||||
|
||||
parse(buffer.toString(), ParserLanguage.C, true, false);
|
||||
}
|
||||
}
|
|
@ -554,6 +554,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
protected CASTTranslationUnit translationUnit;
|
||||
|
||||
private boolean knr = false;
|
||||
|
||||
private static final int DEFAULT_POINTEROPS_LIST_SIZE = 4;
|
||||
|
||||
private static final int DEFAULT_PARAMETERS_LIST_SIZE = 4;
|
||||
|
@ -1941,7 +1943,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
// count the number of K&R C parameters (0 K&R C parameters
|
||||
// essentially means it's not K&R C)
|
||||
numKnRCParms = countKnRCParms();
|
||||
if( !knr )
|
||||
numKnRCParms = countKnRCParms();
|
||||
|
||||
if (supportKnRC && numKnRCParms > 0) { // KnR C parameters were found so
|
||||
// handle the declarator accordingly
|
||||
|
@ -2646,6 +2649,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
boolean previousWasIdentifier = false;
|
||||
|
||||
try {
|
||||
knr = true;
|
||||
mark = mark();
|
||||
|
||||
// starts at the beginning of the parameter list
|
||||
|
@ -2713,6 +2717,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
return 0;
|
||||
}
|
||||
finally
|
||||
{
|
||||
knr = false;
|
||||
}
|
||||
}
|
||||
|
||||
private IASTProblemDeclaration createKnRCProblemDeclaration(int length,
|
||||
|
|
Loading…
Add table
Reference in a new issue