[Dwarf-Discuss] DW_AT_accessibility default

Robinson, Paul T (NonStop) paul.t.robinson at hp.com
Thu Jul 29 12:08:13 PDT 2010


>> Should for DIE parents other than DW_TAG_{structure,interface,union,class}_type
>> DW_AT_accessibility be not considered meaningful?
>
>I don't know of a language which has similar attributes for
>non-class members.  C++/Java do not allow public or private
>attributes to be applied to anything which is not a member of
>a class/etc.

Obscure Feature of the Day time....

Most languages that support nested routines (Algol, Pascal, etc)
give an inner routine full access to all the variables and stuff
in the outer routine that contains it.  You can think of this in
a couple of ways, e.g. the inner routine automatically imports
everything from the outer routine.

When the COBOL committee defined nesting, bless their hearts,
they thought of the visibility of variables inward as being a
lot like visibility outward.  That is, if you want a variable
to be visible outside the compilation, you have to tell the
compiler by marking it EXTERNAL; so, if you want a variable to
be visible to an inner routine, you also have to tell the 
compiler by marking it GLOBAL.  By default, an inner routine
does not have access to variables in the outer routine.

You can, of course, have very perverted situations.

PROG-A defines VAR-1 and contains PROG-B;
PROG-B defines VAR-1 and contains PROG-C;
PROG-C references VAR-1.

If PROG-A's VAR-1 is marked GLOBAL, and PROG-B's is not,
then PROG-C refers to PROG-A's variable, not PROG-B's.
PROG-B of course cannot refer to PROG-A's VAR-1, because
PROG-B has its own VAR-1; it has to call its nested routine
PROG-C in order to access the outer VAR-1.

(In all fairness, I should mention that in the COBOL-2002
standard, the new stuff all uses "normal" scoping rules,
i.e. everything is GLOBAL automatically.  It's only in creaky
old fuddy-duddy procedural code, which is probably 99% of all
COBOL everywhere, that GLOBAL is still necessary.)

Dragging the conversation back on-topic...
My compiler uses DW_AT_visibility to indicate which variables 
are visible to inner routines and which are not, as an
attribute on DW_TAG_variable.  This seems like something of
an abuse of the attribute, and I am not inclined to propose
it as an amendment to the standard.

--paulr



More information about the Dwarf-Discuss mailing list