public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Miro Palmu <email@miropalmu.cc>
To: gcc@gcc.gnu.org
Subject: Questions about language hooks and some macro definitions
Date: Fri, 8 Mar 2024 23:58:18 +0200	[thread overview]
Message-ID: <17ae3018-9c38-434a-a1df-169519182a74@miropalmu.cc> (raw)

Hello,

I have been trying to understand the higher level structure of g++,
so I have been reading the source code. I'm not sure about some
things and asked the dev irc channel. There I was recommended to ask
them here so:

1) Is there some reason, why following language hook definitions
   have not been removed from cp/cp-lang.cc:

       LANG_HOOKS_CLEAR_BINDING_STACK pop_everything
       LANG_HOOKS_HANDLE_FILENAME c_common_handle_filename

   as they were removed in following patches:

       2008-03-11  Paolo Bonzini  <bonzini@gnu.org>
   
           * langhooks-def.h (LANG_HOOKS_CLEAR_BINDING_STACK): Delete.
           * langhooks.h (struct lang_hooks): delete clear_binding_stack member.
           * toplev.c (compile_file): Don't call it.

       2003-07-31  Per Bothner  <pbothner@apple.com>

           * opts.c (in_fnames, num_in_fnames):  Moved here from c-opts.
           (add_input_filename):  New function.
           (handle_options):  Call add_input_filename directly instead of
           with a lang hook.
           * opts.h (in_fnames, num_in_fnames):  Moved here.
           (add_input_filename):  Declare.
           * c-decl.c:  Need to #include opts.h.
           * Makefile.in (c-decl.o):  Also depends on opts.h.
           * c-opts.c (in_fnames, num_in_fnames):  Moved to opts.c.
           (c_common_handle_filename):  Replaced by add_input_filename.
           * c-common.h (in_fnames, num_in_fnames, c_common_handle_filename):
           Remove.
           * langhooks.h (struct lang_hooks):  Remove handle_filename hook.
           * langhooks-def.h (LANG_HOOKS_HANDLE_FILENAME):  Remove macro.
           (LANG_HOOKS_INITIALIZER):  Remove use of LANG_HOOKS_HANDLE_FILENAME.
           * c-lang.c (LANG_HOOKS_HANDLE_FILENAME):  Remove macro.

2) Why macro FROB_CONTEXT in cp/cp-tree.h:

       #define FROB_CONTEXT(NODE) \
         ((NODE) == global_namespace ? DECL_CONTEXT (NODE) : (NODE))

   returns DECL_CONTEXT (NODE) if NODE is global_namespace,
   as the gcc internal manual says that:
   
     > The DECL_CONTEXT for the global_namespace is NULL_TREE
   
   Isn't DECL_CONTEXT (NODE) redundant and could be replaced by NULL_TREE?

I assume that the answers for both is simply that, nobody just has not written
a patch removing them. However I'm not sure as there might be some
deeper reason that I'm not understanding.

-- 
Miro Palmu

                 reply	other threads:[~2024-03-08 21:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17ae3018-9c38-434a-a1df-169519182a74@miropalmu.cc \
    --to=email@miropalmu.cc \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).