This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: On a piece of code in C++ and nested functions
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Steven Bosscher <s dot bosscher at student dot tudelft dot nl>
- Cc: mark at codesourcery dot com, gcc at gcc dot gnu dot org
- Date: 15 Sep 2003 15:52:53 +0200
- Subject: Re: On a piece of code in C++ and nested functions
- Organization: Integrable Solutions
- References: <1063632819.3989.2.camel@steven.lr-s.tudelft.nl>
Steven Bosscher <s.bosscher@student.tudelft.nl> writes:
| Hi,
|
| In cp/decl.c, there's the following piece of code to expand nested
| functions,
|
| 979 /* Output any nested inline functions within this block
| 980 if they weren't already output. */
| 981 for (decl = decls; decl; decl = TREE_CHAIN (decl))
| 982 if (TREE_CODE (decl) == FUNCTION_DECL
| 983 && ! TREE_ASM_WRITTEN (decl)
| 984 && DECL_INITIAL (decl) != NULL_TREE
| 985 && TREE_ADDRESSABLE (decl)
| 986 && decl_function_context (decl) == current_function_decl)
| 987 {
| 988 /* If this decl was copied from a file-scope decl
| 989 on account of a block-scope extern decl,
| 990 propagate TREE_ADDRESSABLE to the file-scope decl. */
| 991 if (DECL_ABSTRACT_ORIGIN (decl) != NULL_TREE)
| 992 TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (decl)) = 1;
| 993 else
| 994 {
| 995 push_function_context ();
| 996 output_inline_function (decl);
| 997 pop_function_context ();
| 998 }
| 999 }
|
| that hasn't been touched since revision 1.1. The manual says that
| "Nested functions are not supported for GNU C++." So what's the purpose
| of this code? Can it be removed?
I would say that it is a leftover of the era when cc1plus started as
copy-n-paste of cc1. Moreover, C++ provides clean and standard ways
to implement inline nested-functions in terms of local classes.
I would suggest to get rid of that piece of code.
-- Gaby