Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2006-06-03 14:11:59 +0000
committerDoug Schaefer2006-06-03 14:11:59 +0000
commit7ca72c49aaaff1fa2c3ab6a8d8ed424ffd734242 (patch)
tree3669a3eca600121131549cad8b4b9de7887247ed
parentf658aea9b26e114e463eb7ccfa87c82e6ae6325d (diff)
downloadorg.eclipse.cdt-7ca72c49aaaff1fa2c3ab6a8d8ed424ffd734242.tar.gz
org.eclipse.cdt-7ca72c49aaaff1fa2c3ab6a8d8ed424ffd734242.tar.xz
org.eclipse.cdt-7ca72c49aaaff1fa2c3ab6a8d8ed424ffd734242.zip
Applied John C's patch to fix 143502 which addresses a hang when C++ code is parsed by the C parser.
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java46
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java10
2 files changed, 55 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
index 270ac2c493..6ca277de01 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
@@ -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);
+ }
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
index f6fc53456b..2b37c1f250 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
@@ -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,

Back to the top