This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[obvious] Fix va_end calls
- From: Michael Matz <matz at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 19 Apr 2012 14:53:45 +0200 (CEST)
- Subject: [obvious] Fix va_end calls
Hi,
I observed this with an alternate implementation of the stdarg stuff that
allocs new va_lists for va_start and va_copy, and frees them on va_end.
Some routines of diagnostic.c called va_end while the va_list was still
stored away in the diag objects and used in report_diagnostic.
I've audited all other calls of va_end in the compiler and these were the
only problematic ones. Committed as obvious in r186590 after regstrapping
on x86_64-linux, all languages.
Ciao,
Michael.
------------------
* diagnostic.c (emit_diagnostic): Move va_end call after user
of the va_list.
(warning, warning_at, pedwarn, permerror): Ditto.
Index: diagnostic.c
===================================================================
--- diagnostic.c (revision 186580)
+++ diagnostic.c (working copy)
@@ -714,6 +714,7 @@ emit_diagnostic (diagnostic_t kind, loca
{
diagnostic_info diagnostic;
va_list ap;
+ bool ret;
va_start (ap, gmsgid);
if (kind == DK_PERMERROR)
@@ -727,9 +728,10 @@ emit_diagnostic (diagnostic_t kind, loca
if (kind == DK_WARNING || kind == DK_PEDWARN)
diagnostic.option_index = opt;
}
- va_end (ap);
- return report_diagnostic (&diagnostic);
+ ret = report_diagnostic (&diagnostic);
+ va_end (ap);
+ return ret;
}
/* An informative note at LOCATION. Use this for additional details on an error
@@ -771,13 +773,15 @@ warning (int opt, const char *gmsgid, ..
{
diagnostic_info diagnostic;
va_list ap;
+ bool ret;
va_start (ap, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location, DK_WARNING);
diagnostic.option_index = opt;
+ ret = report_diagnostic (&diagnostic);
va_end (ap);
- return report_diagnostic (&diagnostic);
+ return ret;
}
/* A warning at LOCATION. Use this for code which is correct according to the
@@ -789,12 +793,14 @@ warning_at (location_t location, int opt
{
diagnostic_info diagnostic;
va_list ap;
+ bool ret;
va_start (ap, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_WARNING);
diagnostic.option_index = opt;
+ ret = report_diagnostic (&diagnostic);
va_end (ap);
- return report_diagnostic (&diagnostic);
+ return ret;
}
/* A "pedantic" warning at LOCATION: issues a warning unless
@@ -815,12 +821,14 @@ pedwarn (location_t location, int opt, c
{
diagnostic_info diagnostic;
va_list ap;
+ bool ret;
va_start (ap, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_PEDWARN);
diagnostic.option_index = opt;
+ ret = report_diagnostic (&diagnostic);
va_end (ap);
- return report_diagnostic (&diagnostic);
+ return ret;
}
/* A "permissive" error at LOCATION: issues an error unless
@@ -835,13 +843,15 @@ permerror (location_t location, const ch
{
diagnostic_info diagnostic;
va_list ap;
+ bool ret;
va_start (ap, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
permissive_error_kind (global_dc));
diagnostic.option_index = permissive_error_option (global_dc);
+ ret = report_diagnostic (&diagnostic);
va_end (ap);
- return report_diagnostic (&diagnostic);
+ return ret;
}
/* A hard error: the code is definitely ill-formed, and an object file