Bug 413204 - "field could not be resolved" error in function returning function pointer
Summary: "field could not be resolved" error in function returning function pointer
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 8.2   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: 8.2.1   Edit
Assignee: Nathan Ridge CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-17 15:57 EDT by Daniel Pirch CLA
Modified: 2013-08-27 16:34 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Pirch CLA 2013-07-17 15:57:12 EDT
#include <stdio.h>

typedef struct { int x; } A;

void (*function(A *a))(void)
{
    printf("%d\n", a->x);
    return NULL;
}

int main()
{
    A a = { 7 };
    function(&a);
    return 0;
}



In the C code above, a "Field 'x' could not be resolved" error is shown at a->x.
Comment 1 Nathan Ridge CLA 2013-07-19 01:33:50 EDT
Works fine for me. Are you using Eclipse Kepler?
Comment 2 Daniel Pirch CLA 2013-07-19 05:44:38 EDT
Using Eclipse Kepler, Build id 20130614-0229

Apparently it happens only in C projects, not in C++ projects.
Comment 3 Nathan Ridge CLA 2013-07-20 02:29:32 EDT
Ah yes, I see it now. I was trying it in C++.
Comment 4 Nathan Ridge CLA 2013-07-22 21:36:39 EDT
Patch: https://git.eclipse.org/r/14763
Comment 5 CDT Genie CLA 2013-07-23 22:22:08 EDT
*** cdt git genie on behalf of Nathan Ridge ***

    Bug 413204 - &quot;field could not be resolved&quot; error in function returning
    function pointer
    Change-Id: I9f2e9b0f46a46232961948fd3d4310e520d95774
    Signed-off-by: Nathan Ridge &lt;zeratul976@xxxxxxxxxxx&gt;
    Reviewed-on: <a  href="https://git.eclipse.org/r/14763">https://git.eclipse.org/r/14763</a>
    Reviewed-by: Sergey Prigogin &lt;eclipse.sprigogin@xxxxxxxxx&gt;
    IP-Clean: Sergey Prigogin &lt;eclipse.sprigogin@xxxxxxxxx&gt;
    Tested-by: Sergey Prigogin &lt;eclipse.sprigogin@xxxxxxxxx&gt;

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=2accba3b07e0a9bf177431521ca4ce442609c6e0
Comment 6 Marc-André Laperle CLA 2013-07-29 12:19:57 EDT
Fixed in 8.2.1 and master.
Comment 7 Nathan Ridge CLA 2013-08-25 22:59:05 EDT
This still doesn't work in C. It looks like the test I wrote only tests it for C++ (which is strange as it already worked in C++...).

Anyways, reopening.
Comment 8 Nathan Ridge CLA 2013-08-26 02:02:58 EDT
This patch fixes the test and the code: https://git.eclipse.org/r/#/c/15840/
Comment 9 CDT Genie CLA 2013-08-26 23:22:17 EDT
*** cdt git genie on behalf of Nathan Ridge ***

    Bug 413204 - &quot;field could not be resolved&quot; error in function returning
    function pointer (really fixed this time)
    Change-Id: Ica4255ca554db6952248fe1fae53d188a1b78d75
    Signed-off-by: Nathan Ridge &lt;zeratul976@xxxxxxxxxxx&gt;
    Reviewed-on: <a  href="https://git.eclipse.org/r/15840">https://git.eclipse.org/r/15840</a>
    Reviewed-by: Sergey Prigogin &lt;eclipse.sprigogin@xxxxxxxxx&gt;
    IP-Clean: Sergey Prigogin &lt;eclipse.sprigogin@xxxxxxxxx&gt;
    Tested-by: Sergey Prigogin &lt;eclipse.sprigogin@xxxxxxxxx&gt;

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=9745cb982655172e4a354dd967e80dee06ad3bc5
Comment 10 Sergey Prigogin CLA 2013-08-27 16:34:05 EDT
Fixed in cdt_8_2 and master.