diff options
4 files changed, 42 insertions, 32 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 cff0b157f4e..4f09c1987d1 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 @@ -34,6 +34,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTDoStatement; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement; import org.eclipse.cdt.core.dom.ast.IASTFieldReference; @@ -90,7 +91,6 @@ import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.IVariable; -import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier; import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer; @@ -6510,11 +6510,7 @@ public class AST2Tests extends AST2BaseTest { } } } - - - - - // + // /* check that enumerator values are evaluated correctly for // * conditional expressions */ // @@ -6542,4 +6538,13 @@ public class AST2Tests extends AST2BaseTest { final String code = getAboveComment(); parseAndCheckBindings(code, ParserLanguage.C, false, true); } + + // typeof(b(1)) b(int); + public void testRecursiveFunctionType_321856() throws Exception { + final String code = getAboveComment(); + BindingAssertionHelper bh= new BindingAssertionHelper(code, false); + IFunction f= bh.assertNonProblem("b(1)", 1); + f= bh.assertNonProblem("b(int)", 1); + f.getType(); + } } 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 297743684bb..9f414806052 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 @@ -39,11 +39,15 @@ public class CExternalFunction extends CFunction implements ICExternalBinding { @Override public IFunctionType getType() { - IFunctionType t = super.getType(); - if( t == null ) { - type = new CPPFunctionType( CPPSemantics.VOID_TYPE, IType.EMPTY_TYPE_ARRAY ); - } - return type; + if (type == null) { + // Bug 321856: Prevent recursions + type = new CPPFunctionType(CPPSemantics.VOID_TYPE, IType.EMPTY_TYPE_ARRAY); + IFunctionType computedType = createType(); + if (computedType != null) { + type = computedType; + } + } + return type; } @Override 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 f9e9d0aa026..61b044adcd2 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 @@ -202,29 +202,30 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu return null; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IFunction#getType() - */ public IFunctionType getType() { - if( type == null ) { - IASTDeclarator functionDtor = (IASTDeclarator) getPhysicalNode(); - if( functionDtor == null && (bits & FULLY_RESOLVED) == 0){ - resolveAllDeclarations(); - functionDtor = (IASTDeclarator) getPhysicalNode(); - } - if( functionDtor != null ) { - while (functionDtor.getNestedDeclarator() != null) - functionDtor = functionDtor.getNestedDeclarator(); - - IType tempType = CVisitor.createType( functionDtor ); - if (tempType instanceof IFunctionType) - type = (IFunctionType)tempType; - } - } - + if (type == null) { + type = createType(); + } return type; } - + + protected IFunctionType createType() { + IASTDeclarator functionDtor = (IASTDeclarator) getPhysicalNode(); + if (functionDtor == null && (bits & FULLY_RESOLVED) == 0) { + resolveAllDeclarations(); + functionDtor = (IASTDeclarator) getPhysicalNode(); + } + if (functionDtor != null) { + while (functionDtor.getNestedDeclarator() != null) + functionDtor = functionDtor.getNestedDeclarator(); + + IType tempType = CVisitor.createType(functionDtor); + if (tempType instanceof IFunctionType) + return (IFunctionType) tempType; + } + return null; + } + public IBinding resolveParameter( IASTName paramName ){ if( paramName.getBinding() != null ) return paramName.getBinding(); 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 fe6e0c3e569..ff284172996 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 @@ -804,7 +804,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { if (exception != null) { Throwable masked= getMaskedException(exception); if (masked != exception) { - e= exception; + e= masked; exception= null; } } |