Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 347298

Summary: Member function call of array type variable yields ProblemBinding
Product: [Tools] CDT Reporter: Thomas Corbat <thomas.corbat>
Component: cdt-coreAssignee: Markus Schorn <mschorn.eclipse>
Status: RESOLVED FIXED QA Contact: Doug Schaefer <cdtdoug>
Severity: minor    
Priority: P3    
Version: 8.0   
Target Milestone: 8.1.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
A patch fixing my problem specifically, but breaking 30 core tests
none
Problem fixing patch
none
testcase + fix mschorn.eclipse: iplog-

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().