From f95a890c94952276c4f7d09af39c105a8017ae3c Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Mon, 23 Mar 2009 20:11:27 +0000 Subject: [PATCH] Invalid attempts of using user-defined conversions, bug 269729. --- .../cdt/core/parser/tests/ast2/AST2CPPTests.java | 15 ++++++++++++--- .../cdt/internal/ui/search/LinkedNamesFinder.java | 13 +++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 863ac9faff5..03c36564b14 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -7074,7 +7074,16 @@ public class AST2CPPTests extends AST2BaseTest { ba.assertNonProblem("a; //2", 1, ICPPField.class); } - - - + // class C { + // operator int(){return 0;} + // }; + // void test(int) {} + // void ref() { + // C* c= 0; + // test(c); + // } + public void testInvalidUserDefinedConversion_Bug269729() throws Exception { + BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); + ba.assertProblem("test(c)", 4); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java index e9d39fd0eb2..afc63403659 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Google, Inc and others. + * Copyright (c) 2007, 2009 Google, Inc 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 @@ -121,13 +121,10 @@ public class LinkedNamesFinder { if (fileLocation != null) { int offset= fileLocation.getNodeOffset(); int length= fileLocation.getNodeLength(); - try { - if (binding instanceof ICPPMethod && ((ICPPMethod) binding).isDestructor()) { - // Skip tilde. - offset++; - length--; - } - } catch (DOMException e) { + if (binding instanceof ICPPMethod && ((ICPPMethod) binding).isDestructor()) { + // Skip tilde. + offset++; + length--; } if (offset >= 0 && length > 0) { locations.add(new Region(offset, length));