cppexp.c (cpp_interpret_integer): Don't force traditional numbers to be unsigned.
authorNeil Booth <neil@daikokuya.co.uk>
Thu, 20 Jun 2002 20:34:19 +0000 (20:34 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Thu, 20 Jun 2002 20:34:19 +0000 (20:34 +0000)
* 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/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:
Remove.

From-SVN: r54856

18 files changed:
gcc/ChangeLog
gcc/cppexp.c
gcc/cpplib.c
gcc/cpptrad.c
gcc/f/ChangeLog
gcc/f/lang-specs.h
gcc/gcc.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/assert_trad1.c [deleted file]
gcc/testsuite/gcc.dg/cpp/assert_trad2.c [deleted file]
gcc/testsuite/gcc.dg/cpp/assert_trad3.c [deleted file]
gcc/testsuite/gcc.dg/cpp/defined_trad.c [deleted file]
gcc/testsuite/gcc.dg/cpp/hash2.c [deleted file]
gcc/testsuite/gcc.dg/cpp/tr-define.c [deleted file]
gcc/testsuite/gcc.dg/cpp/tr-direct.c [deleted file]
gcc/testsuite/gcc.dg/cpp/tr-sign.c [deleted file]
gcc/testsuite/gcc.dg/cpp/tr-str.c [deleted file]
gcc/testsuite/gcc.dg/cpp/uchar-2.c [deleted file]

index 48ac7822f973eb30c6350498e0698b3fc9efb661..f7b0f3261b57e60cbf5f19f9b17a51e61181e96c 100644 (file)
@@ -1,3 +1,13 @@
+2002-06-20  Neil Booth  <neil@daikokuya.co.uk>
+
+       * 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.
+
 2002-06-20  Jeffrey Law  <law@redhat.com>
 
        * i386.h (TARGET_DEFAULT): Do not turn on frame pointer
index 4fc833c23e4e4d3e690a126e090e6728fedaaa96..b3a7ce60966f2501c4ea6130f6ca42417e979ae9 100644 (file)
@@ -375,10 +375,13 @@ cpp_interpret_integer (pfile, token, type)
       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.  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 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");
index 4ee97e81a05ea502759d968882f116f5a5ea85d1..d3c95e75c864fdc3e87f30f2051764c161b08608 100644 (file)
@@ -303,6 +303,8 @@ prepare_directive_trad (pfile)
       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 82eeee52026c06dd7a815a58850bbd7a856e8dce..74976dbe2310ecf70eeb17f33b43d9a148821b0e 100644 (file)
@@ -38,7 +38,7 @@ struct block
 };
 
 #define BLOCK_HEADER_LEN offsetof (struct block, text)
-#define BLOCK_LEN(TEXT_LEN) CPP_ALIGN (BLOCK_HEADER_LEN + TEXT_LEN)
+#define BLOCK_LEN(TEXT_LEN) CPP_ALIGN (BLOCK_HEADER_LEN + (TEXT_LEN))
 
 /* Structure holding information about a function-like macro
    invocation.  */
@@ -602,8 +602,9 @@ scan_out_logical_line (pfile, macro)
                {
                  /* Found a parameter in the replacement text of a
                     #define.  Remove its name from the output.  */
-                 out = pfile->out.cur = out_start;
+                 pfile->out.cur = out_start;
                  save_replacement_text (pfile, macro, node->arg_index);
+                 out = pfile->out.base;
                }
              else if (lex_state == ls_hash)
                {
index 581fbe1e67848888007303442a1d9b23404377f8..fa3128ca8735ea7356cd96f76154bc63ad1960a4 100644 (file)
@@ -1,3 +1,7 @@
+Thu Jun 20 21:56:34 2002  Neil Booth  <neil@daikokuya.co.uk>
+
+       * lang-specs.h: Use cc1 for traditional preprocessing.
+
 2002-06-20  Andreas Jaeger  <aj@suse.de>
 
        * com.c (ffecom_prepare_expr_,ffecom_expr_power_integer_):
index c22837a7b938d87a28ced1f7136013d7944b2348..5536f78cab060588cd8b8c147b2398e8484a8bcd 100644 (file)
@@ -28,7 +28,7 @@ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
   {".fpp", "@f77-cpp-input", 0},
   {".FPP", "@f77-cpp-input", 0},
   {"@f77-cpp-input",
-   "tradcpp0 -lang-fortran %(cpp_options) \
+   "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 292b061ef364469bf0cb3f73cce77b868224b318..fc0f3592c9798ee33e09b5e6219b9a05cd822644 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -675,8 +675,7 @@ static const char *startfile_prefix_spec = STARTFILE_PREFIX_SPEC;
    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}}}";
+"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 653cab34af708ee0c092a2775812975495f6f2ff..498e67171a509b8c4a119b2c4633d3f703d8626f 100644 (file)
@@ -1,3 +1,11 @@
+2002-06-20  Neil Booth  <neil@daikokuya.co.uk>
+
+       * 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:
+       Remove.
+
 2002-06-20  Richard Sandiford  <rsandifo@redhat.com>
 
        * gcc.dg/20020620-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/cpp/assert_trad1.c b/gcc/testsuite/gcc.dg/cpp/assert_trad1.c
deleted file mode 100644 (file)
index 6d3c04e..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/* 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
diff --git a/gcc/testsuite/gcc.dg/cpp/assert_trad2.c b/gcc/testsuite/gcc.dg/cpp/assert_trad2.c
deleted file mode 100644 (file)
index 2f6963e..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/* 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
diff --git a/gcc/testsuite/gcc.dg/cpp/assert_trad3.c b/gcc/testsuite/gcc.dg/cpp/assert_trad3.c
deleted file mode 100644 (file)
index 641ba5c..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/* 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
diff --git a/gcc/testsuite/gcc.dg/cpp/defined_trad.c b/gcc/testsuite/gcc.dg/cpp/defined_trad.c
deleted file mode 100644 (file)
index 666fd71..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/* 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
diff --git a/gcc/testsuite/gcc.dg/cpp/hash2.c b/gcc/testsuite/gcc.dg/cpp/hash2.c
deleted file mode 100644 (file)
index 4e177f4..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/* 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 } */
diff --git a/gcc/testsuite/gcc.dg/cpp/tr-define.c b/gcc/testsuite/gcc.dg/cpp/tr-define.c
deleted file mode 100644 (file)
index 54bd7a7..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/* { dg-do preprocess } */
-/* { dg-options "-traditional -DDEFINE1DEFINE -DDEFINE2DEFIN=" } */
diff --git a/gcc/testsuite/gcc.dg/cpp/tr-direct.c b/gcc/testsuite/gcc.dg/cpp/tr-direct.c
deleted file mode 100644 (file)
index 56a52ba..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/* 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" } */
diff --git a/gcc/testsuite/gcc.dg/cpp/tr-sign.c b/gcc/testsuite/gcc.dg/cpp/tr-sign.c
deleted file mode 100644 (file)
index e48e8cc..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/* 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
diff --git a/gcc/testsuite/gcc.dg/cpp/tr-str.c b/gcc/testsuite/gcc.dg/cpp/tr-str.c
deleted file mode 100644 (file)
index 3423473..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/* 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);
-}
diff --git a/gcc/testsuite/gcc.dg/cpp/uchar-2.c b/gcc/testsuite/gcc.dg/cpp/uchar-2.c
deleted file mode 100644 (file)
index 739573c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-/* 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