diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 94890206002..9c49868f1ad 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -6266,4 +6266,14 @@ public class AST2CPPTests extends AST2BaseTest { parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP); } + // typedef void VOID; + // void donothing(); + // void donothing(VOID){} + // void donothing(VOID); + // void test() { + // donothing(); + // } + public void testVoidViaTypedef_Bug258694() throws Exception { + parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java index c12a6ac37b9..be757316b9f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java @@ -6,12 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation + * Andrew Niefer (IBM Corporation) - initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ - -/* - * Created on Dec 13, 2004 - */ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; @@ -21,9 +18,10 @@ import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; /** - * @author aniefer + * Represents c++ function types. Note that we keep typedefs as part of the function type. */ public class CPPFunctionType implements ICPPFunctionType { private IType[] parameters; @@ -68,10 +66,12 @@ public class CPPFunctionType implements ICPPFunctionType { try { if (parameters.length == 1 && fps.length == 0) { - if (!(parameters[0] instanceof IBasicType) || ((IBasicType) parameters[0]).getType() != IBasicType.t_void) + IType p0= SemanticUtil.getUltimateTypeViaTypedefs(parameters[0]); + if (!(p0 instanceof IBasicType) || ((IBasicType) p0).getType() != IBasicType.t_void) return false; } else if (fps.length == 1 && parameters.length == 0) { - if (!(fps[0] instanceof IBasicType) || ((IBasicType) fps[0]).getType() != IBasicType.t_void) + IType p0= SemanticUtil.getUltimateTypeViaTypedefs(fps[0]); + if (!(p0 instanceof IBasicType) || ((IBasicType) p0).getType() != IBasicType.t_void) return false; } else if (parameters.length != fps.length) { return false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 6612eb465ee..a1574f19720 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -1883,7 +1883,7 @@ public class CPPSemantics { // check for parameter of type void IType[] argTypes= getSourceParameterTypes(funcArgs); if (argTypes.length == 1) { - IType t= argTypes[0]; + IType t= SemanticUtil.getUltimateTypeViaTypedefs(argTypes[0]); if (t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_void) { numArgs= 0; } @@ -1910,7 +1910,7 @@ public class CPPSemantics { int numPars = params.length; if (numArgs == 0 && numPars == 1) { // check for void - IType t = params[0].getType(); + IType t = SemanticUtil.getUltimateTypeViaTypedefs(params[0].getType()); if (t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_void) numPars= 0; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java index 032d82efdf5..d38c3a39e54 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java @@ -227,10 +227,8 @@ public class SemanticUtil { /** * Descends into a typedef sequence. - * @param type - * @return */ - static IType getUltimateTypeViaTypedefs(IType type) { + public static IType getUltimateTypeViaTypedefs(IType type) { try { while (type instanceof ITypedef) { IType t= ((ITypedef) type).getType(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunctionType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunctionType.java index 79916b7cf5a..d8be997e353 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunctionType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunctionType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Systems and others. + * Copyright (c) 2007, 2008 Symbian Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.cdt.internal.core.index.IIndexCBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexType; import org.eclipse.cdt.internal.core.pdom.PDOM; @@ -124,10 +125,12 @@ public class PDOMCFunctionType extends PDOMNode implements IIndexType, IFunction IType[] params1= getParameterTypes(); IType[] params2= ft.getParameterTypes(); if (params1.length == 1 && params2.length == 0) { - if (!(params1[0] instanceof IBasicType) || ((IBasicType)params1[0]).getType() != IBasicType.t_void) + IType p0= SemanticUtil.getUltimateTypeViaTypedefs(params1[0]); + if (!(p0 instanceof IBasicType) || ((IBasicType) p0).getType() != IBasicType.t_void) return false; } else if (params2.length == 1 && params1.length == 0) { - if (!(params2[0] instanceof IBasicType) || ((IBasicType) params2[0]).getType() != IBasicType.t_void) + IType p0= SemanticUtil.getUltimateTypeViaTypedefs(params2[0]); + if (!(p0 instanceof IBasicType) || ((IBasicType) p0).getType() != IBasicType.t_void) return false; } else if (params1.length != params2.length) { return false;