This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 270898 - Code Completion wrong type with declaring multiple structs with a macro
Summary: Code Completion wrong type with declaring multiple structs with a macro
Status: NEW
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 8.2
Hardware: PC All
: P3 normal with 1 vote (vote)
Assignee: petrk
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-16 20:37 UTC by kmhallen
Modified: 2018-10-12 17:25 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screenshot (96.16 KB, image/png)
2017-06-16 20:37 UTC, kmhallen
Details
test case (1.22 KB, text/plain)
2017-06-16 20:39 UTC, kmhallen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kmhallen 2017-06-16 20:37:39 UTC
Created attachment 164559 [details]
Screenshot

When declaring multiple structures in the same macro, the code completion incorrectly types all structures as the last used type. Example below.

All of the following have the type MsgC, when they should be MsgA/MsgB/MsgC.
list2_.aaa.msg.a
list2_.bbb.msg.b
list2_.ccc.msg.c



/******************************************************************************/

// Simple message structures
typedef struct { int a; } MsgA;
typedef struct { int b; } MsgB;
typedef struct { int c; } MsgC;
typedef struct { int d; } MsgD;
typedef struct { int e; } MsgE;
typedef struct { int f; } MsgF;

// X-Macro for list elements: X(name,MsgName)
#define MY_LIST1 \
X(aaa, MsgA)\
X(bbb, MsgB)\
X(ccc, MsgC)\

// X-Macro for list elements: X(name,MsgName)
#define MY_LIST2 \
X(ddd, MsgD)\
X(eee, MsgE)\
X(fff, MsgF)\

// Generate structure of all messages
#define X(name,MsgName) MsgName name;
static struct { MY_LIST1 MY_LIST2 } list1_ = {0};
#undef X

// Generate structure of all messages
#define X(name,MsgName) struct { MsgName msg; } name;
static struct { MY_LIST1 MY_LIST2 } list2_ = {0};
#undef X

// Generate structure of all messages
#define X(name,MsgName) struct { MsgName msg; } list3_##name;
MY_LIST1 MY_LIST2
#undef X

static void test() {
    list1_.aaa.a; list1_.ddd.d;
    list1_.bbb.b; list1_.eee.e;
    list1_.ccc.c; list1_.fff.f;
    list2_.aaa.msg.a; list2_.ddd.msg.d;
    list2_.bbb.msg.b; list2_.eee.msg.e;
    list2_.ccc.msg.c; list2_.fff.msg.f;
    list3_aaa.msg.a; list3_ddd.msg.d;
    list3_bbb.msg.b; list3_eee.msg.e;
    list3_ccc.msg.c; list3_fff.msg.f;
}
Comment 1 kmhallen 2017-06-16 20:39:50 UTC
Created attachment 164560 [details]
test case
Comment 2 kmhallen 2018-10-12 17:25:43 UTC
New issue: https://issues.apache.org/jira/browse/NETBEANS-1413