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

Bug 259680.

This commit is contained in:
Sergey Prigogin 2008-12-26 04:20:12 +00:00
parent 0e9935bd07
commit 6ea85657c4
2 changed files with 96 additions and 94 deletions

View file

@ -6322,7 +6322,7 @@ public class AST2CPPTests extends AST2BaseTest {
// void test(A& a) { // void test(A& a) {
// func(*a); // func(*a);
// } // }
public void _testSmartPointerReference_259680() throws Exception { public void testSmartPointerReference_259680() throws Exception {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
ba.assertNonProblem("func(*a)", 4, ICPPFunction.class); ba.assertNonProblem("func(*a)", 4, ICPPFunction.class);
} }

View file

@ -1949,19 +1949,21 @@ public class CPPVisitor extends ASTQueries {
break; break;
} }
} }
if (op == IASTUnaryExpression.op_star && type instanceof ICPPClassType) { if (op == IASTUnaryExpression.op_star) {
try { try {
if (type instanceof ICPPReferenceType) {
type = ((ICPPReferenceType) type).getType();
}
if (type instanceof ICPPClassType) {
ICPPFunction operator= CPPSemantics.findOperator(expression, (ICPPClassType) type); ICPPFunction operator= CPPSemantics.findOperator(expression, (ICPPClassType) type);
if (operator != null) { if (operator != null) {
return operator.getType().getReturnType(); return operator.getType().getReturnType();
} }
} catch (DOMException de) { } else if (type instanceof IPointerType || type instanceof IArrayType) {
return de.getProblem();
}
}
if (op == IASTUnaryExpression.op_star && (type instanceof IPointerType || type instanceof IArrayType)) {
try {
return ((ITypeContainer) type).getType(); return ((ITypeContainer) type).getType();
}
return new ProblemBinding(expression, IProblemBinding.SEMANTIC_INVALID_TYPE,
("*" + type.toString()).toCharArray()); //$NON-NLS-1$
} catch (DOMException e) { } catch (DOMException e) {
return e.getProblem(); return e.getProblem();
} }
@ -2191,10 +2193,11 @@ public class CPPVisitor extends ASTQueries {
} }
if (node != null) { if (node != null) {
IASTName name = null; IASTName name = null;
if (node instanceof IASTDeclarator) if (node instanceof IASTDeclarator) {
name = ((IASTDeclarator)node).getName(); name = ((IASTDeclarator)node).getName();
else if (node instanceof IASTName) } else if (node instanceof IASTName) {
name = (IASTName) node; name = (IASTName) node;
}
if (name != null) if (name != null)
found = new IASTName[] { name }; found = new IASTName[] { name };
} }
@ -2412,7 +2415,6 @@ public class CPPVisitor extends ASTQueries {
while (!(node instanceof IASTDeclaration)) { while (!(node instanceof IASTDeclaration)) {
if (node == null) if (node == null)
return null; return null;
node= node.getParent(); node= node.getParent();
} }