mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Typedef'ed void in function-parameter list, bug 258694.
This commit is contained in:
parent
049e4b13f1
commit
f091f52080
5 changed files with 27 additions and 16 deletions
|
@ -6266,4 +6266,14 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* 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;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
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.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
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 {
|
public class CPPFunctionType implements ICPPFunctionType {
|
||||||
private IType[] parameters;
|
private IType[] parameters;
|
||||||
|
@ -68,10 +66,12 @@ public class CPPFunctionType implements ICPPFunctionType {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (parameters.length == 1 && fps.length == 0) {
|
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;
|
return false;
|
||||||
} else if (fps.length == 1 && parameters.length == 0) {
|
} 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;
|
return false;
|
||||||
} else if (parameters.length != fps.length) {
|
} else if (parameters.length != fps.length) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1883,7 +1883,7 @@ public class CPPSemantics {
|
||||||
// check for parameter of type void
|
// check for parameter of type void
|
||||||
IType[] argTypes= getSourceParameterTypes(funcArgs);
|
IType[] argTypes= getSourceParameterTypes(funcArgs);
|
||||||
if (argTypes.length == 1) {
|
if (argTypes.length == 1) {
|
||||||
IType t= argTypes[0];
|
IType t= SemanticUtil.getUltimateTypeViaTypedefs(argTypes[0]);
|
||||||
if (t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_void) {
|
if (t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_void) {
|
||||||
numArgs= 0;
|
numArgs= 0;
|
||||||
}
|
}
|
||||||
|
@ -1910,7 +1910,7 @@ public class CPPSemantics {
|
||||||
int numPars = params.length;
|
int numPars = params.length;
|
||||||
if (numArgs == 0 && numPars == 1) {
|
if (numArgs == 0 && numPars == 1) {
|
||||||
// check for void
|
// 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)
|
if (t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_void)
|
||||||
numPars= 0;
|
numPars= 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,10 +227,8 @@ public class SemanticUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Descends into a typedef sequence.
|
* Descends into a typedef sequence.
|
||||||
* @param type
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
static IType getUltimateTypeViaTypedefs(IType type) {
|
public static IType getUltimateTypeViaTypedefs(IType type) {
|
||||||
try {
|
try {
|
||||||
while (type instanceof ITypedef) {
|
while (type instanceof ITypedef) {
|
||||||
IType t= ((ITypedef) type).getType();
|
IType t= ((ITypedef) type).getType();
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
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.IIndexCBindingConstants;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
|
@ -124,10 +125,12 @@ public class PDOMCFunctionType extends PDOMNode implements IIndexType, IFunction
|
||||||
IType[] params1= getParameterTypes();
|
IType[] params1= getParameterTypes();
|
||||||
IType[] params2= ft.getParameterTypes();
|
IType[] params2= ft.getParameterTypes();
|
||||||
if (params1.length == 1 && params2.length == 0) {
|
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;
|
return false;
|
||||||
} else if (params2.length == 1 && params1.length == 0) {
|
} 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;
|
return false;
|
||||||
} else if (params1.length != params2.length) {
|
} else if (params1.length != params2.length) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue