Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA]: Remove warnings from ada-exp.tab.c compilation
@ 2004-10-05 10:37 Paul Hilfinger
  2004-10-05 19:47 ` Andrew Cagney
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Hilfinger @ 2004-10-05 10:37 UTC (permalink / raw)
  To: gdb-patches


I propose to commit the following tonight if there is no objection,
but post it here first because it involves a change to Makefile.in
(granted, to a part of Makefile.in only Ada uses at the moment).

The patch is more involved than I anticipated in order to deal with
the several different versions of Flex that are still at large; it
also fixes some misprints in the .l.c rule.

Paul Hilfinger

2004-10-05  Paul N. Hilfinger  <Hilfinger@gnat.com>

	* Makefile.in (.l.c): Do conversions of names of alloc and free 
	functions that are done for .y.c files, plus special one
	for yy_flex_realloc.  Also, correct missing-file tests here.
	* ada-lex.l (malloc, free): Remove macros.
	(resize_tempbuf): Use "realloc"; rely on sed changes to convert to
	xrealloc.
	(ada_flex_use): Dummy definition to remove warnings about unused
	functions.
	* ada-exp.y (dummy_string_to_ada_operator): Temporary definition
	to suppress warning.

Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.637
diff -u -p -r1.637 Makefile.in
--- gdb/Makefile.in	3 Oct 2004 08:35:57 -0000	1.637
+++ gdb/Makefile.in	5 Oct 2004 10:26:07 -0000
@@ -1582,14 +1582,24 @@ po/$(PACKAGE).pot: force
 	-rm $@.tmp
 	mv $@.new ./$*.c
 .l.c:
-	@if [ "$(FLEX)" ] && $(FLEX) --version >/dev/null 2>&1; then \
-	    echo $(FLEX) -o$@ $<; \
-	    $(FLEX) -o$@ $<; \
-	elif [ ! -f $@ -a ! -f $< ]; then \
-	    echo "$< missing and flex not available."; \
-	    false; \
-	elif [ ! -f $@ ]; then \
+	if [ "$(FLEX)" ] && $(FLEX) --version >/dev/null 2>&1; then \
+	    $(FLEX) -o$@ $< && \
+	    rm -f $@.new && \
+	    sed -e '/extern.*malloc/d' \
+	        -e '/extern.*realloc/d' \
+	        -e '/extern.*free/d' \
+	        -e '/include.*malloc.h/d' \
+	        -e 's/malloc/xmalloc/g' \
+	        -e 's/realloc/xrealloc/g' \
+		-e 's/yy_flex_xrealloc/yyxrealloc/g' \
+	      < $@ > $@.new && \
+	    rm -f $@ && \
+	    mv $@.new $@; \
+	elif [ -f $@ ]; then \
 	    echo "Warning: $*.c older than $*.l and flex not available."; \
+	else \
+	    echo "$@ missing and flex not available."; \
+	    false; \
 	fi
 
 .PRECIOUS: ada-exp.c ada-lex.c
Index: gdb/ada-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/ada-exp.y,v
retrieving revision 1.12
diff -u -p -r1.12 ada-exp.y
--- gdb/ada-exp.y	18 Sep 2004 22:23:23 -0000	1.12
+++ gdb/ada-exp.y	5 Oct 2004 10:26:07 -0000
@@ -952,3 +952,13 @@ _initialize_ada_exp (void)
 {
   obstack_init (&temp_parse_space);
 }
+
+/* FIXME: Temporary measure to remove warning.  The function
+   string_to_operator is supposed to be used for cases where one
+   calls an operator function with prefix notation, as in 
+   "+" (a, b), but at some point, this code seems to have gone
+   missing. */
+
+struct stoken (*dummy_string_to_ada_operator) (struct stoken) 
+     = string_to_operator;
+
Index: gdb/ada-lex.l
===================================================================
RCS file: /cvs/src/src/gdb/ada-lex.l,v
retrieving revision 1.8
diff -u -p -r1.8 ada-lex.l
--- gdb/ada-lex.l	3 Oct 2004 08:35:56 -0000	1.8
+++ gdb/ada-lex.l	5 Oct 2004 10:26:07 -0000
@@ -42,8 +42,6 @@ EXP	(e[+-]{NUM10})
 POSEXP  (e"+"?{NUM10})
 
 %{
-#define malloc xmalloc
-#define free xfree
 
 #define NUMERAL_WIDTH 256
 #define LONGEST_SIGN ((ULONGEST) 1 << (sizeof(LONGEST) * HOST_CHAR_BIT - 1))
@@ -349,7 +347,7 @@ resize_tempbuf (unsigned int n)
   if (tempbufsize < n)
     {
       tempbufsize = (n+63) & ~63;
-      tempbuf = (char *) xrealloc (tempbuf, tempbufsize);
+      tempbuf = (char *) realloc (tempbuf, tempbufsize);
     }
 }
 
@@ -923,3 +921,10 @@ yywrap(void)
 {
   return 1;
 }
+
+/* Dummy definition to suppress warnings about unused static definitions. */
+typedef void (*dummy_function) ();
+dummy_function ada_flex_use[] = 
+{ 
+  (dummy_function) yyrealloc, (dummy_function) yyunput
+};


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA]: Remove warnings from ada-exp.tab.c compilation
  2004-10-05 10:37 [RFA]: Remove warnings from ada-exp.tab.c compilation Paul Hilfinger
@ 2004-10-05 19:47 ` Andrew Cagney
  2004-10-06  9:31   ` Paul Hilfinger
  2004-10-06  9:47   ` Paul Hilfinger
  0 siblings, 2 replies; 6+ messages in thread
From: Andrew Cagney @ 2004-10-05 19:47 UTC (permalink / raw)
  To: Paul Hilfinger; +Cc: gdb-patches

> +/* FIXME: Temporary measure to remove warning.  The function

I'd write this as:

	/* FIXME: hilfingr/2004-10-05: Hack to remove warning.  ...

so that who added the note and when are clear.  If you're curious grep 
for this pattern in the sources and quickly discover how old some of 
those tempoary hacks are :-)

otherwize ok,
Andrew

PS:
+      tempbuf = (char *) realloc (tempbuf, tempbufsize);
the cast is redundant - realloc returns (void *).

Andrew



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA]: Remove warnings from ada-exp.tab.c compilation
  2004-10-05 19:47 ` Andrew Cagney
@ 2004-10-06  9:31   ` Paul Hilfinger
  2004-10-06  9:47   ` Paul Hilfinger
  1 sibling, 0 replies; 6+ messages in thread
From: Paul Hilfinger @ 2004-10-06  9:31 UTC (permalink / raw)
  To: gdb-patches


Now committed.

Paul Hilfinger

ChangeLog:

2004-10-06  Paul N. Hilfinger  <Hilfinger@gnat.com>

	* Makefile.in (.l.c): Do conversions of names of alloc and free 
	functions that are done for .y.c files, plus special one
	for yy_flex_realloc.  Also, correct missing-file tests here.
	* ada-lex.l (malloc, free): Remove macros.
	(resize_tempbuf): Use "realloc"; rely on sed changes to convert to
	xrealloc.
	(ada_flex_use): Dummy definition to remove warnings about unused
	functions.
	* ada-exp.y (dummy_string_to_ada_operator): Temporary definition
	to suppress warning.
	

Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.637
diff -u -p -r1.637 Makefile.in
--- gdb/Makefile.in	3 Oct 2004 08:35:57 -0000	1.637
+++ gdb/Makefile.in	6 Oct 2004 09:25:42 -0000
@@ -1582,14 +1582,24 @@ po/$(PACKAGE).pot: force
 	-rm $@.tmp
 	mv $@.new ./$*.c
 .l.c:
-	@if [ "$(FLEX)" ] && $(FLEX) --version >/dev/null 2>&1; then \
-	    echo $(FLEX) -o$@ $<; \
-	    $(FLEX) -o$@ $<; \
-	elif [ ! -f $@ -a ! -f $< ]; then \
-	    echo "$< missing and flex not available."; \
-	    false; \
-	elif [ ! -f $@ ]; then \
+	if [ "$(FLEX)" ] && $(FLEX) --version >/dev/null 2>&1; then \
+	    $(FLEX) -o$@ $< && \
+	    rm -f $@.new && \
+	    sed -e '/extern.*malloc/d' \
+	        -e '/extern.*realloc/d' \
+	        -e '/extern.*free/d' \
+	        -e '/include.*malloc.h/d' \
+	        -e 's/malloc/xmalloc/g' \
+	        -e 's/realloc/xrealloc/g' \
+		-e 's/yy_flex_xrealloc/yyxrealloc/g' \
+	      < $@ > $@.new && \
+	    rm -f $@ && \
+	    mv $@.new $@; \
+	elif [ -f $@ ]; then \
 	    echo "Warning: $*.c older than $*.l and flex not available."; \
+	else \
+	    echo "$@ missing and flex not available."; \
+	    false; \
 	fi
 
 .PRECIOUS: ada-exp.c ada-lex.c
Index: gdb/ada-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/ada-exp.y,v
retrieving revision 1.12
diff -u -p -r1.12 ada-exp.y
--- gdb/ada-exp.y	18 Sep 2004 22:23:23 -0000	1.12
+++ gdb/ada-exp.y	6 Oct 2004 09:25:42 -0000
@@ -952,3 +952,13 @@ _initialize_ada_exp (void)
 {
   obstack_init (&temp_parse_space);
 }
+
+/* FIXME: hilfingr/2004-10-05: Hack to remove warning.  The function
+   string_to_operator is supposed to be used for cases where one
+   calls an operator function with prefix notation, as in 
+   "+" (a, b), but at some point, this code seems to have gone
+   missing. */
+
+struct stoken (*dummy_string_to_ada_operator) (struct stoken) 
+     = string_to_operator;
+
Index: gdb/ada-lex.l
===================================================================
RCS file: /cvs/src/src/gdb/ada-lex.l,v
retrieving revision 1.8
diff -u -p -r1.8 ada-lex.l
--- gdb/ada-lex.l	3 Oct 2004 08:35:56 -0000	1.8
+++ gdb/ada-lex.l	6 Oct 2004 09:25:42 -0000
@@ -42,8 +42,6 @@ EXP	(e[+-]{NUM10})
 POSEXP  (e"+"?{NUM10})
 
 %{
-#define malloc xmalloc
-#define free xfree
 
 #define NUMERAL_WIDTH 256
 #define LONGEST_SIGN ((ULONGEST) 1 << (sizeof(LONGEST) * HOST_CHAR_BIT - 1))
@@ -349,7 +347,7 @@ resize_tempbuf (unsigned int n)
   if (tempbufsize < n)
     {
       tempbufsize = (n+63) & ~63;
-      tempbuf = (char *) xrealloc (tempbuf, tempbufsize);
+      tempbuf = (char *) realloc (tempbuf, tempbufsize);
     }
 }
 
@@ -923,3 +921,10 @@ yywrap(void)
 {
   return 1;
 }
+
+/* Dummy definition to suppress warnings about unused static definitions. */
+typedef void (*dummy_function) ();
+dummy_function ada_flex_use[] = 
+{ 
+  (dummy_function) yyrealloc, (dummy_function) yyunput
+};


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA]: Remove warnings from ada-exp.tab.c compilation
  2004-10-05 19:47 ` Andrew Cagney
  2004-10-06  9:31   ` Paul Hilfinger
@ 2004-10-06  9:47   ` Paul Hilfinger
  2004-10-06 10:14     ` Andreas Schwab
  2004-10-06 16:29     ` Andrew Cagney
  1 sibling, 2 replies; 6+ messages in thread
From: Paul Hilfinger @ 2004-10-06  9:47 UTC (permalink / raw)
  To: cagney; +Cc: gdb-patches


> I'd write this as:
> 
> 	/* FIXME: hilfingr/2004-10-05: Hack to remove warning.  ...
> 
> so that who added the note and when are clear.  If you're curious grep 
> for this pattern in the sources and quickly discover how old some of 
> those tempoary hacks are :-)

Thanks for the suggestion.

> _otherwize_ ok,

Is that a Canadian spelling (:->)?

> PS:
> +      tempbuf = (char *) realloc (tempbuf, tempbufsize);
> the cast is redundant - realloc returns (void *).

Yeah, well, call it a personal quirk, call it an act of rebellion.
But when I see an ISO standard that tells me I don't need this conversion
by saying that

   "A pointer to void shall have the same representation and 
    alignment requirements as a pointer to a character type."

and then tells me IN A FOOTNOTE that 

   "The same representation and alignment requirements are meant to
    imply interchangeability as arguments to functions, return values
    from functions, and members of unions."

the horror I feel at this shameless confusion of abstraction layers is such
that I feel compelled to ignore the passages altogether (:->).

Paul Hilfinger


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA]: Remove warnings from ada-exp.tab.c compilation
  2004-10-06  9:47   ` Paul Hilfinger
@ 2004-10-06 10:14     ` Andreas Schwab
  2004-10-06 16:29     ` Andrew Cagney
  1 sibling, 0 replies; 6+ messages in thread
From: Andreas Schwab @ 2004-10-06 10:14 UTC (permalink / raw)
  To: Paul Hilfinger; +Cc: cagney, gdb-patches

Paul Hilfinger <hilfingr@gnat.com> writes:

>> PS:
>> +      tempbuf = (char *) realloc (tempbuf, tempbufsize);
>> the cast is redundant - realloc returns (void *).
>
> Yeah, well, call it a personal quirk, call it an act of rebellion.
> But when I see an ISO standard that tells me I don't need this conversion
> by saying that
>
>    "A pointer to void shall have the same representation and 
>     alignment requirements as a pointer to a character type."

This has nothing to do with representation, but with implicit conversion
in an assignment.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA]: Remove warnings from ada-exp.tab.c compilation
  2004-10-06  9:47   ` Paul Hilfinger
  2004-10-06 10:14     ` Andreas Schwab
@ 2004-10-06 16:29     ` Andrew Cagney
  1 sibling, 0 replies; 6+ messages in thread
From: Andrew Cagney @ 2004-10-06 16:29 UTC (permalink / raw)
  To: Paul Hilfinger; +Cc: gdb-patches


>>> PS:
>>> +      tempbuf = (char *) realloc (tempbuf, tempbufsize);
>>> the cast is redundant - realloc returns (void *).
> 
> 
> Yeah, well, call it a personal quirk, call it an act of rebellion.
> But when I see an ISO standard that tells me I don't need this conversion
> by saying that
> 
>    "A pointer to void shall have the same representation and 
>     alignment requirements as a pointer to a character type."
> 
> and then tells me IN A FOOTNOTE that 
> 
>    "The same representation and alignment requirements are meant to
>     imply interchangeability as arguments to functions, return values
>     from functions, and members of unions."
> 
> the horror I feel at this shameless confusion of abstraction layers is such
> that I feel compelled to ignore the passages altogether (:->).

You could make up something like an XREALLOC macro (XCREALLOC?) to go 
with XMALLOC et.al.  That might be needed anyway as while a C compiler 
doesn't require the cast, a C++ one does.

whichever,
Andrew



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-10-06 16:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-05 10:37 [RFA]: Remove warnings from ada-exp.tab.c compilation Paul Hilfinger
2004-10-05 19:47 ` Andrew Cagney
2004-10-06  9:31   ` Paul Hilfinger
2004-10-06  9:47   ` Paul Hilfinger
2004-10-06 10:14     ` Andreas Schwab
2004-10-06 16:29     ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox