Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2010-08-05 13:56:30 +0000
committerMarkus Schorn2010-08-05 13:56:30 +0000
commit3805136b3f616859f78dd81976d4380f41fcae3e (patch)
tree878d422b94e445d6dd2c1a7fa1bd1147e2099093 /core/org.eclipse.cdt.core
parent24639ea8487271154e67ddf837bc6dd38809916f (diff)
downloadorg.eclipse.cdt-3805136b3f616859f78dd81976d4380f41fcae3e.tar.gz
org.eclipse.cdt-3805136b3f616859f78dd81976d4380f41fcae3e.tar.xz
org.eclipse.cdt-3805136b3f616859f78dd81976d4380f41fcae3e.zip
Bug 321856: Stack overflow for recursive function type.
Diffstat (limited to 'core/org.eclipse.cdt.core')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CExternalFunction.java13
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java32
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java2
3 files changed, 27 insertions, 20 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CExternalFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CExternalFunction.java
index e27efb2f5b8..4d67e2625f5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CExternalFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CExternalFunction.java
@@ -13,12 +13,13 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
-import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionType;
/**
* Models functions used without declarations.
@@ -38,9 +39,13 @@ public class CExternalFunction extends CFunction implements ICExternalBinding {
@Override
public IFunctionType getType() {
- IFunctionType t = super.getType();
- if (t == null) {
- type = new CFunctionType(VOID_TYPE, IType.EMPTY_TYPE_ARRAY);
+ if (type == null) {
+ // Bug 321856: Prevent recursions
+ type = new CPPFunctionType(VOID_TYPE, IType.EMPTY_TYPE_ARRAY);
+ IFunctionType computedType = createType();
+ if (computedType != null) {
+ type = computedType;
+ }
}
return type;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java
index 4a4f452de27..1c1a1ba89e3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java
@@ -196,23 +196,25 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.IFunction#getType()
- */
- public IFunctionType getType() {
+ public IFunctionType getType() {
if (type == null) {
- IASTDeclarator declarator = getPhysicalNode();
- if (declarator == null && (bits & FULLY_RESOLVED) == 0) {
- resolveAllDeclarations();
- declarator = getPhysicalNode();
- }
- if (declarator != null) {
- IType tempType = CVisitor.unwrapTypedefs(CVisitor.createType(declarator));
- if (tempType instanceof IFunctionType)
- type = (IFunctionType) tempType;
- }
+ type = createType();
}
- return type;
+ return type;
+ }
+
+ protected IFunctionType createType() {
+ IASTDeclarator declarator = getPhysicalNode();
+ if (declarator == null && (bits & FULLY_RESOLVED) == 0) {
+ resolveAllDeclarations();
+ declarator = getPhysicalNode();
+ }
+ if (declarator != null) {
+ IType tempType = CVisitor.unwrapTypedefs(CVisitor.createType(declarator));
+ if (tempType instanceof IFunctionType)
+ return (IFunctionType) tempType;
+ }
+ return null;
}
public IBinding resolveParameter( IASTName paramName ){
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java
index 65c3068efce..b11638817d8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java
@@ -883,7 +883,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
if (exception != null) {
Throwable masked= getMaskedException(exception);
if (masked != exception) {
- e= exception;
+ e= masked;
exception= null;
}
}

Back to the top