mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 00:45:28 +02:00
Bug 264963. Fix + test case.
This commit is contained in:
parent
641956d09e
commit
d9e8e6d74f
2 changed files with 33 additions and 15 deletions
|
@ -2204,7 +2204,25 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
ICPPFunction fn= bh.assertNonProblem("make_pair(1", 9, ICPPFunction.class);
|
||||
}
|
||||
|
||||
// // Brian W.'s example from bugzilla#167098
|
||||
// template<class T>
|
||||
// struct A {};
|
||||
//
|
||||
// template<class T>
|
||||
// A<T> a(T p);
|
||||
//
|
||||
// void f(A<int> p);
|
||||
//
|
||||
// typedef int& B;
|
||||
//
|
||||
// void test(B x) {
|
||||
// f(a(x));
|
||||
// }
|
||||
public void testFunctionTemplate_264963() throws Exception {
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||
bh.assertNonProblem("f(a(x));", 1, ICPPFunction.class);
|
||||
}
|
||||
|
||||
// // Brian W.'s example from bugzilla#167098
|
||||
// template<class K>
|
||||
// class D { //CPPClassTemplate
|
||||
// public:
|
||||
|
@ -3804,5 +3822,4 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
String code= getAboveComment();
|
||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1486,27 +1486,28 @@ public class CPPTemplates {
|
|||
* - If A is an array type, the pointer type produced by the array-to-pointer conversion is used instead
|
||||
* - If A is a function type, the pointer type produced by the function-to-pointer conversion is used instead
|
||||
* - If A is a cv-qualified type, the top level cv-qualifiers are ignored for type deduction
|
||||
* @param aInfo
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
static private IType getArgumentTypeForDeduction(IType aType, boolean pIsAReferenceType) {
|
||||
if (aType instanceof ICPPReferenceType) {
|
||||
static private IType getArgumentTypeForDeduction(IType type, boolean pIsAReferenceType) {
|
||||
type = SemanticUtil.getSimplifiedType(type);
|
||||
if (type instanceof ICPPReferenceType) {
|
||||
try {
|
||||
aType = ((ICPPReferenceType) aType).getType();
|
||||
type = ((ICPPReferenceType) type).getType();
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
}
|
||||
IType result = aType;
|
||||
IType result = type;
|
||||
if (!pIsAReferenceType) {
|
||||
try {
|
||||
if (aType instanceof IArrayType) {
|
||||
result = new CPPPointerType(((IArrayType) aType).getType());
|
||||
} else if (aType instanceof IFunctionType) {
|
||||
result = new CPPPointerType(aType);
|
||||
} else if (aType instanceof IQualifierType) {
|
||||
result = ((IQualifierType) aType).getType();
|
||||
} else if (aType instanceof CPPPointerType) {
|
||||
result = ((CPPPointerType) aType).stripQualifiers();
|
||||
if (type instanceof IArrayType) {
|
||||
result = new CPPPointerType(((IArrayType) type).getType());
|
||||
} else if (type instanceof IFunctionType) {
|
||||
result = new CPPPointerType(type);
|
||||
} else if (type instanceof IQualifierType) {
|
||||
result = ((IQualifierType) type).getType();
|
||||
} else if (type instanceof CPPPointerType) {
|
||||
result = ((CPPPointerType) type).stripQualifiers();
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
result = e.getProblem();
|
||||
|
|
Loading…
Add table
Reference in a new issue