This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++: undefined local static variable
- To: snyder at fnal dot gov
- Subject: Re: c++: undefined local static variable
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Wed, 26 Jul 2000 21:50:55 -0700
- Cc: gcc-bugs at gcc dot gnu dot org
- Organization: CodeSourcery, LLC
- References: <200007262155.QAA16464@d0sgibnl1.fnal.gov>
>>>>> "scott" == scott snyder <snyder@fnal.gov> writes:
scott> hi -
scott> For a recent cvs version of g++ (2.96 20000724 on
scott> i686-pc-linux-gnu), the following input generates a
scott> reference to a symbol that is not present in the assembly
Interesting. This represents an improvement in a sense. In previous
version of G++, we kept the `cleanup' variable, even though we didn't
need it, since it was only used in an inline function we didn't emit.
My patch caused us to stop emitting the variable (a good thing), but
failed to stop us from emitting the associated cleanup function. This
patch stops us from emitting the cleanup function, too.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2000-07-26 Mark Mitchell <mark@codesourcery.com>
* decl.c (start_cleanup_fn): Mark the function as `inline'.
* decl2.c (get_guard): Call cp_finish_decl, not
rest_of_decl_compilation, for local guards.
* lex.c (do_identifier): Remove unused variable.
Index: decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.661
diff -c -p -r1.661 decl.c
*** decl.c 2000/07/25 20:19:23 1.661
--- decl.c 2000/07/27 04:40:02
*************** start_cleanup_fn ()
*** 8362,8367 ****
--- 8362,8372 ----
compiler. */
TREE_PUBLIC (fndecl) = 0;
DECL_ARTIFICIAL (fndecl) = 1;
+ /* Make the function `inline' so that it is only emitted if it is
+ actually needed. It is unlikely that it will be inlined, since
+ it is only called via a function pointer, but we avoid unncessary
+ emissions this way. */
+ DECL_INLINE (fndecl) = 1;
/* Build the parameter. */
if (flag_use_cxa_atexit)
{
Index: decl2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl2.c,v
retrieving revision 1.378
diff -c -p -r1.378 decl2.c
*** decl2.c 2000/07/25 20:19:24 1.378
--- decl2.c 2000/07/27 04:40:06
*************** get_guard (decl)
*** 2866,2872 ****
if (!flag_new_abi && !DECL_NAMESPACE_SCOPE_P (decl))
{
guard = get_temp_name (integer_type_node);
! rest_of_decl_compilation (guard, NULL_PTR, 0, 0);
return guard;
}
--- 2866,2872 ----
if (!flag_new_abi && !DECL_NAMESPACE_SCOPE_P (decl))
{
guard = get_temp_name (integer_type_node);
! cp_finish_decl (guard, NULL_TREE, NULL_TREE, 0);
return guard;
}
Index: lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/lex.c,v
retrieving revision 1.210
diff -c -p -r1.210 lex.c
*** lex.c 2000/07/25 20:19:24 1.210
--- lex.c 2000/07/27 04:40:08
*************** do_identifier (token, parsing, args)
*** 3071,3077 ****
{
register tree id;
int lexing = (parsing == 1);
- int in_call = (parsing == 2);
if (! lexing || IDENTIFIER_OPNAME_P (token))
id = lookup_name (token, 0);
--- 3071,3076 ----