mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Resolution of overloaded operators. Bug 248803.
This commit is contained in:
parent
d7dee70d25
commit
6aa77b925c
2 changed files with 25 additions and 1 deletions
|
@ -123,6 +123,7 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
|
|||
|
||||
public class AST2CPPTests extends AST2BaseTest {
|
||||
|
||||
|
||||
public AST2CPPTests() {
|
||||
}
|
||||
|
||||
|
@ -6026,4 +6027,23 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
ICPPFunction func2= helper.assertNonProblem("func(y)", 4, ICPPFunction.class);
|
||||
assertNotSame(func1, func2);
|
||||
}
|
||||
|
||||
// struct A {
|
||||
// const char& operator[](int pos) const;
|
||||
// char& operator[](int pos);
|
||||
// };
|
||||
//
|
||||
// void func(const char& c);
|
||||
// void func(char& c);
|
||||
//
|
||||
// void test(const A& x, A& y) {
|
||||
// func(x[0]);
|
||||
// func(y[0]);
|
||||
// }
|
||||
public void testOverloadedOperator_248803() throws Exception {
|
||||
BindingAssertionHelper helper= new BindingAssertionHelper(getAboveComment(), true);
|
||||
ICPPFunction func1= helper.assertNonProblem("func(x[0])", 4, ICPPFunction.class);
|
||||
ICPPFunction func2= helper.assertNonProblem("func(y[0])", 4, ICPPFunction.class);
|
||||
assertNotSame(func1, func2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2026,8 +2026,12 @@ public class CPPVisitor {
|
|||
} else if (expression instanceof IASTArraySubscriptExpression) {
|
||||
IType t = getExpressionType(((IASTArraySubscriptExpression) expression).getArrayExpression());
|
||||
try {
|
||||
if (t instanceof ICPPReferenceType)
|
||||
if (t instanceof ICPPReferenceType) {
|
||||
t = ((ICPPReferenceType)t).getType();
|
||||
}
|
||||
if (t instanceof IQualifierType) {
|
||||
t = ((IQualifierType) t).getType();
|
||||
}
|
||||
while (t instanceof ITypedef) {
|
||||
t = ((ITypedef)t).getType();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue