summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-05-28 22:48:36 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-05-28 22:48:36 +0000
commit460b8bb3856c1d8edc561ab4ed8b1ee11712ad6d (patch)
treee9cbdec79403c99a1cb3ef44833dcf33827d46a9
parent732f3fd856cc1c94fc0f28b75f08d7b5fadc27dc (diff)
downloadgcc-460b8bb3856c1d8edc561ab4ed8b1ee11712ad6d.tar.gz
* gcc.c: Include diagnostic.h.
(error_count): Remove. All users changed to use errorcount. (programname): Remove. All users changed to use progname. (fancy_abort, internal_error, fatal_error, error, warning, inform, fnotice): Remove. (execute): Don't include "Internal error" and bug reporting information in argument of internal_error call. (process_command): Don't increment error_count after calling perror_with_name. (input_filename): Rename to gcc_input_filename. All users changed. (main): Call diagnostic_initialize. Register delete_temp_files with atexit. Use seen_error to test for errors. * gcc.h: Include diagnostic-core.h. (fatal_error, error, warning): Remove. * Makefile.in (GCC_H): Add $(DIAGNOSTIC_CORE_H). (GCC_OBJS): Add diagnostic.o, pretty-print.o and input.o. (gcc.o): Update dependencies. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160004 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog21
-rw-r--r--gcc/Makefile.in7
-rw-r--r--gcc/gcc.c200
-rw-r--r--gcc/gcc.h5
4 files changed, 72 insertions, 161 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7bf25681d61..3ef5ef04dc1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,24 @@
+2010-05-28 Joseph Myers <joseph@codesourcery.com>
+
+ * gcc.c: Include diagnostic.h.
+ (error_count): Remove. All users changed to use errorcount.
+ (programname): Remove. All users changed to use progname.
+ (fancy_abort, internal_error, fatal_error, error, warning, inform,
+ fnotice): Remove.
+ (execute): Don't include "Internal error" and bug reporting
+ information in argument of internal_error call.
+ (process_command): Don't increment error_count after calling
+ perror_with_name.
+ (input_filename): Rename to gcc_input_filename. All users
+ changed.
+ (main): Call diagnostic_initialize. Register delete_temp_files
+ with atexit. Use seen_error to test for errors.
+ * gcc.h: Include diagnostic-core.h.
+ (fatal_error, error, warning): Remove.
+ * Makefile.in (GCC_H): Add $(DIAGNOSTIC_CORE_H).
+ (GCC_OBJS): Add diagnostic.o, pretty-print.o and input.o.
+ (gcc.o): Update dependencies.
+
2010-05-28 Jeff Law <law@redhat.com>
* ira.c (ira_bad_reload_regno, ira_build_reload_regno_1): New
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 20939572287..1fe89bf337b 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -911,7 +911,7 @@ DF_H = df.h $(BITMAP_H) $(REGSET_H) sbitmap.h $(BASIC_BLOCK_H) \
alloc-pool.h $(TIMEVAR_H)
RESOURCE_H = resource.h hard-reg-set.h $(DF_H)
DDG_H = ddg.h sbitmap.h $(DF_H)
-GCC_H = gcc.h version.h
+GCC_H = gcc.h version.h $(DIAGNOSTIC_CORE_H)
GGC_H = ggc.h gtype-desc.h statistics.h
TIMEVAR_H = timevar.h timevar.def
INSN_ATTR_H = insn-attr.h $(INSN_ADDR_H)
@@ -1124,7 +1124,8 @@ CXX_TARGET_OBJS=@cxx_target_objs@
FORTRAN_TARGET_OBJS=@fortran_target_objs@
# Object files for gcc driver.
-GCC_OBJS = gcc.o opts-common.o gcc-options.o
+GCC_OBJS = gcc.o opts-common.o gcc-options.o diagnostic.o pretty-print.o \
+ input.o
# Language-specific object files for C and Objective C.
C_AND_OBJC_OBJS = attribs.o c-errors.o c-lex.o c-pragma.o c-decl.o c-typeck.o \
@@ -2130,7 +2131,7 @@ DRIVER_DEFINES = \
gcc.o: gcc.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) intl.h multilib.h \
Makefile $(lang_specs_files) specs.h prefix.h $(GCC_H) $(FLAGS_H) \
- configargs.h $(OBSTACK_H) opts.h
+ configargs.h $(OBSTACK_H) opts.h $(DIAGNOSTIC_H)
(SHLIB_LINK='$(SHLIB_LINK)'; \
$(COMPILER) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
$(DRIVER_DEFINES) \
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 54da6675bed..ffb69ce598a 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -82,6 +82,7 @@ compilation is specified by a string called a "spec". */
#include "intl.h"
#include "prefix.h"
#include "gcc.h"
+#include "diagnostic.h"
#include "flags.h"
#include "opts.h"
@@ -296,10 +297,6 @@ static const struct modify_target
modify_target[] = MODIFY_TARGET_NAME;
#endif
-/* The number of errors that have occurred; the link phase will not be
- run if this is nonzero. */
-static int error_count = 0;
-
/* Greatest exit code of sub-processes that has been encountered up to
now. */
static int greatest_status = 1;
@@ -377,11 +374,7 @@ static int used_arg (const char *, int);
static int default_arg (const char *, int);
static void set_multilib_dir (void);
static void print_multilib_info (void);
-static void inform (int, const char *, ...) ATTRIBUTE_PRINTF_2;
static void perror_with_name (const char *);
-static void internal_error (const char *, ...)
- ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
-static void fnotice (FILE *, const char *, ...) ATTRIBUTE_PRINTF_2;
static void display_help (void);
static void add_preprocessor_option (const char *, int);
static void add_assembler_option (const char *, int);
@@ -2037,10 +2030,6 @@ static int execution_count;
/* Number of commands that exited with a signal. */
static int signal_count;
-
-/* Name with which this program was invoked. */
-
-static const char *programname;
/* Allocate the argument vector. */
@@ -3105,7 +3094,7 @@ execute (void)
pex = pex_init (PEX_USE_PIPES | ((report_times || report_times_to_file)
? PEX_RECORD_TIMES : 0),
- programname, temp_filename);
+ progname, temp_filename);
if (pex == NULL)
pfatal_with_name (_("pex_init failed"));
@@ -3178,12 +3167,8 @@ execute (void)
}
else
#endif
- internal_error ("\
-Internal error: %s (program %s)\n\
-Please submit a full bug report.\n\
-See %s for instructions.",
- strsignal (WTERMSIG (status)), commands[i].prog,
- bug_report_url);
+ internal_error ("%s (program %s)",
+ strsignal (WTERMSIG (status)), commands[i].prog);
}
else if (WIFEXITED (status)
&& WEXITSTATUS (status) >= MIN_FATAL_STATUS)
@@ -3401,7 +3386,7 @@ convert_filename (const char *name, int do_exe ATTRIBUTE_UNUSED,
static void
display_help (void)
{
- printf (_("Usage: %s [options] file...\n"), programname);
+ printf (_("Usage: %s [options] file...\n"), progname);
fputs (_("Options:\n"), stdout);
fputs (_(" -pass-exit-codes Exit with highest error code from a phase\n"), stdout);
@@ -3463,7 +3448,7 @@ display_help (void)
\nOptions starting with -g, -f, -m, -O, -W, or --param are automatically\n\
passed on to the various sub-processes invoked by %s. In order to pass\n\
other options on to these processes the -W<letter> options must be used.\n\
-"), programname);
+"), progname);
/* The rest of the options are displayed by invocations of the various
sub-processes. */
@@ -4547,10 +4532,7 @@ process_command (int argc, const char **argv)
fname = xstrdup (argv[i]);
if (strcmp (fname, "-") != 0 && access (fname, F_OK) < 0)
- {
- perror_with_name (fname);
- error_count++;
- }
+ perror_with_name (fname);
else
{
infiles[n_infiles].language = spec_lang;
@@ -4658,7 +4640,7 @@ set_collect_gcc_options (void)
sans all directory names, and basename_length is the number
of characters starting there excluding the suffix .c or whatever. */
-static const char *input_filename;
+static const char *gcc_input_filename;
static int input_file_number;
size_t input_filename_length;
static int basename_length;
@@ -5333,7 +5315,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
break;
}
- /* If the input_filename has the same suffix specified
+ /* If the gcc_input_filename has the same suffix specified
for the %g, %u, or %U, and -save-temps is specified,
we could end up using that file as an intermediate
thus clobbering the user's source file (.e.g.,
@@ -5351,7 +5333,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
tmp[basename_length + suffix_length] = '\0';
temp_filename = tmp;
- if (strcmp (temp_filename, input_filename) != 0)
+ if (strcmp (temp_filename, gcc_input_filename) != 0)
{
#ifndef HOST_LACKS_INODE_NUMBERS
struct stat st_temp;
@@ -5359,12 +5341,13 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
/* Note, set_input() resets input_stat_set to 0. */
if (input_stat_set == 0)
{
- input_stat_set = stat (input_filename, &input_stat);
+ input_stat_set = stat (gcc_input_filename,
+ &input_stat);
if (input_stat_set >= 0)
input_stat_set = 1;
}
- /* If we have the stat for the input_filename
+ /* If we have the stat for the gcc_input_filename
and we can do the stat for the temp_filename
then the they could still refer to the same
file if st_dev/st_ino's are the same. */
@@ -5374,7 +5357,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
|| input_stat.st_ino != st_temp.st_ino)
#else
/* Just compare canonical pathnames. */
- char* input_realname = lrealpath (input_filename);
+ char* input_realname = lrealpath (gcc_input_filename);
char* temp_realname = lrealpath (temp_filename);
bool files_differ = strcmp (input_realname, temp_realname);
free (input_realname);
@@ -5476,7 +5459,8 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
}
else
{
- obstack_grow (&obstack, input_filename, input_filename_length);
+ obstack_grow (&obstack, gcc_input_filename,
+ input_filename_length);
arg_going = 1;
}
break;
@@ -6582,9 +6566,9 @@ set_input (const char *filename)
{
const char *p;
- input_filename = filename;
- input_filename_length = strlen (input_filename);
- input_basename = lbasename (input_filename);
+ gcc_input_filename = filename;
+ input_filename_length = strlen (gcc_input_filename);
+ input_basename = lbasename (gcc_input_filename);
/* Find a suffix starting with the last period,
and set basename_length to exclude that suffix. */
@@ -6602,7 +6586,7 @@ set_input (const char *filename)
input_suffix = "";
/* If a spec for 'g', 'u', or 'U' is seen with -save-temps then
- we will need to do a stat on the input_filename. The
+ we will need to do a stat on the gcc_input_filename. The
INPUT_STAT_SET signals that the stat is needed. */
input_stat_set = 0;
}
@@ -6643,7 +6627,7 @@ compare_files (char *cmpfile[])
if (stat (cmpfile[i], &st) < 0 || !S_ISREG (st.st_mode))
{
error ("%s: could not determine length of compare-debug file %s",
- input_filename, cmpfile[i]);
+ gcc_input_filename, cmpfile[i]);
ret = 1;
break;
}
@@ -6653,7 +6637,7 @@ compare_files (char *cmpfile[])
if (!ret && length[0] != length[1])
{
- error ("%s: -fcompare-debug failure (length)", input_filename);
+ error ("%s: -fcompare-debug failure (length)", gcc_input_filename);
ret = 1;
}
@@ -6664,7 +6648,7 @@ compare_files (char *cmpfile[])
if (fd < 0)
{
error ("%s: could not open compare-debug file %s",
- input_filename, cmpfile[i]);
+ gcc_input_filename, cmpfile[i]);
ret = 1;
break;
}
@@ -6683,7 +6667,7 @@ compare_files (char *cmpfile[])
{
if (memcmp (map[0], map[1], length[0]) != 0)
{
- error ("%s: -fcompare-debug failure", input_filename);
+ error ("%s: -fcompare-debug failure", gcc_input_filename);
ret = 1;
}
}
@@ -6705,7 +6689,7 @@ compare_files (char *cmpfile[])
if (!temp[i])
{
error ("%s: could not open compare-debug file %s",
- input_filename, cmpfile[i]);
+ gcc_input_filename, cmpfile[i]);
ret = 1;
break;
}
@@ -6721,7 +6705,7 @@ compare_files (char *cmpfile[])
if (c0 != c1)
{
error ("%s: -fcompare-debug failure",
- input_filename);
+ gcc_input_filename);
ret = 1;
break;
}
@@ -6762,9 +6746,9 @@ main (int argc, char **argv)
p = argv[0] + strlen (argv[0]);
while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
--p;
- programname = p;
+ progname = p;
- xmalloc_set_program_name (programname);
+ xmalloc_set_program_name (progname);
expandargv (&argc, &argv);
@@ -6784,6 +6768,10 @@ main (int argc, char **argv)
gcc_init_libintl ();
+ diagnostic_initialize (global_dc, 0);
+ if (atexit (delete_temp_files) != 0)
+ fatal_error ("atexit failed");
+
if (signal (SIGINT, SIG_IGN) != SIG_IGN)
signal (SIGINT, fatal_signal);
#ifdef SIGHUP
@@ -7063,7 +7051,7 @@ main (int argc, char **argv)
set_multilib_dir ();
/* Set up to remember the pathname of gcc and any options
- needed for collect. We use argv[0] instead of programname because
+ needed for collect. We use argv[0] instead of progname because
we need the complete pathname. */
obstack_init (&collect_obstack);
obstack_grow (&collect_obstack, "COLLECT_GCC=", sizeof ("COLLECT_GCC=") - 1);
@@ -7189,7 +7177,7 @@ main (int argc, char **argv)
if (print_version)
{
- printf (_("%s %s%s\n"), programname, pkgversion_string,
+ printf (_("%s %s%s\n"), progname, pkgversion_string,
version_string);
printf ("Copyright %s 2010 Free Software Foundation, Inc.\n",
_("(C)"));
@@ -7322,7 +7310,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
if (input_file_compiler->spec[0] == '#')
{
error ("%s: %s compiler not installed on this system",
- input_filename, &input_file_compiler->spec[1]);
+ gcc_input_filename, &input_file_compiler->spec[1]);
this_file_error = 1;
}
else
@@ -7346,7 +7334,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
if (this_file_error)
{
delete_failure_queue ();
- error_count++;
+ errorcount++;
break;
}
clear_failure_queue ();
@@ -7368,7 +7356,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
/* Use the same thing in %o, unless cp->spec says otherwise. */
- outfiles[i] = input_filename;
+ outfiles[i] = gcc_input_filename;
/* Figure out which compiler from the file's suffix. */
@@ -7386,7 +7374,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
if (input_file_compiler->spec[0] == '#')
{
error ("%s: %s compiler not installed on this system",
- input_filename, &input_file_compiler->spec[1]);
+ gcc_input_filename, &input_file_compiler->spec[1]);
this_file_error = 1;
}
else
@@ -7463,7 +7451,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
if (this_file_error)
{
delete_failure_queue ();
- error_count++;
+ errorcount++;
}
/* If this compilation succeeded, don't delete those files later. */
clear_failure_queue ();
@@ -7485,13 +7473,13 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
}
}
- if (error_count == 0)
+ if (!seen_error ())
{
/* Make sure INPUT_FILE_NUMBER points to first available open
slot. */
input_file_number = n_infiles;
if (lang_specific_pre_link ())
- error_count++;
+ errorcount++;
}
/* Determine if there are any linker input files. */
@@ -7502,7 +7490,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
/* Run ld to link all the compiler output files. */
- if (num_linker_inputs > 0 && error_count == 0 && print_subprocess_help < 2)
+ if (num_linker_inputs > 0 && !seen_error () && print_subprocess_help < 2)
{
int tmp = execution_count;
const char *fuse_linker_plugin = "fuse-linker-plugin";
@@ -7545,14 +7533,14 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
}
value = do_spec (link_command_spec);
if (value < 0)
- error_count = 1;
+ errorcount = 1;
linker_was_run = (tmp != execution_count);
}
/* If options said don't run linker,
complain about input files to be given to the linker. */
- if (! linker_was_run && error_count == 0)
+ if (! linker_was_run && !seen_error ())
for (i = 0; (int) i < n_infiles; i++)
if (explicit_link_files[i]
&& !(infiles[i].language && infiles[i].language[0] == '*'))
@@ -7561,7 +7549,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
/* Delete some or all of the temporary files we made. */
- if (error_count)
+ if (seen_error ())
delete_failure_queue ();
delete_temp_files ();
@@ -7572,7 +7560,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
}
return (signal_count != 0 ? 2
- : error_count > 0 ? (pass_exit_codes ? greatest_status : 1)
+ : seen_error () ? (pass_exit_codes ? greatest_status : 1)
: 0);
}
@@ -7669,102 +7657,6 @@ perror_with_name (const char *name)
{
error ("%s: %s", name, xstrerror (errno));
}
-
-/* Output an error message and exit. */
-
-void
-fancy_abort (const char *file, int line, const char *func)
-{
- internal_error ("internal gcc abort in %s, at %s:%d", func, file, line);
-}
-
-/* Output an error message and exit. */
-
-void
-internal_error (const char *gmsgid, ...)
-{
- va_list ap;
-
- va_start (ap, gmsgid);
-
- fprintf (stderr, "%s: ", programname);
- vfprintf (stderr, _(gmsgid), ap);
- va_end (ap);
- fprintf (stderr, "\n");
- delete_temp_files ();
- exit (pass_exit_codes ? ICE_EXIT_CODE : 1);
-}
-
-void
-fatal_error (const char *gmsgid, ...)
-{
- va_list ap;
-
- va_start (ap, gmsgid);
-
- fprintf (stderr, "%s: ", programname);
- vfprintf (stderr, _(gmsgid), ap);
- va_end (ap);
- fprintf (stderr, "\n");
- delete_temp_files ();
- exit (1);
-}
-
-/* The argument is actually c-format, not gcc-internal-format,
- but because functions with identical names are used through
- the rest of the compiler with gcc-internal-format, we just
- need to hope all users of these functions use the common
- subset between c-format and gcc-internal-format. */
-
-void
-error (const char *gmsgid, ...)
-{
- va_list ap;
-
- va_start (ap, gmsgid);
- error_count++;
- fprintf (stderr, "%s: %s", programname, _("error: "));
- vfprintf (stderr, _(gmsgid), ap);
- va_end (ap);
-
- fprintf (stderr, "\n");
-}
-
-void
-warning (int dummy ATTRIBUTE_UNUSED, const char *gmsgid, ...)
-{
- va_list ap;
-
- va_start (ap, gmsgid);
- fprintf (stderr, "%s: %s", programname, _("warning: "));
- vfprintf (stderr, _(gmsgid), ap);
- va_end (ap);
-
- fprintf (stderr, "\n");
-}
-
-static void
-inform (int dummy ATTRIBUTE_UNUSED, const char *gmsgid, ...)
-{
- va_list ap;
-
- va_start (ap, gmsgid);
- fprintf (stderr, "%s: %s", programname, _("note: "));
- vfprintf (stderr, _(gmsgid), ap);
- va_end (ap);
-
- fprintf (stderr, "\n");
-}
-
-static void
-fnotice (FILE *fp, const char *cmsgid, ...)
-{
- va_list ap;
-
- va_start (ap, cmsgid);
- vfprintf (fp, _(cmsgid), ap);
- va_end (ap);
-}
static inline void
validate_switches_from_spec (const char *spec)
diff --git a/gcc/gcc.h b/gcc/gcc.h
index a28567454da..af8f0027ee0 100644
--- a/gcc/gcc.h
+++ b/gcc/gcc.h
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3. If not see
#define GCC_GCC_H
#include "version.h"
+#include "diagnostic-core.h"
/* The mapping of a spec function name to the C function that
implements it. */
@@ -59,10 +60,6 @@ struct spec_function
/* These are exported by gcc.c. */
extern int do_spec (const char *);
extern void record_temp_file (const char *, int, int);
-extern void fatal_error (const char *, ...)
- ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
-extern void error (const char *, ...) ATTRIBUTE_PRINTF_1;
-extern void warning (int, const char *, ...) ATTRIBUTE_PRINTF_2;
extern void pfatal_with_name (const char *) ATTRIBUTE_NORETURN;
extern void set_input (const char *);