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

Bug 394024. Fixed a use case with typedef.

This commit is contained in:
Sergey Prigogin 2012-11-13 12:38:01 -08:00
parent 4462ca0b8a
commit 5c57467a36
2 changed files with 13 additions and 7 deletions

View file

@ -4189,7 +4189,8 @@ public class AST2TemplateTests extends AST2BaseTest {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template <unsigned int N> // typedef unsigned int uint;
// template <uint N>
// void S(int (&array)[N]); // void S(int (&array)[N]);
// //
// int a[1]; // int a[1];

View file

@ -202,9 +202,7 @@ public class TemplateArgumentDeduction {
IType type2= arg.getTypeOfNonTypeValue(); IType type2= arg.getTypeOfNonTypeValue();
// Template-argument deduced from an array bound may be of any integral // Template-argument deduced from an array bound may be of any integral
// type. // type.
if (type2 instanceof TypeOfValueDeducedFromArraySize && if (type2 instanceof TypeOfValueDeducedFromArraySize && isIntegerType(type1)) {
type1 instanceof IBasicType &&
((IBasicType) type1).getKind() == IBasicType.Kind.eInt) {
arg = new CPPTemplateNonTypeArgument(arg.getNonTypeValue(), type1); arg = new CPPTemplateNonTypeArgument(arg.getNonTypeValue(), type1);
deduct.fDeducedArgs.put(tpar, arg); deduct.fDeducedArgs.put(tpar, arg);
} else if (!type1.isSameType(type2)) { } else if (!type1.isSameType(type2)) {
@ -220,11 +218,18 @@ public class TemplateArgumentDeduction {
return false; return false;
} }
private static boolean deduceFromFunctionArg(IType par, IType arg, ValueCategory valueCat, TemplateArgumentDeduction deduct, IASTNode point) throws DOMException { private static boolean isIntegerType(IType type) {
type = SemanticUtil.getNestedType(type, SemanticUtil.TDEF);
return type instanceof IBasicType && ((IBasicType) type).getKind() == IBasicType.Kind.eInt;
}
private static boolean deduceFromFunctionArg(IType par, IType arg, ValueCategory valueCat,
TemplateArgumentDeduction deduct, IASTNode point) throws DOMException {
boolean isReferenceTypeParameter= false; boolean isReferenceTypeParameter= false;
if (par instanceof ICPPReferenceType) { if (par instanceof ICPPReferenceType) {
// If P is an rvalue reference to a cv-unqualified template parameter and the argument is an // If P is an rvalue reference to a cv-unqualified template parameter and the argument
// lvalue, the type "lvalue reference to A" is used in place of A for type deduction. // is an lvalue, the type "lvalue reference to A" is used in place of A for type
// deduction.
isReferenceTypeParameter= true; isReferenceTypeParameter= true;
final ICPPReferenceType refPar = (ICPPReferenceType) par; final ICPPReferenceType refPar = (ICPPReferenceType) par;
if (refPar.isRValueReference() && refPar.getType() instanceof ICPPTemplateParameter && if (refPar.isRValueReference() && refPar.getType() instanceof ICPPTemplateParameter &&