public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Iain Sandoe <iains.gcc@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: [pushed] Objective-C/C++: Ensure sufficient setup for the preprocessor.
Date: Thu, 18 Jan 2024 14:36:13 +0000	[thread overview]
Message-ID: <20240118143613.24772-1-iain@sandoe.co.uk> (raw)

This is a regression fix where non-trivial Objective-C parses would
ICE when given -save-temps (ICE in the lexer).

This is a short-term fix for stage-4.  ISTM that we should not really
be making use of these functions in lexing and hopefully in GCC-15
we can take a look at moving the functionality to a later phase.

Tested on i686, powerpc, x86_64 Darwin, x86_64 Linux, pushed to trunk,
thanks
Iain

--- 8< ---

The tokenizer makes use of functions that determine if identifiers
are interface or class names, and those functions need a hash map
to be set up.

This ensures that these are initialized before pre-process-only
jobs are run.

gcc/objc/ChangeLog:

	* objc-act.cc (objc_init): Initialize interface and class
	name hash maps before the preprocessor uses them.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
---
 gcc/objc/objc-act.cc | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/objc/objc-act.cc b/gcc/objc/objc-act.cc
index 143134832ff..cec64c4bfbd 100644
--- a/gcc/objc/objc-act.cc
+++ b/gcc/objc/objc-act.cc
@@ -345,6 +345,11 @@ bool
 objc_init (void)
 {
   bool ok;
+
+  /* Set up stuff used by the preprocessor as well as FE parser.  */
+  interface_hash_init ();
+  hash_init ();
+
 #ifdef OBJCPLUS
   if (cxx_init () == false)
 #else
@@ -374,8 +379,6 @@ objc_init (void)
 
   /* Set up stuff used by FE parser and all runtimes.  */
   errbuf = XNEWVEC (char, 1024 * 10);
-  interface_hash_init ();
-  hash_init ();
   objc_encoding_init ();
   /* ... and then check flags and set-up for the selected runtime ... */
   if (flag_next_runtime && flag_objc_abi >= 2)
-- 
2.39.2 (Apple Git-143)


                 reply	other threads:[~2024-01-18 14:36 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=20240118143613.24772-1-iain@sandoe.co.uk \
    --to=iains.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=iain@sandoe.co.uk \
    /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).