1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 06:05:24 +02:00

Bug 394024 - Template resolution problem with unsigned int non type

parameter.
This commit is contained in:
Sergey Prigogin 2012-11-11 11:24:12 -08:00
parent 5b038020f5
commit dd9ba663b4
3 changed files with 28 additions and 9 deletions

View file

@ -4205,8 +4205,18 @@ public class AST2TemplateTests extends AST2BaseTest {
// S(a);
// }
public void testFunctionTemplateWithArrayReferenceParameter_269926() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
parseAndCheckBindings();
}
// template <unsigned int N>
// void S(int (&array)[N]);
//
// int a[1];
// void test() {
// S(a);
// }
public void testFunctionTemplateWithArrayReferenceParameter_394024() throws Exception {
parseAndCheckBindings();
}
// template <typename T>

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2011 IBM Corporation and others.
* Copyright (c) 2004, 2012 IBM Corporation 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
@ -8,6 +8,7 @@
* Contributors:
* Andrew Niefer (IBM Corporation) - initial API and implementation
* Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -31,6 +32,7 @@ import org.eclipse.core.runtime.CoreException;
*/
public class CPPBasicType implements ICPPBasicType, ISerializableType {
private static final int FROM_STRING_LITERAL = 1 << 31;
public static final int UNSPECIFIED_MODIFIERS = 1 << 30;
public static final CPPBasicType BOOLEAN = new CPPBasicType(Kind.eBoolean, 0, null);
public static final CPPBasicType NULL_PTR = new CPPBasicType(Kind.eNullPtr, 0, null);
@ -119,16 +121,20 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
if (!(object instanceof ICPPBasicType))
return false;
ICPPBasicType t = (ICPPBasicType) object;
if (fKind != t.getKind())
ICPPBasicType other = (ICPPBasicType) object;
if (fKind != other.getKind())
return false;
int modifiers = getModifiers();
int otherModifiers = other.getModifiers();
if ((modifiers & UNSPECIFIED_MODIFIERS) != 0 || (otherModifiers & UNSPECIFIED_MODIFIERS) != 0) {
return true;
}
if (fKind == Kind.eInt) {
// Signed int and int are equivalent.
return (modifiers & ~IS_SIGNED) == (t.getModifiers() & ~IS_SIGNED);
return (modifiers & ~IS_SIGNED) == (otherModifiers & ~IS_SIGNED);
}
return modifiers == t.getModifiers();
return modifiers == otherModifiers;
}
@Override

View file

@ -737,8 +737,11 @@ public class TemplateArgumentDeduction {
if (parID >= 0) {
ICPPTemplateArgument old= fDeducedArgs.getArgument(parID, fPackOffset);
if (old == null) {
if (!deduce(parID,
new CPPTemplateNonTypeArgument(as, new CPPBasicType(ICPPBasicType.Kind.eInt, 0)))) {
// Template-argument deduced from an array bound may be of any integral
// type (14.8.2.5 - 17).
CPPBasicType wildcardIntegralType =
new CPPBasicType(ICPPBasicType.Kind.eInt, CPPBasicType.UNSPECIFIED_MODIFIERS);
if (!deduce(parID, new CPPTemplateNonTypeArgument(as, wildcardIntegralType))) {
return false;
}
} else if (!as.equals(old.getNonTypeValue())) {