Community
Participate
Working Groups
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.
Created attachment 151924 [details] Test case the shows the problem
Interestingly in the junit if I use parseAndCheckBindings() (rather than parse()) to get the IASTTranslationUnit then the IFields match.
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().
(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.