[ 
https://issues.apache.org/jira/browse/NETBEANS-1413?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kevin Hallenbeck updated NETBEANS-1413:
---------------------------------------
    Description: 
Migrated issue from old issue tracker: 
[https://netbeans.org/bugzilla/show_bug.cgi?id=270898]

When declaring multiple structures in the same macro, the code model 
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.
{code:java}
list2_.aaa.msg.a
list2_.bbb.msg.b
list2_.ccc.msg.c{code}
 

 

 
{code:java}
// 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;
 }
{code}
 

  was:
Migrated issue from old issue tracker: 
[https://netbeans.org/bugzilla/show_bug.cgi?id=270898]

When declaring multiple structures in the same macro, the code model 
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.
{code:java}
list2_.aaa.msg.a
list2_.bbb.msg.b
list2_.ccc.msg.c{code}
 

 
{code:java}
// 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;
 }
{code}
 


> Code Model: Wrong type when declaring multiple structs with a macro
> -------------------------------------------------------------------
>
>                 Key: NETBEANS-1413
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-1413
>             Project: NetBeans
>          Issue Type: Bug
>          Components: cnd - Code Model
>            Reporter: Kevin Hallenbeck
>            Priority: Minor
>         Attachments: netbeans_struct_macro.png, test.c
>
>
> Migrated issue from old issue tracker: 
> [https://netbeans.org/bugzilla/show_bug.cgi?id=270898]
> When declaring multiple structures in the same macro, the code model 
> 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.
> {code:java}
> list2_.aaa.msg.a
> list2_.bbb.msg.b
> list2_.ccc.msg.c{code}
>  
>  
>  
> {code:java}
> // 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;
>  }
> {code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to