Bug 294845 - Incorrect binding resolution for structure members with nested declarator
Summary: Incorrect binding resolution for structure members with nested declarator
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 6.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 6.0.2   Edit
Assignee: Markus Schorn CLA
QA Contact: Mike Kucera CLA
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2009-11-11 03:35 EST by Richard Miskin CLA
Modified: 2009-11-11 09:45 EST (History)
0 users

See Also:


Attachments
Test case the shows the problem (2.77 KB, patch)
2009-11-11 03:37 EST, Richard Miskin CLA
mschorn.eclipse: iplog+
Details | Diff
Possible fix (1.38 KB, patch)
2009-11-11 03:56 EST, Richard Miskin CLA
mschorn.eclipse: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Miskin CLA 2009-11-11 03:35:48 EST
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5
Build Identifier: M20090917-0800

With the following code the IField that I get by calling getFields() on the IComposite type for structure does not match the IField that I get from the field name in the second field reference expression.

	 extern void goo();
	 struct MyStruct {
	      int a;
	      void (*ptr)();
	 };
	 void foo() {
	     struct MyStruct structure;
	     structure.a = 1;
	     structure.ptr = goo;
	 }

This only seems to happen for function pointer members; possibly down to the handling of the nested declarator?




Reproducible: Always

Steps to Reproduce:
I'll attach a junit test that demonstrates this with CDT 6.0.1.
Comment 1 Richard Miskin CLA 2009-11-11 03:37:45 EST
Created attachment 151924 [details]
Test case the shows the problem
Comment 2 Richard Miskin CLA 2009-11-11 03:48:23 EST
Interestingly in the junit if I use parseAndCheckBindings() (rather than parse()) to get the IASTTranslationUnit then the IFields match.
Comment 3 Richard Miskin CLA 2009-11-11 03:56:25 EST
Created attachment 151925 [details]
Possible fix

I had a quick look at the way the CompositeCPPClassType gets the IField bindings and it looks like the code in CStructure was missing a call to ASTQueries.findInnermostDeclarator(). The attached patch adds this, which makes the test pass.

It's still a bit odd that the behaviour was different when using parseAndCheckBindings().
Comment 4 Markus Schorn CLA 2009-11-11 09:42:03 EST
(In reply to comment #2)
> Interestingly in the junit if I use parseAndCheckBindings() (rather than
> parse()) to get the IASTTranslationUnit then the IFields match.

The fields match, however the binding refers to two declarations of the field. I have enhanced the testcase to check that.

Thanks Richard,
I have applied your patches in 6.0.2 and 6.1 > 20091111.