mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Instantiation of default template argument during argument deduction, bug 272848.
This commit is contained in:
parent
63d41f2395
commit
264e4f5164
5 changed files with 28 additions and 11 deletions
|
@ -2265,7 +2265,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// void test(A<int*> p) {
|
||||
// f(p);
|
||||
// }
|
||||
public void _testFunctionTemplate_272848_2() throws Exception {
|
||||
public void testFunctionTemplate_272848_2() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
|
@ -98,6 +99,16 @@ public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDef
|
|||
}
|
||||
|
||||
public CPPTemplateParameterMap getTemplateParameterMap() {
|
||||
try {
|
||||
ICPPTemplateParameter[] params = fClassTemplate.getTemplateParameters();
|
||||
int size = Math.min(fArguments.length, params.length);
|
||||
CPPTemplateParameterMap map = new CPPTemplateParameterMap(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
map.put(params[i], fArguments[i]);
|
||||
}
|
||||
return map;
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return CPPTemplateParameterMap.EMPTY;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 QNX Software Systems and others.
|
||||
* Copyright (c) 2007, 2009 QNX Software Systems 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
|
||||
|
@ -26,8 +26,8 @@ public interface ICPPDeferredClassInstance extends ICPPUnknownClassType, ICPPTem
|
|||
ICPPClassTemplate getClassTemplate();
|
||||
|
||||
/**
|
||||
* Returns an empty map, because template parameters cannot be mapped until
|
||||
* all of the arguments are resolved.
|
||||
* Returns the mapping of the template parameters of the primary class template to the
|
||||
* arguments of this instance.
|
||||
* @since 5.1
|
||||
*/
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap();
|
||||
|
|
|
@ -1661,7 +1661,7 @@ public class CPPTemplates {
|
|||
pArg= tpars[i].getDefaultValue();
|
||||
if (pArg == null)
|
||||
return false;
|
||||
pArg= instantiateArgument(pArg, map, null);
|
||||
pArg= instantiateArgument(pArg, pInst.getTemplateParameterMap(), null);
|
||||
}
|
||||
if (!deduceTemplateParameterMap(pArg, aArgs[i], map))
|
||||
return false;
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
|
@ -201,13 +201,19 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPSpecialization implements ICPP
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectMap getArgumentMap() {
|
||||
return ObjectMap.EMPTY_MAP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPPTemplateParameterMap getTemplateParameterMap() {
|
||||
try {
|
||||
ICPPTemplateParameter[] params = getClassTemplate().getTemplateParameters();
|
||||
ICPPTemplateArgument[] args = getTemplateArguments();
|
||||
int size = Math.min(args.length, params.length);
|
||||
CPPTemplateParameterMap map = new CPPTemplateParameterMap(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
map.put(params[i], args[i]);
|
||||
}
|
||||
return map;
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return CPPTemplateParameterMap.EMPTY;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue