diff options
author | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-09-25 14:24:11 +0000 |
---|---|---|
committer | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-09-25 14:24:11 +0000 |
commit | a6871bda07973b01bb6472dbd4cac03339cce8e2 (patch) | |
tree | 21100e9b2f3e1a93346e76fdaba64fa8547b8ad1 | |
parent | b0d054a98e062cb8541c1dd00bdae82d5ee4dc9e (diff) | |
download | gcc-a6871bda07973b01bb6472dbd4cac03339cce8e2.tar.gz |
PR pretty-print/67567 do not pass NULL as a string
Fortran passes NULL where a non-null string is expected by the pretty-printer,
which causes a sanitizer warning. This could have been found earlier by using
gcc_checking_assert. Even if the assertion is false, the result is just an
incomplete diagnostic, thus it seems more user-friendly to assert only when
checking. I do not have any idea how to properly fix the Fortran bug, thus this
patch simply works-around it.
gcc/fortran/ChangeLog:
2015-09-25 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR pretty-print/67567
* resolve.c (resolve_fl_procedure): Work-around when iface->module
== NULL.
gcc/ChangeLog:
2015-09-25 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR pretty-print/67567
* pretty-print.c (pp_string): Add gcc_checking_assert.
* pretty-print.h (output_buffer_append_r): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228131 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/resolve.c | 15 | ||||
-rw-r--r-- | gcc/pretty-print.c | 3 | ||||
-rw-r--r-- | gcc/pretty-print.h | 1 |
5 files changed, 27 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1fe4e933737..7c39c519ec2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-09-25 Manuel López-Ibáñez <manu@gcc.gnu.org> + + PR pretty-print/67567 + * pretty-print.c (pp_string): Add gcc_checking_assert. + * pretty-print.h (output_buffer_append_r): Likewise. + 2015-09-25 Oleg Endo <olegendo@gcc.gnu.org> PR target/67675 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 2b818213b69..8e33a1d231c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2015-09-25 Manuel López-Ibáñez <manu@gcc.gnu.org> + + PR pretty-print/67567 + * resolve.c (resolve_fl_procedure): Work-around when iface->module + == NULL. + 2015-09-21 Steven G. Kargl <kargl@gcc.gnu.org> * resolve.c (nonscalar_typebound_assign): Fix typos in comment. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 7363e0643b9..59cf03402fe 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -11743,7 +11743,10 @@ resolve_fl_procedure (gfc_symbol *sym, int mp_flag) { gfc_error ("Mismatch in PURE attribute between MODULE " "PROCEDURE at %L and its interface in %s", - &sym->declared_at, iface->module); + &sym->declared_at, + /* FIXME: PR fortran/67567: iface->module should + not be NULL ! */ + iface->module ? iface->module : ""); return false; } @@ -11759,7 +11762,10 @@ resolve_fl_procedure (gfc_symbol *sym, int mp_flag) { gfc_error ("Mismatch in RECURSIVE attribute between MODULE " "PROCEDURE at %L and its interface in %s", - &sym->declared_at, iface->module); + &sym->declared_at, + /* FIXME: PR fortran/67567: iface->module should + not be NULL ! */ + iface->module ? iface->module : ""); return false; } @@ -11768,7 +11774,10 @@ resolve_fl_procedure (gfc_symbol *sym, int mp_flag) { gfc_error ("%s between the MODULE PROCEDURE declaration " "in module %s and the declaration at %L in " - "SUBMODULE %s", errmsg, iface->module, + "SUBMODULE %s", errmsg, + /* FIXME: PR fortran/67567: iface->module should + not be NULL ! */ + iface->module ? iface->module : "", &sym->declared_at, sym->ns->proc_name->name); return false; } diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c index fdc7b4da34f..5889015d400 100644 --- a/gcc/pretty-print.c +++ b/gcc/pretty-print.c @@ -905,7 +905,8 @@ pp_character (pretty_printer *pp, int c) void pp_string (pretty_printer *pp, const char *str) { - pp_maybe_wrap_text (pp, str, str + (str ? strlen (str) : 0)); + gcc_checking_assert (str); + pp_maybe_wrap_text (pp, str, str + strlen (str)); } /* Maybe print out a whitespace if needed. */ diff --git a/gcc/pretty-print.h b/gcc/pretty-print.h index 36d4e37a0d2..2654b0fcbec 100644 --- a/gcc/pretty-print.h +++ b/gcc/pretty-print.h @@ -139,6 +139,7 @@ output_buffer_formatted_text (output_buffer *buff) static inline void output_buffer_append_r (output_buffer *buff, const char *start, int length) { + gcc_checking_assert (start); obstack_grow (buff->obstack, start, length); buff->line_length += length; } |