]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/24101 (Segfault with preprocessed source)
authorUros Bizjak <uros@gcc.gnu.org>
Wed, 9 Nov 2005 07:51:51 +0000 (08:51 +0100)
committerUros Bizjak <uros@gcc.gnu.org>
Wed, 9 Nov 2005 07:51:51 +0000 (08:51 +0100)
gcc/

PR c/24101
* toplev.c (process_options): Initialize debug_hooks early
in case lang_hooks.post_options ends up calling a debug_hook.
        * cppinit.c (read_original_filename): Temporarily set
        state.in_directive before calling _cpp_lex_direct for
        CPP_HASH tokens.

gcc/testsuite/

PR c/24101
* gcc.dg/pr24101-1.i, gcc.dg/pr24101-2.i: New tests.
* gcc.dg/dg.exp: Run main loop also for *.i files.

From-SVN: r106679

gcc/ChangeLog
gcc/cppinit.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/dg.exp
gcc/testsuite/gcc.dg/pr24101-1.i [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr24101-2.i [new file with mode: 0644]
gcc/toplev.c

index c8e7587fd2cbe3c6b1509d4bee4bf8e7cb1cdc78..9576fbd272fae4ab42c6eb90e9f4982e7ef2aea5 100644 (file)
@@ -1,3 +1,13 @@
+2005-11-09  Per Bothner  <per@bothner.com>
+           Uros Bizjak  <uros@kss-loka.si>
+       
+       PR c/24101
+       * toplev.c (process_options): Initialize debug_hooks early
+       in case lang_hooks.post_options ends up calling a debug_hook.
+       * cppinit.c (read_original_filename): Temporarily set
+       state.in_directive before calling _cpp_lex_direct for
+       CPP_HASH tokens.
+
 2005-11-07  Steve Ellcey  <sje@cup.hp.com>
 
        PR bootstrap/24688
index 8da0857dc7d06e8ec492473fd3eabd1b4f7a2db2..647fbbf5f52cc7700fd91248931bef65abd91165 100644 (file)
@@ -498,8 +498,10 @@ read_original_filename (cpp_reader *pfile)
   token = _cpp_lex_direct (pfile);
   if (token->type == CPP_HASH)
     {
+      pfile->state.in_directive = 1;
       token1 = _cpp_lex_direct (pfile);
       _cpp_backup_tokens (pfile, 1);
+      pfile->state.in_directive = 0;
 
       /* If it's a #line directive, handle it.  */
       if (token1->type == CPP_NUMBER)
index 28b9395508256d6a9f94543c291927ad85523057..54ca96de343b17811b437b75ff5ca239db2070fe 100644 (file)
@@ -1,3 +1,9 @@
+2005-11-09  Uros Bizjak  <uros@kss-loka.si>
+
+       PR c/24101
+       * gcc.dg/pr24101-1.i, gcc.dg/pr24101-2.i: New tests.
+       * gcc.dg/dg.exp: Run main loop also for *.i files.
+
 2005-11-02  Josh Conner  <jconner@apple.com>
 
        * g++.dg/crash38.C: moved into proper directory...
index 14cf79d7e142b11349b7c9b13f9a440cdaab6f30..083345244dbeb1a3e36719ecf65e1f7189a96f7a 100644 (file)
@@ -29,7 +29,7 @@ if ![info exists DEFAULT_CFLAGS] then {
 dg-init
 
 # Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cSi\]]] \
        "" $DEFAULT_CFLAGS
 
 # All done.
diff --git a/gcc/testsuite/gcc.dg/pr24101-1.i b/gcc/testsuite/gcc.dg/pr24101-1.i
new file mode 100644 (file)
index 0000000..45c1655
--- /dev/null
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-ansi" } */
+
+# 1 "/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.0/include/stddef.h" 1 3 4
diff --git a/gcc/testsuite/gcc.dg/pr24101-2.i b/gcc/testsuite/gcc.dg/pr24101-2.i
new file mode 100644 (file)
index 0000000..501382d
--- /dev/null
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-ansi" } */
+
+#
index 3c9dbcb06606f072d463a655fadfed7709760680..4e10fd6c7303acb6c3079af8164ea02706d1d9ed 100644 (file)
@@ -4271,6 +4271,10 @@ general_init (const char *argv0)
 static void
 process_options (void)
 {
+  /* Just in case lang_hooks.post_options ends up calling a debug_hook.
+     This can happen with incorrect pre-processed input. */
+  debug_hooks = &do_nothing_debug_hooks;
+
   /* Allow the front end to perform consistency checks and do further
      initialization based on the command line options.  This hook also
      sets the original filename if appropriate (e.g. foo.i -> foo.c)
@@ -4400,7 +4404,7 @@ process_options (void)
   /* Now we know write_symbols, set up the debug hooks based on it.
      By default we do nothing for debug output.  */
   if (write_symbols == NO_DEBUG)
-    debug_hooks = &do_nothing_debug_hooks;
+    ;
 #if defined(DBX_DEBUGGING_INFO)
   else if (write_symbols == DBX_DEBUG)
     debug_hooks = &dbx_debug_hooks;