This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[RFA:] Fix gcc.dg/noncompile/incomplete-1.c (gcc/toplev.c)
- From: Hans-Peter Nilsson <hp at bitrange dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 27 Oct 2002 11:14:40 -0500 (EST)
- Subject: [RFA:] Fix gcc.dg/noncompile/incomplete-1.c (gcc/toplev.c)
Here's a patch to fix (for most if not all targets :-)
FAIL: gcc.dg/noncompile/incomplete-1.c (test for excess errors)
Excess errors:
x/gcc/testsuite/gcc.dg/noncompile/incomplete-1.c:4: internal compiler error: Segmentation fault
I could have e.g. plugged dwarf2out.c:field_byte_offset, where
there is already similar error handling, by returning zero early
if the type is error_mark_node (backtrace in gdb from the SEGV
to see). At the same time, I thought it odd that dwarf2out.c
should actually have to look for error_mark_node; better to not
call it if there were errors, since it does not seem necessary
in order to see more errors in the compiled program. The checks
are similar to one in rest_of_compilation.
Bootstrapped and checked i686-pc-linux-gnu, checked on
mmix-knuth-mmixware and cris-axis-elf, fixing the error above,
no regressions.
Ok to commit?
* toplev.c (rest_of_type_compilation): Return early in case of
errors.
(check_global_declarations): Don't call debug_hooks->global_decl
in case of errors.
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.683
diff -p -c -r1.683 toplev.c
*** toplev.c 20 Oct 2002 19:18:29 -0000 1.683
--- toplev.c 27 Oct 2002 07:22:41 -0000
*************** check_global_declarations (vec, len)
*** 2048,2056 ****
&& (*lang_hooks.decls.warn_unused_global) (decl))
warning_with_decl (decl, "`%s' defined but not used");
! timevar_push (TV_SYMOUT);
! (*debug_hooks->global_decl) (decl);
! timevar_pop (TV_SYMOUT);
}
}
--- 2048,2061 ----
&& (*lang_hooks.decls.warn_unused_global) (decl))
warning_with_decl (decl, "`%s' defined but not used");
! /* Avoid confusing the debug information machinery when there are
! errors. */
! if (errorcount == 0 && sorrycount == 0)
! {
! timevar_push (TV_SYMOUT);
! (*debug_hooks->global_decl) (decl);
! timevar_pop (TV_SYMOUT);
! }
}
}
*************** rest_of_type_compilation (type, toplev)
*** 2328,2333 ****
--- 2333,2343 ----
int toplev ATTRIBUTE_UNUSED;
#endif
{
+ /* Avoid confusing the debug information machinery when there are
+ errors. */
+ if (errorcount != 0 || sorrycount != 0)
+ return;
+
timevar_push (TV_SYMOUT);
#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
brgds, H-P