[Ada] Patch to make constants visible at -O0
Richard Henderson
rth@redhat.com
Thu Oct 11 10:48:00 GMT 2001
On Wed, Oct 10, 2001 at 04:40:55PM -0700, Richard Henderson wrote:
> Compare with the following c++ program:
>
> const int foo = 42;
>
> Note that C++, unline C, defines "foo" to be an integer constant
> expression; foo need not appear in any data segment.
>
> Dwarf2, for instance, is able to represent this directly in
> the debugging info. Though I see that there is a bug in that
> at the moment...
This fixes that bug.
r~
* dwarf2out.c (rtl_for_decl_location): If no DECL_RTL, look
for a DECL_INITIAL.
Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.315
diff -c -p -d -r1.315 dwarf2out.c
*** dwarf2out.c 2001/10/11 03:15:27 1.315
--- dwarf2out.c 2001/10/11 17:44:19
*************** rtl_for_decl_location (decl)
*** 8567,8572 ****
--- 8567,8582 ----
#endif
}
+ /* A variable with no DECL_RTL but a DECL_INITIAL is a compile-time
+ constant, and will have been substituted directly into all
+ expressions that use it. C does not have such a concept, but
+ C++ and other languages do. */
+ else if (DECL_INITIAL (decl))
+ {
+ rtl = expand_expr (DECL_INITIAL (decl), NULL_RTX, VOIDmode,
+ EXPAND_INITIALIZER);
+ }
+
return rtl;
}
More information about the Gcc-patches
mailing list