[RFA] Stop using tradcpp

Neil Booth neil@daikokuya.co.uk
Wed Jun 19 14:37:00 GMT 2002


This patch:

1) Fixes a silly bug my previous patch introduced to traditional funlike
   macros
2) Puts diagnostics in directives on the first line of the directive
3) Makes traditional numbers signed (unless explicit U suffix)
4) Adjusts gcc.c specs so that cc1 rather than tradcpp is used for
   traditional preprocessing.
5) Moves existing -traditional-cpp tests to a new directory cpp/trad,
   and updates some appropriately.  In particular, Kaveh had a test of
   stringification that went like:

  #define foo(a, b) c="a"; d="b";
  
  int main ()
  {
    char *c, *d;
  
    foo (p, q);
    if (c[0] != 'p' || d[0] != 'q')
      abort ();
  
    exit (0);
  }
  
  Note the invocation of foo has a leading space before 'q'; some
  traditional preprocessors would retain whitespace when replacing
  arguments; I continued this behaviour as it is stricter, and I feel
  more in the spirit of text-based preprocessing.  It causes the above
  test to fail, though, but that is easily fixed by removing the space.

  I've also copied the assertion tests for ISO CPP that were omitted
  for tradcpp.c (because it didn't do it right) that test that the answer
  to a predicate is not macro-expanded in #if.  We now get this right.

I've not yet removed tradcpp for 2 reasons: there's a small chance this
is disastrous and we want it back 8-), and it is being miscompiled for
some targets.  If everything is OK in a week or so, and the
compilation issue is fixed, I'll kill it.

There are several minor issues remaining with -traditional-cpp; I'll
address these over the period before 3.2.  I'll also add many tests.

Jason and Chris, you both were anxious that this get in for 3.2,
mainly for the continuation of built-in macro support.  I'd appreciate
it if you hit it with all test cases that you've got once it's
committed.  You're bound to find some issues initially.

Tested for C, ObjC, C++ and Fortran.  OK to commit?

Neil.

	* cppexp.c (cpp_interpret_integer): Don't force traditional
	numbers to be unsigned.
	* cpplib.c (prepare_directive_trad): Set line number for
	diagnostics.
	* cpptrad.c (scan_out_logical_line): Continue scanning out
	at start of buffer.
	* gcc.c (trad_capable_cpp): Use cc1 always.
f:
	* lang-specs.h: Use cc1 for traditional preprocessing.
testsuite:
	* gcc.dg/cpp/trad: New directory with traditional tests copied
	from parent directory.
	* gcc.dg/cpp/assert_trad1.c, gcc.dg/cpp/assert_trad2.c,
	gcc.dg/cpp/assert_trad3.c, gcc.dg/cpp/defined_trad.c,
	gcc.dg/cpp/hash2.c, gcc.dg/cpp/tr-define.c, gcc.dg/cpp/tr-direct.c,
	gcc.dg/cpp/tr-sign.c, gcc.dg/cpp/tr-str.c, gcc.dg/cpp/uchar-2.c:
	Move to trad/ and rename.

============================================================
Index: gcc/cppexp.c
*** gcc/cppexp.c	7 Jun 2002 13:29:17 -0000	1.123
--- gcc/cppexp.c	19 Jun 2002 21:15:44 -0000
*************** cpp_interpret_integer (pfile, token, typ
*** 375,384 ****
        if (overflow)
  	cpp_error (pfile, DL_PEDWARN,
  		   "integer constant is too large for its type");
!       else if (!result.unsignedp && !num_positive (result, precision))
  	{
- 	  /* If too big to be signed, consider it unsigned.  Only warn
- 	     for decimal numbers.  */
  	  if (base == 10)
  	    cpp_error (pfile, DL_WARNING,
  		       "integer constant is so large that it is unsigned");
--- 375,387 ----
        if (overflow)
  	cpp_error (pfile, DL_PEDWARN,
  		   "integer constant is too large for its type");
!       /* If too big to be signed, consider it unsigned.  Only warn for
! 	 decimal numbers.  Traditional numbers were always signed (but
! 	 we still honour an explicit U suffix).  */
!       else if (!result.unsignedp
! 	       && !CPP_OPTION (pfile, traditional)
! 	       && !num_positive (result, precision))
  	{
  	  if (base == 10)
  	    cpp_error (pfile, DL_WARNING,
  		       "integer constant is so large that it is unsigned");
============================================================
Index: gcc/cpplib.c
*** gcc/cpplib.c	18 Jun 2002 06:27:39 -0000	1.311
--- gcc/cpplib.c	19 Jun 2002 21:15:45 -0000
*************** prepare_directive_trad (pfile)
*** 303,308 ****
--- 303,310 ----
        pfile->state.skipping = was_skipping;
        _cpp_overlay_buffer (pfile, pfile->out.base,
  			   pfile->out.cur - pfile->out.base);
+       /* Report diagnostics on the line of the directive.  */
+       pfile->line = pfile->directive_line;
      }
  
    /* Stop ISO C from expanding anything.  */
============================================================
Index: gcc/cpptrad.c
*** gcc/cpptrad.c	19 Jun 2002 19:59:45 -0000	1.15
--- gcc/cpptrad.c	19 Jun 2002 21:15:45 -0000
*************** scan_out_logical_line (pfile, macro)
*** 602,609 ****
  		{
  		  /* Found a parameter in the replacement text of a
  		     #define.  Remove its name from the output.  */
! 		  out = pfile->out.cur = out_start;
  		  save_replacement_text (pfile, macro, node->arg_index);
  		}
  	      else if (lex_state == ls_hash)
  		{
--- 602,610 ----
  		{
  		  /* Found a parameter in the replacement text of a
  		     #define.  Remove its name from the output.  */
! 		  pfile->out.cur = out_start;
  		  save_replacement_text (pfile, macro, node->arg_index);
+ 		  out = pfile->out.base;
  		}
  	      else if (lex_state == ls_hash)
  		{
============================================================
Index: gcc/gcc.c
*** gcc/gcc.c	16 Jun 2002 04:21:17 -0000	1.324
--- gcc/gcc.c	19 Jun 2002 21:15:47 -0000
*************** static const char *startfile_prefix_spec
*** 675,682 ****
     call cc1 (or cc1obj in objc/lang-specs.h) from the main specs so
     that we default the front end language better.  */
  static const char *trad_capable_cpp =
! "%{traditional|ftraditional|traditional-cpp:tradcpp0}\
!  %{!traditional:%{!ftraditional:%{!traditional-cpp:cc1 -E}}}";
  
  static const char *cpp_unique_options =
  "%{C:%{!E:%eGNU C does not support -C without using -E}}\
--- 675,681 ----
     call cc1 (or cc1obj in objc/lang-specs.h) from the main specs so
     that we default the front end language better.  */
  static const char *trad_capable_cpp =
! "cc1 -E %{traditional|ftraditional|traditional-cpp:-traditional-cpp}";
  
  static const char *cpp_unique_options =
  "%{C:%{!E:%eGNU C does not support -C without using -E}}\
============================================================
Index: gcc/f/lang-specs.h
*** gcc/f/lang-specs.h	31 May 2002 21:01:26 -0000	1.32
--- gcc/f/lang-specs.h	19 Jun 2002 21:15:47 -0000
*************** the Free Software Foundation, 59 Temple 
*** 28,34 ****
    {".fpp", "@f77-cpp-input", 0},
    {".FPP", "@f77-cpp-input", 0},
    {"@f77-cpp-input",
!    "tradcpp0 -lang-fortran %(cpp_options) \
          %{E|M|MM:%(cpp_debug_options)}\
          %{!M:%{!MM:%{!E:%{!pipe:%g.f} |\n\
      f771 %{!pipe:%g.f} %(cc1_options) %{I*} %{!fsyntax-only:%(invoke_as)}}}}", 0},
--- 28,34 ----
    {".fpp", "@f77-cpp-input", 0},
    {".FPP", "@f77-cpp-input", 0},
    {"@f77-cpp-input",
!    "./cc1 -E -traditional-cpp -D_LANGUAGE_FORTRAN %(cpp_options) \
          %{E|M|MM:%(cpp_debug_options)}\
          %{!M:%{!MM:%{!E:%{!pipe:%g.f} |\n\
      f771 %{!pipe:%g.f} %(cc1_options) %{I*} %{!fsyntax-only:%(invoke_as)}}}}", 0},
============================================================
Index: gcc/testsuite/gcc.dg/cpp/assert_trad1.c
*** gcc/testsuite/gcc.dg/cpp/assert_trad1.c	18 Nov 2001 17:16:24 -0000	1.2
--- /dev/null	1 Jan 1970 00:00:00 -0000
***************
*** 1,46 ****
- /* Basic tests of the #assert preprocessor extension. */
- /* { dg-do compile } */
- /* { dg-options "-traditional-cpp" } */
- 
- /* #define def unused expansion */ /* tradcpp can't handle macros in answers.  */
- #define fail int failit
- 
- #assert abc (def)
- #assert abc (ghi)
- #assert abc (jkl)
- #assert space ( s p a c e )
- 
- /* Basic: */
- #if !#abc (def) || !#abc (ghi) || !#abc (jkl)
- fail
- #endif
- 
- /* any answer for #abc */
- #if !#abc
- fail
- #endif
- 
- /* internal whitespace is collapsed,
-    external whitespace is deleted  */
- #if !#space (s p  a  c e) || !#space (  s p a c e  ) || #space (space)
- fail
- #endif
- 
- /* removing assertions */
- #unassert abc (jkl)
- #if !#abc || !#abc (def) || !#abc (ghi) || #abc (jkl)
- fail
- #endif
- 
- #unassert abc
- #if #abc || #abc (def) || #abc (ghi) || #abc (jkl)
- fail
- #endif
- 
- int gobble
- 
- /* make sure it can succeed too.
-    also check space before open paren isn't significant */
- #if #space(s p a c e)
- ;
- #endif
--- 0 ----
============================================================
Index: gcc/testsuite/gcc.dg/cpp/assert_trad2.c
*** gcc/testsuite/gcc.dg/cpp/assert_trad2.c	4 Dec 2000 22:06:41 -0000	1.1
--- /dev/null	1 Jan 1970 00:00:00 -0000
***************
*** 1,24 ****
- /* Malformed assertion tests.  */
- /* { dg-do preprocess } */
- /* { dg-options "-traditional" } */
- 
- #assert		/* { dg-error "without predicate" "assert w/o predicate" } */
- #assert %	/* { dg-error "an identifier" "assert punctuation" } */
- #assert 12	/* { dg-error "an identifier" "assert number" } */
- #assert abc	/* { dg-error "missing" "assert w/o answer" } */
- 
- #if #		/* { dg-error "without predicate" "test w/o predicate" } */
- #endif
- 
- #if #%		/* { dg-error "an identifier" "test punctuation" } */
- #endif		/* { dg-error "parse error" "" { target *-*-* } 13 } */
- 
- #if #12		/* { dg-error "an identifier" "test number" } */
- #endif		/* { dg-error "parse error" "" { target *-*-* } 16 } */
- 
- #if #abc
- #error		/* { dg-bogus "error" "test w/o answer" } */
- #endif
- 
- #if #abc[def]	/* { dg-error "parse error" "bad syntax" } */
- #endif
--- 0 ----
============================================================
Index: gcc/testsuite/gcc.dg/cpp/assert_trad3.c
*** gcc/testsuite/gcc.dg/cpp/assert_trad3.c	4 Dec 2000 22:06:41 -0000	1.1
--- /dev/null	1 Jan 1970 00:00:00 -0000
***************
*** 1,10 ****
- /* Copyright (C) 2000 Free Software Foundation, Inc.  */
- 
- /* { dg-do preprocess } */
- /* { dg-options "-A abc=def -A abc\(ghi\) \"-Aabc = jkl\" -A abc=mno -A -abc=mno -traditional" } */
- 
- /* Test -A command line syntax.  Source Neil Booth.  31 Oct 2000.  */
- 
- #if !#abc (def) || !#abc (ghi) || !#abc (jkl) || #abc(mno)
- #error Command line -A assertions
- #endif
--- 0 ----
============================================================
Index: gcc/testsuite/gcc.dg/cpp/defined_trad.c
*** gcc/testsuite/gcc.dg/cpp/defined_trad.c	13 Dec 2000 19:47:04 -0000	1.3
--- /dev/null	1 Jan 1970 00:00:00 -0000
***************
*** 1,79 ****
- /* Copyright (C) 2000 Free Software Foundation, Inc.  */
- 
- /* { dg-do preprocess } */
- /* { dg-options "-traditional" } */
- 
- /* Tests tradcpp0 with defined.  The defined operator in traditional C
-    works just the same as the defined operator in Standard C.  */
- 
- /* Source: Zack Weinberg, glibc, Neil Booth 11 Dec 2000.  */
- 
- #if defined REGPARMS
- #error REGPARMS should not be defined
- #endif
- 
- #define REGPARMS 1
- #if !defined REGPARMS
- #error REGPARMS should be defined
- #endif
- 
- #define defined			/* { dg-error "defined" } */
- 
- /* No diagnostics, though you could argue there should be.  */
- #if defined defined
- #error defined is defined!
- #endif
- 
- #define is_Z_defined defined Z
- 
- #if defined Z
- #error Z is not defined
- #endif
- 
- /* The behaviour of "defined" when it comes from a macro expansion is
-    now documented.  */
- #if is_Z_defined
- #error Macro expanding into defined operator test 1
- #endif
- 
- #define Z
- 
- #if !defined Z
- #error Z is defined
- #endif
- 
- #if !is_Z_defined
- #error Macro expanding into defined operator test 2
- #endif
- 
- #undef is_Z_defined
- #undef Z
- 
- /* Do all the tests over again with the () form of defined.  */
- 
- /* No diagnostics, though you could argue there should be.  */
- #if defined(defined)
- #error defined is defined!
- #endif
- 
- #define is_Z_defined defined ( Z )
- 
- #if defined(Z)
- #error Z is not defined
- #endif
- 
- /* The behaviour of "defined" when it comes from a macro expansion is
-    now documented.  */
- #if is_Z_defined
- #error Macro expanding into defined operator test 1
- #endif
- 
- #define Z
- 
- #if !defined(Z)
- #error Z is defined
- #endif
- 
- #if !is_Z_defined
- #error Macro expanding into defined operator test 2
- #endif
--- 0 ----
============================================================
Index: gcc/testsuite/gcc.dg/cpp/hash2.c
*** gcc/testsuite/gcc.dg/cpp/hash2.c	27 Jun 2000 22:26:11 -0000	1.1
--- /dev/null	1 Jan 1970 00:00:00 -0000
***************
*** 1,15 ****
- /* Test for erroneously thinking comments are token-pastes.
-    From XFree86 4.0.  */
- /* { dg-do preprocess } */
- /* { dg-options "-traditional" } */
- 
- #ifndef foo
- #define foo	/**/
- #endif
- 
- #ifndef foo
- #define foo	/* as nothing */
- #endif
- 
- /* { dg-bogus "(start|end) of macro" "paste at end" { target *-*-* } 7 } */
- /* { dg-bogus "(start|end) of macro" "comment at end" { target *-*-* } 11 } */
--- 0 ----
============================================================
Index: gcc/testsuite/gcc.dg/cpp/tr-define.c
*** gcc/testsuite/gcc.dg/cpp/tr-define.c	2 May 2001 20:50:01 -0000	1.1
--- /dev/null	1 Jan 1970 00:00:00 -0000
***************
*** 1,2 ****
- /* { dg-do preprocess } */
- /* { dg-options "-traditional -DDEFINE1DEFINE -DDEFINE2DEFIN=" } */
--- 0 ----
============================================================
Index: gcc/testsuite/gcc.dg/cpp/tr-direct.c
*** gcc/testsuite/gcc.dg/cpp/tr-direct.c	13 Dec 2000 07:28:54 -0000	1.2
--- /dev/null	1 Jan 1970 00:00:00 -0000
***************
*** 1,11 ****
- /* Test for some basic aspects of -traditional directive processing.  */
- 
- /* { dg-do preprocess } */
- /* { dg-options -traditional } */
- 
- /* There is a #error directive.  */
- 
- #error bad	/* { dg-error "bad" } */
- 
- /* Directives with their #s indented are not recognized.  */
-  #if 0	/* { dg-bogus "unterminated" } */
--- 0 ----
============================================================
Index: gcc/testsuite/gcc.dg/cpp/tr-sign.c
*** gcc/testsuite/gcc.dg/cpp/tr-sign.c	5 Aug 2001 21:31:30 -0000	1.1
--- /dev/null	1 Jan 1970 00:00:00 -0000
***************
*** 1,18 ****
- /* Copyright (C) 2001 Free Software Foundation, Inc.  */
- 
- /* { dg-do preprocess { target i?86-*-* } } */
- 
- /* { dg-options "-traditional" } */
- 
- /* Tests that traditional numbers are signed, unless otherwise
-    specified.  This test assumes a 32 bit target.
- 
-    Neil Booth, 5 Aug 2001.  Inspired by PR 3824.  */
- 
- #if 0xffffffff >= 0
- # error	0xffffffff	/* { dg-bogus "0xffffffff" "0xffffffff positive" } */
- #endif
- 
- #if 0xffffffffU <= 0
- # error	0xffffffffU	/* { dg-bogus "0xffffffffU" "0xffffffffU negative" } */
- #endif
--- 0 ----
============================================================
Index: gcc/testsuite/gcc.dg/cpp/tr-str.c
*** gcc/testsuite/gcc.dg/cpp/tr-str.c	18 Nov 2001 17:16:24 -0000	1.3
--- /dev/null	1 Jan 1970 00:00:00 -0000
***************
*** 1,17 ****
- /* Test whether traditional stringify works.  */
- /* { dg-do run } */
- /* { dg-options "-traditional-cpp" } */
- #define foo(a, b) c="a"; d="b";
- 
- extern void abort ();
- 
- int main ()
- {
-   char *c, *d;
- 
-   foo (p, q);
-   if (c[0] != 'p' || d[0] != 'q')
-     abort ();
- 
-   exit (0);
- }
--- 0 ----
============================================================
Index: gcc/testsuite/gcc.dg/cpp/uchar-2.c
*** gcc/testsuite/gcc.dg/cpp/uchar-2.c	2 Feb 2002 18:56:37 -0000	1.1
--- /dev/null	1 Jan 1970 00:00:00 -0000
***************
*** 1,8 ****
- /* Copyright (C) 2002 Free Software Foundation, Inc.  */
- 
- /* { dg-do preprocess } */
- /* { dg-options "-funsigned-char -fsigned-char -traditional" } */
- 
- #if defined (__CHAR_UNSIGNED__)
- # error __CHAR_UNSIGNED__ defined
- #endif
--- 0 ----
============================================================
Index: gcc/testsuite/gcc.dg/cpp/trad/assert1.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/gcc.dg/cpp/trad/assert1.c	19 Jun 2002 21:15:47 -0000
***************
*** 0 ****
--- 1,46 ----
+ /* Basic tests of the #assert preprocessor extension. */
+ /* { dg-do compile } */
+ /* { dg-options "" } */
+ 
+ #define def unused expansion
+ #define fail  int fail
+ 
+ #assert abc (def)
+ #assert abc (ghi)
+ #assert abc (jkl)
+ #assert space ( s p a c e )
+ 
+ /* Basic: */
+ #if !#abc (def) || !#abc (ghi) || !#abc (jkl)
+ fail
+ #endif
+ 
+ /* any answer for #abc */
+ #if !#abc
+ fail
+ #endif
+ 
+ /* internal whitespace is collapsed,
+    external whitespace is deleted  */
+ #if !#space (s p  a  c e) || !#space (  s p a c e  ) || #space (space)
+ fail
+ #endif
+ 
+ /* removing assertions */
+ #unassert abc (jkl)
+ #if !#abc || !#abc (def) || !#abc (ghi) || #abc (jkl)
+ fail
+ #endif
+ 
+ #unassert abc
+ #if #abc || #abc (def) || #abc (ghi) || #abc (jkl)
+ fail
+ #endif
+ 
+ int gobble
+ 
+ /* make sure it can succeed too.
+    also check space before open paren isn't significant */
+ #if #space(s p a c e)
+ ;
+ #endif
============================================================
Index: gcc/testsuite/gcc.dg/cpp/trad/assert2.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/gcc.dg/cpp/trad/assert2.c	19 Jun 2002 21:15:47 -0000
***************
*** 0 ****
--- 1,23 ----
+ /* Malformed assertion tests.  */
+ /* { dg-do preprocess } */
+ 
+ #assert		/* { dg-error "without predicate" "assert w/o predicate" } */
+ #assert %	/* { dg-error "an identifier" "assert punctuation" } */
+ #assert 12	/* { dg-error "an identifier" "assert number" } */
+ #assert abc	/* { dg-error "missing" "assert w/o answer" } */
+ 
+ #if #		/* { dg-error "without predicate" "test w/o predicate" } */
+ #endif
+ 
+ #if #%		/* { dg-error "an identifier" "test punctuation" } */
+ #endif
+ 
+ #if #12		/* { dg-error "an identifier" "test number" } */
+ #endif
+ 
+ #if #abc
+ #error		/* { dg-bogus "error" "test w/o answer" } */
+ #endif
+ 
+ #if #abc[def]	/* { dg-error "not valid in" "bad syntax" } */
+ #endif
============================================================
Index: gcc/testsuite/gcc.dg/cpp/trad/assert3.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/gcc.dg/cpp/trad/assert3.c	19 Jun 2002 21:15:47 -0000
***************
*** 0 ****
--- 1,10 ----
+ /* Copyright (C) 2000 Free Software Foundation, Inc.  */
+ 
+ /* { dg-do preprocess } */
+ /* { dg-options "-A abc=def -A abc\(ghi\) \"-Aabc = jkl\" -A abc=mno -A -abc=mno" } */
+ 
+ /* Test -A command line syntax.  Source Neil Booth.  31 Oct 2000.  */
+ 
+ #if !#abc (def) || !#abc (ghi) || !#abc (jkl) || #abc(mno)
+ #error Command line -A assertions
+ #endif
============================================================
Index: gcc/testsuite/gcc.dg/cpp/trad/define.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/gcc.dg/cpp/trad/define.c	19 Jun 2002 21:15:47 -0000
***************
*** 0 ****
--- 1,2 ----
+ /* { dg-do preprocess } */
+ /* { dg-options "-traditional-cpp -DDEFINE1DEFINE -DDEFINE2DEFIN=" } */
============================================================
Index: gcc/testsuite/gcc.dg/cpp/trad/defined.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/gcc.dg/cpp/trad/defined.c	19 Jun 2002 21:15:47 -0000
***************
*** 0 ****
--- 1,78 ----
+ /* Copyright (C) 2000 Free Software Foundation, Inc.  */
+ 
+ /* { dg-do preprocess } */
+ 
+ /* Tests tradcpp0 with defined.  The defined operator in traditional C
+    works just the same as the defined operator in Standard C.  */
+ 
+ /* Source: Zack Weinberg, glibc, Neil Booth 11 Dec 2000.  */
+ 
+ #if defined REGPARMS
+ #error REGPARMS should not be defined
+ #endif
+ 
+ #define REGPARMS 1
+ #if !defined REGPARMS
+ #error REGPARMS should be defined
+ #endif
+ 
+ #define defined			/* { dg-error "defined" } */
+ 
+ /* No diagnostics, though you could argue there should be.  */
+ #if defined defined
+ #error defined is defined!
+ #endif
+ 
+ #define is_Z_defined defined Z
+ 
+ #if defined Z
+ #error Z is not defined
+ #endif
+ 
+ /* The behaviour of "defined" when it comes from a macro expansion is
+    now documented.  */
+ #if is_Z_defined
+ #error Macro expanding into defined operator test 1
+ #endif
+ 
+ #define Z
+ 
+ #if !defined Z
+ #error Z is defined
+ #endif
+ 
+ #if !is_Z_defined
+ #error Macro expanding into defined operator test 2
+ #endif
+ 
+ #undef is_Z_defined
+ #undef Z
+ 
+ /* Do all the tests over again with the () form of defined.  */
+ 
+ /* No diagnostics, though you could argue there should be.  */
+ #if defined(defined)
+ #error defined is defined!
+ #endif
+ 
+ #define is_Z_defined defined ( Z )
+ 
+ #if defined(Z)
+ #error Z is not defined
+ #endif
+ 
+ /* The behaviour of "defined" when it comes from a macro expansion is
+    now documented.  */
+ #if is_Z_defined
+ #error Macro expanding into defined operator test 1
+ #endif
+ 
+ #define Z
+ 
+ #if !defined(Z)
+ #error Z is defined
+ #endif
+ 
+ #if !is_Z_defined
+ #error Macro expanding into defined operator test 2
+ #endif
============================================================
Index: gcc/testsuite/gcc.dg/cpp/trad/directive.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/gcc.dg/cpp/trad/directive.c	19 Jun 2002 21:15:47 -0000
***************
*** 0 ****
--- 1,10 ----
+ /* Test for some basic aspects of -traditional directive processing.  */
+ 
+ /* { dg-do preprocess } */
+ 
+ /* There is a #error directive.  */
+ 
+ #error bad	/* { dg-error "bad" } */
+ 
+ /* Directives with their #s indented are not recognized.  */
+  #if 0	/* { dg-bogus "unterminated" } */
============================================================
Index: gcc/testsuite/gcc.dg/cpp/trad/hash.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/gcc.dg/cpp/trad/hash.c	19 Jun 2002 21:15:47 -0000
***************
*** 0 ****
--- 1,14 ----
+ /* Test for erroneously thinking comments are token-pastes.
+    From XFree86 4.0.  */
+ /* { dg-do preprocess } */
+ 
+ #ifndef foo
+ #define foo	/**/
+ #endif
+ 
+ #ifndef foo
+ #define foo	/* as nothing */
+ #endif
+ 
+ /* { dg-bogus "(start|end) of macro" "paste at end" { target *-*-* } 7 } */
+ /* { dg-bogus "(start|end) of macro" "comment at end" { target *-*-* } 11 } */
============================================================
Index: gcc/testsuite/gcc.dg/cpp/trad/num-sign.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/gcc.dg/cpp/trad/num-sign.c	19 Jun 2002 21:15:47 -0000
***************
*** 0 ****
--- 1,16 ----
+ /* Copyright (C) 2001 Free Software Foundation, Inc.  */
+ 
+ /* { dg-do preprocess { target i?86-*-* } } */
+ 
+ /* Tests that traditional numbers are signed, unless otherwise
+    specified.  This test assumes a 32 bit target.
+ 
+    Neil Booth, 5 Aug 2001.  Inspired by PR 3824.  */
+ 
+ #if 0xffffffffffffffff >= 0
+ # error	0xffffffffffffffff /* { dg-bogus "0xffffffffffffffff" "0xffffffffffffffff positive" } */
+ #endif
+ 
+ #if 0xffffffffffffffffU <= 0
+ # error	0xffffffffffffffffU	/* { dg-bogus "0xffffffffffffffffU" "0xffffffffffffffffU negative" } */
+ #endif
============================================================
Index: gcc/testsuite/gcc.dg/cpp/trad/paste.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/gcc.dg/cpp/trad/paste.c	19 Jun 2002 21:15:47 -0000
***************
*** 0 ****
--- 1,16 ----
+ /* Test for proper comment elimination semantics from cpplib's -traditional.
+    This should compile and link with compiled with `gcc -traditional-cpp'.
+    Test case by Jason R. Thorpe <thorpej@zembu.com>.  */
+ 
+ /* { dg-do compile } */
+ 
+ #define A(name) X/**/name
+ 
+ #define B(name) \
+ void A(Y/**/name)() { A(name)(); }
+ 
+ void Xhello() { printf("hello world\n"); }
+ 
+ B(hello)
+ 
+ int main() { XYhello(); return (0); }
============================================================
Index: gcc/testsuite/gcc.dg/cpp/trad/strify.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/gcc.dg/cpp/trad/strify.c	19 Jun 2002 21:15:47 -0000
***************
*** 0 ****
--- 1,17 ----
+ /* Test whether traditional stringify works.  */
+ /* { dg-do run } */
+ 
+ #define foo(a, b) c="a"; d="b";
+ 
+ extern void abort ();
+ 
+ int main ()
+ {
+   char *c, *d;
+ 
+   foo (p,q);
+   if (c[0] != 'p' || d[0] != 'q')
+     abort ();
+ 
+   exit (0);
+ }
============================================================
Index: gcc/testsuite/gcc.dg/cpp/trad/trad.exp
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/gcc.dg/cpp/trad/trad.exp	19 Jun 2002 21:15:47 -0000
***************
*** 0 ****
--- 1,43 ----
+ #   Copyright (C) 1997, 2000 Free Software Foundation, Inc.
+ 
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; either version 2 of the License, or
+ # (at your option) any later version.
+ # 
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ # GNU General Public License for more details.
+ # 
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+ 
+ # GCC testsuite that uses the `dg.exp' driver.
+ 
+ # There's a bunch of headers we need.
+ if [is_remote host] {
+     foreach header [glob -nocomplain $srcdir/$subdir/*.{h,def} ] {
+ 	remote_download host $header
+     }
+ }
+ 
+ # Load support procs.
+ load_lib gcc-dg.exp
+ 
+ # If a testcase doesn't have special options, use these.
+ global DEFAULT_CFLAGS
+ if ![info exists DEFAULT_CFLAGS] then {
+     set DEFAULT_CFLAGS " -traditional-cpp"
+ }
+ 
+ # Initialize `dg'.
+ dg-init
+ 
+ # Main loop.
+ dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
+ 	"" $DEFAULT_CFLAGS
+ 
+ # All done.
+ dg-finish
============================================================
Index: gcc/testsuite/gcc.dg/cpp/trad/uchar.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/gcc.dg/cpp/trad/uchar.c	19 Jun 2002 21:15:47 -0000
***************
*** 0 ****
--- 1,8 ----
+ /* Copyright (C) 2002 Free Software Foundation, Inc.  */
+ 
+ /* { dg-do preprocess } */
+ /* { dg-options "-funsigned-char -fsigned-char -traditional-cpp" } */
+ 
+ #if defined (__CHAR_UNSIGNED__)
+ # error __CHAR_UNSIGNED__ defined
+ #endif



More information about the Gcc-patches mailing list