1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Parameter type adjustment, bug 293538.

This commit is contained in:
Markus Schorn 2009-10-28 09:26:05 +00:00
parent a98fd8092a
commit f28c55fa02
2 changed files with 81 additions and 66 deletions

View file

@ -7577,5 +7577,17 @@ public class AST2CPPTests extends AST2BaseTest {
IASTImplicitNameOwner no= (IASTImplicitNameOwner) stmt.getReturnValue();
assertEquals(0, no.getImplicitNames().length);
}
// typedef int Fixed_Array[20];
// void f(const ::Fixed_Array message) {}
//
// void test() {
// int* ptr;
// f(ptr);
// }
public void testParameterAdjustment_293538() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, ParserLanguage.CPP);
}
}

View file

@ -220,14 +220,13 @@ public class SemanticUtil {
t= ((ITypedef) type).getType();
} else if (type instanceof IQualifierType) {
final IQualifierType qt = (IQualifierType) type;
if (((options & CVQ) != 0)) {
t= qt.getType();
} else if (tdef) {
IType temp= qt.getType();
if (temp instanceof ITypedef) {
temp= getNestedType(temp, TDEF);
return addQualifiers(temp, qt.isConst(), qt.isVolatile());
final boolean cvq = (options & CVQ) != 0;
if (cvq || tdef) {
t= getNestedType(qt.getType(), options);
if (!cvq || t instanceof IArrayType || t instanceof ICPPReferenceType) {
t= addQualifiers(t, qt.isConst(), qt.isVolatile());
}
return t;
}
} else if ((options & ARRAY) != 0 && type instanceof IArrayType) {
t= ((IArrayType) type).getType();
@ -245,7 +244,6 @@ public class SemanticUtil {
* Simplifies type by resolving typedefs within the given type.
*/
static IType getSimplifiedType(IType type) {
try {
if (type instanceof ICPPFunctionType) {
final ICPPFunctionType ft = (ICPPFunctionType) type;
IType ret = null;
@ -278,12 +276,10 @@ public class SemanticUtil {
}
return type;
}
} catch (DOMException e) {
}
return type;
}
public static IType replaceNestedType(ITypeContainer type, IType newNestedType) throws DOMException {
public static IType replaceNestedType(ITypeContainer type, IType newNestedType) {
// bug 249085 make sure not to add unnecessary qualifications
if (type instanceof IQualifierType) {
IQualifierType qt= (IQualifierType) type;
@ -299,7 +295,6 @@ public class SemanticUtil {
if (!(type instanceof IIndexType))
return type;
try {
if (type instanceof IFunctionType) {
final ICPPFunctionType ft = (ICPPFunctionType) type;
final IType r = ft.getReturnType();
@ -326,8 +321,6 @@ public class SemanticUtil {
return ((CPPASTTranslationUnit) tu).mapToAST((ICPPClassType) type);
}
}
} catch (DOMException e) {
}
return type;
}
@ -427,6 +420,16 @@ public class SemanticUtil {
return new CPPPointerType(pt.getType(), cnst || pt.isConst(), vol || pt.isVolatile());
}
return baseType;
} else if (baseType instanceof IArrayType) {
IArrayType at= (IArrayType) baseType;
IType nested= at.getType();
IType newNested= addQualifiers(nested, cnst, vol);
if (newNested != nested && at instanceof ITypeContainer) {
return replaceNestedType((ITypeContainer) at, newNested);
}
return at;
} else if (baseType instanceof ICPPReferenceType) {
return baseType;
}
return new CPPQualifierType(baseType, cnst, vol);