public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Checking patch
@ 1998-05-08 12:13 Kaveh R. Ghazi
  1998-05-08 12:13 ` Jeffrey A Law
  1998-05-09  1:39 ` Richard Henderson
  0 siblings, 2 replies; 11+ messages in thread
From: Kaveh R. Ghazi @ 1998-05-08 12:13 UTC (permalink / raw)
  To: law, martin; +Cc: egcs, wilson

 > From: Jeffrey A Law <law@cygnus.com>
 > 
 >   > > gencheck.c uses an ANSI concatenation character (#).
 >   > 
 >   > It doesn't really need concatenation, but stringification, to built
 >   > "VAR_DECL" when given VAR_DECL. Is this also an ANSI-only feature,
 >   > and if so, what is the work-around? Would it be acceptable in gcc
 >   > if tree-check.h is never rebuilt by users of non-ANSI compilers?
 > Sorry.  Second time in 3 months I've see '#' and said concatentation.
 > 
 > I believe we have some autoconf code to detect a working stringify
 > operator.  So you just have to conditionalize your code based on
 > the existence of working stringify.  See gengenrtl.c
 > jeff


	Actually, I'd like to take the opportunity to consolidate
stringify support into system.h, then we can just tell people to use
the STRINGIFY() macro.  (I've found two places which use stringify and
this would make a third.)  So, is this patch okay to install?

		--Kaveh




Fri May  8 11:00:35 1998  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* system.h: Define the STRINGIFY() macro here.
	* protoize.c: Not here.
	* gengenrtl.c (DEF_RTL_EXPR): Use the STRINGIFY() macro.


diff -rup orig/egcs-CVS19980508/gcc/gengenrtl.c egcs-CVS19980508/gcc/gengenrtl.c
--- orig/egcs-CVS19980508/gcc/gengenrtl.c	Fri May  8 09:58:43 1998
+++ egcs-CVS19980508/gcc/gengenrtl.c	Fri May  8 10:20:04 1998
@@ -35,11 +35,7 @@ struct rtx_definition 
   const char *enumname, *name, *format;
 };
 
-#if defined(HAVE_CPP_STRINGIFY) || (defined(__GNUC__) && defined(__STDC__))
-#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) { # ENUM, NAME, FORMAT },
-#else
-#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) { "ENUM", NAME, FORMAT },
-#endif
+#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) { STRINGIFY(ENUM), NAME, FORMAT },
 
 struct rtx_definition defs[] = 
 {  
diff -rup orig/egcs-CVS19980508/gcc/protoize.c egcs-CVS19980508/gcc/protoize.c
--- orig/egcs-CVS19980508/gcc/protoize.c	Fri May  8 09:58:56 1998
+++ egcs-CVS19980508/gcc/protoize.c	Fri May  8 10:18:39 1998
@@ -201,14 +201,6 @@ extern size_t   strlen ()
 
 #define NONCONST
 
-/* Define a STRINGIFY macro that's right for ANSI or traditional C.  */
-
-#if defined(HAVE_CPP_STRINGIFY) || (defined(__GNUC__) && defined(__STDC__))
-#define STRINGIFY(STRING) #STRING
-#else
-#define STRINGIFY(STRING) "STRING"
-#endif
-
 /* Define a default place to find the SYSCALLS.X file.  */
 
 #ifndef STD_PROTO_DIR
diff -rup orig/egcs-CVS19980508/gcc/system.h egcs-CVS19980508/gcc/system.h
--- orig/egcs-CVS19980508/gcc/system.h	Fri May  8 09:59:06 1998
+++ egcs-CVS19980508/gcc/system.h	Fri May  8 10:17:48 1998
@@ -243,4 +243,16 @@
 #endif /* USE_SYSTEM_ABORT */
 #endif /* !abort */
 
+
+/* Define a STRINGIFY macro that's right for ANSI or traditional C.
+   HAVE_CPP_STRINGIFY only refers to the stage1 compiler.  Assume that
+   (non -traditional) gcc used in stage2 or later has the # operator. */
+#ifndef STRINGIFY
+# if defined(HAVE_CPP_STRINGIFY) || (defined(__GNUC__) && defined(__STDC__))
+#  define STRINGIFY(STRING) #STRING
+# else /* Traditional C does macro replacement inside quotes. */
+#  define STRINGIFY(STRING) "STRING"
+# endif
+#endif /* ! STRINGIFY */
+
 #endif /* __GCC_SYSTEM_H__ */

--
Kaveh R. Ghazi			Project Manager / Custom Development
ghazi@caip.rutgers.edu		Icon CMT Corp.

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: Checking patch
@ 1998-05-10  6:17 Kaveh R. Ghazi
  1998-05-11  9:07 ` Richard Henderson
  0 siblings, 1 reply; 11+ messages in thread
From: Kaveh R. Ghazi @ 1998-05-10  6:17 UTC (permalink / raw)
  To: rth; +Cc: egcs, law, martin, wilson

 > From: Richard Henderson <rth@dot.cygnus.com>
 > 
 > On Fri, May 08, 1998 at 11:47:56AM -0400, Kaveh R. Ghazi wrote:
 > > +#ifndef STRINGIFY
 > > +# if defined(HAVE_CPP_STRINGIFY) || (defined(__GNUC__) && defined(__STDC__))
 > > +#  define STRINGIFY(STRING) #STRING
 > 
 > If you are going to do something generic like this, make it
 > 
 > #define STRINGIFY1(STRING)  #STRING
 > #define STRINGIFY(STRING)   STRINGIFY1(STRING)
 > 
 > as otherwise, by ISO rules,
 > 
 > #define foo bar
 > STRINGIFY(foo)
 > 
 > will yield "foo" not "bar" as might be expected.
 > r~




	That's a good point, however I cannot get the !__STDC__ case to
work the same way.  Eg, if I have the following code:



 > #ifdef __STDC__
 > #define STRINGIFY1(STRING) # STRING
 > #else
 > #define STRINGIFY1(STRING) "STRING"
 > #endif
 > #define STRINGIFY(STRING) STRINGIFY1(STRING)
 > 
 > #define FOO hello world
 > 
 > int main()
 > {
 >   char * f = STRINGIFY(FOO);
 > }

preprocessing this file with "gcc -E foo.c" yields:

 > int main()
 > {
 >   char * f = "hello world"  ;
 > }

whereas using "gcc -traditional -E foo.c" gives:

 > int main()
 > {
 >   char * f = "FOO";
 > }

	So I'm not sure we want to support this behavior unless we can
find a way to make KNRish compilers handle the same construct, else
stage1 may break on hosts like sunos4, hpux9, etc.

	Do you have any ideas on how to solve this?

		Thanks,
		--Kaveh
--
Kaveh R. Ghazi			Project Manager / Custom Development
ghazi@caip.rutgers.edu		Icon CMT Corp.

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: Checking patch
@ 1998-05-12  9:49 Kaveh R. Ghazi
  0 siblings, 0 replies; 11+ messages in thread
From: Kaveh R. Ghazi @ 1998-05-12  9:49 UTC (permalink / raw)
  To: rth; +Cc: egcs, law, martin, wilson

 > From: Richard Henderson <rth@dot.cygnus.com>
 > 
 > On Sun, May 10, 1998 at 09:17:33AM -0400, Kaveh R. Ghazi wrote:
 > > 	That's a good point, however I cannot get the !__STDC__ case to
 > > work the same way.
 > 
 > You are right, there's no way to do that with !__STDC__.  I forgot
 > about that.  So it would not be desirable to do the STRINGIFY1 thing
 > on the __STDC__ case.
 > r~

	Okay.  I installed the patch and added a comment in system.h
saying that macro expansion of aruments passed to STRINGIFY is not
supported. 

		--Kaveh
--
Kaveh R. Ghazi			Project Manager / Custom Development
ghazi@caip.rutgers.edu		Icon CMT Corp.

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

end of thread, other threads:[~1998-05-12  9:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <199805022201.AAA00799@mira.isdn.cs.tu-berlin.de>
1998-05-06 23:49 ` Checking patch Jeffrey A Law
1998-05-07 11:23   ` Jim Wilson
1998-05-07 17:39   ` Martin von Loewis
1998-05-08  2:08     ` Andreas Schwab
1998-05-08  2:08     ` Jeffrey A Law
1998-05-08 12:13 Kaveh R. Ghazi
1998-05-08 12:13 ` Jeffrey A Law
1998-05-09  1:39 ` Richard Henderson
1998-05-10  6:17 Kaveh R. Ghazi
1998-05-11  9:07 ` Richard Henderson
1998-05-12  9:49 Kaveh R. Ghazi

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).