Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 347298 - Member function call of array type variable yields ProblemBinding
Summary: Member function call of array type variable yields ProblemBinding
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 8.0   Edit
Hardware: PC Windows 7
: P3 minor (vote)
Target Milestone: 8.1.0   Edit
Assignee: Markus Schorn CLA
QA Contact: Doug Schaefer CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-26 07:48 EDT by Thomas Corbat CLA
Modified: 2012-02-23 11:33 EST (History)
0 users

See Also:


Attachments
A patch fixing my problem specifically, but breaking 30 core tests (2.43 KB, application/octet-stream)
2011-05-26 07:50 EDT, Thomas Corbat CLA
no flags Details
Problem fixing patch (2.73 KB, patch)
2011-05-26 09:20 EDT, Thomas Corbat CLA
no flags Details | Diff
testcase + fix (11.02 KB, patch)
2011-05-27 04:34 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 Thomas Corbat CLA 2011-05-26 07:48:43 EDT
Build Identifier: I20110512-2000

When trying to get the binding for the name "foo" in the call "s->foo()" in the example code below, I get a ProblemBinding.

----------------
struct S{
  void foo(){}
};

int main(){
  S s[1];
  s->foo();
  return 0;
}
----------------
I know that the code is silly, but it is nevertheless correct.
On the other hand when i change "s" to be a "pointer to S", the binding for foo is correct:
----------------
struct S{
  void foo(){}
};

int main(){
  S *s = new S();
  s->foo();
  return 0;
}
----------------

I've tried to track the difference of the two examples. While I was able to change the behavior in CPPSemantics to correctly resolve the lookup-scope and in Conversions to extract the type, my changes break lots of other core tests (~30). Therefore, my patch is not applicable, but it might give a hint solving the problem.

Reproducible: Always
Comment 1 Thomas Corbat CLA 2011-05-26 07:50:53 EDT
Created attachment 196652 [details]
A patch fixing my problem specifically, but breaking 30 core tests

A patch fixing my problem specifically, but breaking 30 core tests. Not to be taken as is, but perhaps it provides a hint for the solution.
Comment 2 Thomas Corbat CLA 2011-05-26 09:20:09 EDT
Created attachment 196659 [details]
Problem fixing patch

This patch fixes the problem without breaking any core tests.
Comment 3 Markus Schorn CLA 2011-05-26 09:38:06 EDT
Thanks, I'll have a look tomorrow.
Comment 4 Markus Schorn CLA 2011-05-27 04:34:34 EDT
Created attachment 196729 [details]
testcase + fix

Thomas, while your patch is correct, I prefer to make a different change. It explicitly performs the transformation of the field-owner to a prvalue, which is what causes the conversion of the array to a pointer.
Comment 5 Thomas Corbat CLA 2011-05-27 07:13:04 EDT
Markus, that sounds reasonable to me. While I have just tracked the different behavior of pointer and array types and modified the code which causes my problem, your approach is much better. Thanks for the fix! As far as I can see, it works perfectly with my tests.
Comment 6 Markus Schorn CLA 2011-07-01 08:28:56 EDT
In addition to the fix I have added the method that computes the field owner type to the public API:
ICPPASTFieldReference.getFieldOwnerType().