Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 325135 - Could not find a parameter symbol when used with operator or copy ctor
Summary: Could not find a parameter symbol when used with operator or copy ctor
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-source-nav (show other bugs)
Version: 6.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 7.0.2   Edit
Assignee: Markus Schorn CLA
QA Contact: Markus Schorn CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-13 12:52 EDT by Marc-André Laperle CLA
Modified: 2010-09-28 11:23 EDT (History)
0 users

See Also:


Attachments
Open declaration parameter patch + test (3.71 KB, patch)
2010-09-15 19:48 EDT, Marc-André Laperle CLA
no flags Details | Diff
extended testcase + fix (6.83 KB, patch)
2010-09-16 04:09 EDT, Markus Schorn CLA
mschorn.eclipse: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marc-André Laperle CLA 2010-09-13 12:52:38 EDT
If I Ctrl+click on a variable used with an operator or the copy constructor and it is declared as a parameter, the symbol cannot be found.

Example:

struct Bar;

void bug(Bar name)
{
	Bar foo = name; // cannot find symbol
	Bar foo2(name); // cannot find symbol
	name; // can find symbol
	if(foo == name); // can find symbol
}

void nobug()
{
	const Bar& name;
	Bar foo = name; // can find symbol
	Bar foo2(name); // can find symbol
}
Comment 1 Marc-André Laperle CLA 2010-09-15 17:24:39 EDT
(In reply to comment #0)
>     const Bar& name;

Oops, this line should be 'Bar name;'
Comment 2 Marc-André Laperle CLA 2010-09-15 18:01:02 EDT
This worked in CDT 5.0.2, the bug was introduced in 6.0.0

No need to use a struct, it works with a simple int:

void bug(int var)
{
    // cannot find symbol
    int foo = var;
    int foo2(var);

    // can find symbol
    var;
    foo = var;
    if(foo == var);
    foo * var;
    foo *= var;
}

void nobug()
{
    // can find symbol
    int var;
    int foo = var;
    int foo2(var);
}
Comment 3 Marc-André Laperle CLA 2010-09-15 19:48:15 EDT
Created attachment 178993 [details]
Open declaration parameter patch + test

I think the problem is OpenDeclarationsJob.isInSameFunction calling getEnclosingDeclaration. getEnclosingDeclaration searches for an IASTDeclaration which 'int foo = var;' matches. I think it should look for IASTFunctionDefinition.
Comment 4 Markus Schorn CLA 2010-09-16 04:09:12 EDT
Created attachment 179003 [details]
extended testcase + fix

Thanks Marc!
There is a related problem with template parameters. Therefore I have extended your patch. Also I have changed the implementation of isInSameFunction, such that it is as similar as possible to isInSameTemplate.
Comment 5 Markus Schorn CLA 2010-09-16 04:10:45 EDT
Fixed in 8.0 > 20100916.
Comment 7 Marc-André Laperle CLA 2010-09-17 21:55:18 EDT
(In reply to comment #5)
> Fixed in 8.0 > 20100916.

Thanks! Would it be possible to apply this to 7.0.2?
Comment 8 Markus Schorn CLA 2010-09-20 03:32:58 EDT
(In reply to comment #7)
> Thanks! Would it be possible to apply this to 7.0.2?
Sure, I'll wait until 7.0.1 has been released, though.
Comment 9 Markus Schorn CLA 2010-09-28 02:38:31 EDT
Fixed in 7.0.2 > 20100928.