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:
parent
a98fd8092a
commit
f28c55fa02
2 changed files with 81 additions and 66 deletions
|
@ -7577,5 +7577,17 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
IASTImplicitNameOwner no= (IASTImplicitNameOwner) stmt.getReturnValue();
|
IASTImplicitNameOwner no= (IASTImplicitNameOwner) stmt.getReturnValue();
|
||||||
assertEquals(0, no.getImplicitNames().length);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -220,14 +220,13 @@ public class SemanticUtil {
|
||||||
t= ((ITypedef) type).getType();
|
t= ((ITypedef) type).getType();
|
||||||
} else if (type instanceof IQualifierType) {
|
} else if (type instanceof IQualifierType) {
|
||||||
final IQualifierType qt = (IQualifierType) type;
|
final IQualifierType qt = (IQualifierType) type;
|
||||||
if (((options & CVQ) != 0)) {
|
final boolean cvq = (options & CVQ) != 0;
|
||||||
t= qt.getType();
|
if (cvq || tdef) {
|
||||||
} else if (tdef) {
|
t= getNestedType(qt.getType(), options);
|
||||||
IType temp= qt.getType();
|
if (!cvq || t instanceof IArrayType || t instanceof ICPPReferenceType) {
|
||||||
if (temp instanceof ITypedef) {
|
t= addQualifiers(t, qt.isConst(), qt.isVolatile());
|
||||||
temp= getNestedType(temp, TDEF);
|
|
||||||
return addQualifiers(temp, qt.isConst(), qt.isVolatile());
|
|
||||||
}
|
}
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
} else if ((options & ARRAY) != 0 && type instanceof IArrayType) {
|
} else if ((options & ARRAY) != 0 && type instanceof IArrayType) {
|
||||||
t= ((IArrayType) type).getType();
|
t= ((IArrayType) type).getType();
|
||||||
|
@ -245,7 +244,6 @@ public class SemanticUtil {
|
||||||
* Simplifies type by resolving typedefs within the given type.
|
* Simplifies type by resolving typedefs within the given type.
|
||||||
*/
|
*/
|
||||||
static IType getSimplifiedType(IType type) {
|
static IType getSimplifiedType(IType type) {
|
||||||
try {
|
|
||||||
if (type instanceof ICPPFunctionType) {
|
if (type instanceof ICPPFunctionType) {
|
||||||
final ICPPFunctionType ft = (ICPPFunctionType) type;
|
final ICPPFunctionType ft = (ICPPFunctionType) type;
|
||||||
IType ret = null;
|
IType ret = null;
|
||||||
|
@ -278,12 +276,10 @@ public class SemanticUtil {
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
|
||||||
}
|
|
||||||
return type;
|
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
|
// bug 249085 make sure not to add unnecessary qualifications
|
||||||
if (type instanceof IQualifierType) {
|
if (type instanceof IQualifierType) {
|
||||||
IQualifierType qt= (IQualifierType) type;
|
IQualifierType qt= (IQualifierType) type;
|
||||||
|
@ -299,7 +295,6 @@ public class SemanticUtil {
|
||||||
if (!(type instanceof IIndexType))
|
if (!(type instanceof IIndexType))
|
||||||
return type;
|
return type;
|
||||||
|
|
||||||
try {
|
|
||||||
if (type instanceof IFunctionType) {
|
if (type instanceof IFunctionType) {
|
||||||
final ICPPFunctionType ft = (ICPPFunctionType) type;
|
final ICPPFunctionType ft = (ICPPFunctionType) type;
|
||||||
final IType r = ft.getReturnType();
|
final IType r = ft.getReturnType();
|
||||||
|
@ -326,8 +321,6 @@ public class SemanticUtil {
|
||||||
return ((CPPASTTranslationUnit) tu).mapToAST((ICPPClassType) type);
|
return ((CPPASTTranslationUnit) tu).mapToAST((ICPPClassType) type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
|
||||||
}
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,6 +420,16 @@ public class SemanticUtil {
|
||||||
return new CPPPointerType(pt.getType(), cnst || pt.isConst(), vol || pt.isVolatile());
|
return new CPPPointerType(pt.getType(), cnst || pt.isConst(), vol || pt.isVolatile());
|
||||||
}
|
}
|
||||||
return baseType;
|
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);
|
return new CPPQualifierType(baseType, cnst, vol);
|
||||||
|
|
Loading…
Add table
Reference in a new issue