[Rose-public] Identifying class static member variables

Phil Miller mille121 at illinois.edu
Mon Sep 9 12:31:05 PDT 2013


Ping. Is the behavior described below as expected, or is there some issue
in ROSE leading to this result?


On Tue, Sep 3, 2013 at 2:25 AM, Phil Miller <mille121 at illinois.edu> wrote:

> Consider the following C++ code:
> ====
> int g;
> static int h;
>
> struct C {
>   static int f;
>   int m;
> };
>
> int C::f = 0;
>
> void foo()
> {
>   static int a;
>   int i;
> }
> ====
>
> When I traverse the AST and print the SgStorageModifier for each
> SgInitializedName, I get a rather surprising result:
> ====
> Found variable declaration 0x7fbfb2ccf0c0 "g"
> SgStorageModifier(isUnknown() = false isDefault() = false isExtern() =
> false isStatic() = false isAuto() = false isUnspecified() = true
> isTypedef() = false isRegister() = false isMutable() = false isAsm() =
> false ) global privatize
> Found variable declaration 0x7fbfb2ccf1e8 "h"
> SgStorageModifier(isUnknown() = false isDefault() = false isExtern() =
> false isStatic() = true isAuto() = false isUnspecified() = false
> isTypedef() = false isRegister() = false isMutable() = false isAsm() =
> false ) global privatize
> Found variable declaration 0x7fbfb2ccf310 "f"
> SgStorageModifier(isUnknown() = false isDefault() = true isExtern() =
> false isStatic() = false isAuto() = false isUnspecified() = false
> isTypedef() = false isRegister() = false isMutable() = false isAsm() =
> false ) local leave
> Found variable declaration 0x7fbfb2ccf438 "m"
> SgStorageModifier(isUnknown() = false isDefault() = true isExtern() =
> false isStatic() = false isAuto() = false isUnspecified() = false
> isTypedef() = false isRegister() = false isMutable() = false isAsm() =
> false ) local leave
> Found variable declaration 0x7fbfb2ccf560 "f"
> SgStorageModifier(isUnknown() = false isDefault() = false isExtern() =
> false *isStatic() = false* isAuto() = false isUnspecified() = true
> isTypedef() = false isRegister() = false isMutable() = false isAsm() =
> false ) local leave
> Found variable declaration 0x7fbfb2ccf688 "a"
> SgStorageModifier(isUnknown() = false isDefault() = false isExtern() =
> false isStatic() = true isAuto() = false isUnspecified() = false
> isTypedef() = false isRegister() = false isMutable() = false isAsm() =
> false ) local privatize
> Found variable declaration 0x7fbfb2ccf7b0 "i"
> SgStorageModifier(isUnknown() = false isDefault() = false isExtern() =
> false isStatic() = false isAuto() = false isUnspecified() = true
> isTypedef() = false isRegister() = false isMutable() = false isAsm() =
> false ) local leave
> ====
>
> For some reason, the global and function scoped static variable
> declarations show up as static, but not the class scoped variable
> declaration. This seems wrong to me.
>
> Is there something I'm missing, an different way I should be checking for
> that property aside from looking at the SgStorageModifier, or is this a bug
> in ROSE?
>
> Thanks.
>
> Phil
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nersc.gov/pipermail/rose-public/attachments/20130909/a8f99fb8/attachment.html>


More information about the rose-public mailing list