public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: doko@gcc.gnu.org, gaiusmod2@gmail.com
Subject: [PATCH] m2: Use time_t in time and don't redefine alloca
Date: Tue, 23 Jan 2024 05:55:07 -0800	[thread overview]
Message-ID: <20240123135507.158395-1-hjl.tools@gmail.com> (raw)

Fix the m2 build warning and error:

[...]
../../src/gcc/m2/mc/mc.flex:32:9: warning: "alloca" redefined
   32 | #define alloca __builtin_alloca
      |         ^~~~~~
In file included from /usr/include/stdlib.h:587,
                 from <stdout>:22:
/usr/include/alloca.h:35:10: note: this is the location of the previous definition
   35 | # define alloca(size)   __builtin_alloca (size)
      |          ^~~~~~
../../src/gcc/m2/mc/mc.flex: In function 'handleDate':
../../src/gcc/m2/mc/mc.flex:333:25: error: passing argument 1 of 'time' from incompatible point
er type [-Wincompatible-pointer-types]
  333 |   time_t  clock = time ((long *)0);
      |                         ^~~~~~~~~
      |                         |
      |                         long int *
In file included from ../../src/gcc/m2/mc/mc.flex:28:
/usr/include/time.h:76:29: note: expected 'time_t *' {aka 'long long int *'} but argument is of
 type 'long int *'
   76 | extern time_t time (time_t *__timer) __THROW;

	PR bootstrap/113554
	* mc/mc.flex (alloca): Don't redefine.
	(handleDate): Replace (long *)0 with (time_t *)0 when calling
	time.
---
 gcc/m2/mc/mc.flex | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/m2/mc/mc.flex b/gcc/m2/mc/mc.flex
index bd37d5ad100..7c841bf8d63 100644
--- a/gcc/m2/mc/mc.flex
+++ b/gcc/m2/mc/mc.flex
@@ -28,9 +28,11 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #include <time.h>
 #include <ctype.h>
 
+#ifndef alloca
 #ifdef __GNUC__
 #define alloca __builtin_alloca
 #endif
+#endif
 
 #if !defined(TRUE)
 #  define TRUE (1==1)
@@ -330,7 +332,7 @@ handleColumn (void)
 static void
 handleDate (void)
 {
-  time_t  clock = time ((long *)0);
+  time_t  clock = time ((time_t *)0);
   char   *sdate = ctime (&clock);
   char   *s     = (char *)alloca (strlen (sdate)+2+1);
   char   *p     = strchr(sdate, '\n');
-- 
2.43.0


             reply	other threads:[~2024-01-23 13:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-23 13:55 H.J. Lu [this message]
2024-01-23 14:05 ` Gaius Mulley

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=20240123135507.158395-1-hjl.tools@gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=doko@gcc.gnu.org \
    --cc=gaiusmod2@gmail.com \
    --cc=gcc-patches@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).