From c05c23808106294ff0b6665cb4dd395a691be659 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 16 Mar 2017 17:27:08 +0100 Subject: [PATCH] re PR fortran/79886 (ICE in pp_format, at pretty-print.c:681) PR fortran/79886 * tree-diagnostic.c (default_tree_printer): No longer static. * tree-diagnostic.h (default_tree_printer): New prototype. fortran/ * error.c (gfc_format_decoder): Rename plus argument to set_locus, remove ATTRIBUTE_UNUSED from all arguments, call default_tree_printer if not a Fortran specific spec. * trans-io.c: Include options.h. (gfc_build_st_parameter): Temporarily disable -Wpadded around layout of artificial IO data structures. testsuite/ * gfortran.dg/pr79886.f90: New test. From-SVN: r246203 --- gcc/ChangeLog | 6 ++++++ gcc/fortran/ChangeLog | 10 ++++++++++ gcc/fortran/error.c | 12 +++++++----- gcc/fortran/trans-io.c | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr79886.f90 | 17 +++++++++++++++++ gcc/tree-diagnostic.c | 2 +- gcc/tree-diagnostic.h | 3 +++ 8 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr79886.f90 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4def3a56312..ee94c4f97eb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-03-16 Jakub Jelinek + + PR fortran/79886 + * tree-diagnostic.c (default_tree_printer): No longer static. + * tree-diagnostic.h (default_tree_printer): New prototype. + 2017-03-16 Tamar Christina * config/aarch64/aarch64-simd.md (*aarch64_simd_mov) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 8629cab6ccb..b617d45ca86 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2017-03-16 Jakub Jelinek + + PR fortran/79886 + * error.c (gfc_format_decoder): Rename plus argument to set_locus, + remove ATTRIBUTE_UNUSED from all arguments, call default_tree_printer + if not a Fortran specific spec. + * trans-io.c: Include options.h. + (gfc_build_st_parameter): Temporarily disable -Wpadded around layout + of artificial IO data structures. + 2017-03-15 David Malcolm PR fortran/79860 diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c index ccf0be019e2..0312499f324 100644 --- a/gcc/fortran/error.c +++ b/gcc/fortran/error.c @@ -916,10 +916,8 @@ gfc_notify_std (int std, const char *gmsgid, ...) %L Takes locus argument */ static bool -gfc_format_decoder (pretty_printer *pp, - text_info *text, const char *spec, - int precision ATTRIBUTE_UNUSED, bool wide ATTRIBUTE_UNUSED, - bool plus ATTRIBUTE_UNUSED, bool hash ATTRIBUTE_UNUSED) +gfc_format_decoder (pretty_printer *pp, text_info *text, const char *spec, + int precision, bool wide, bool set_locus, bool hash) { switch (*spec) { @@ -946,7 +944,11 @@ gfc_format_decoder (pretty_printer *pp, return true; } default: - return false; + /* Fall through info the middle-end decoder, as e.g. stor-layout.c + etc. diagnostics can use the FE printer while the FE is still + active. */ + return default_tree_printer (pp, text, spec, precision, wide, + set_locus, hash); } } diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c index fbbad46de67..36e84be83c1 100644 --- a/gcc/fortran/trans-io.c +++ b/gcc/fortran/trans-io.c @@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see #include "trans-array.h" #include "trans-types.h" #include "trans-const.h" +#include "options.h" /* Members of the ioparm structure. */ @@ -219,7 +220,12 @@ gfc_build_st_parameter (enum ioparam_type ptype, tree *types) gcc_unreachable (); } + /* -Wpadded warnings on these artificially created structures are not + helpful; suppress them. */ + int save_warn_padded = warn_padded; + warn_padded = 0; gfc_finish_type (t); + warn_padded = save_warn_padded; st_parameter[ptype].type = t; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3ca7b5fc483..2fbdeb581ad 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-03-16 Jakub Jelinek + + PR fortran/79886 + * gfortran.dg/pr79886.f90: New test. + 2017-03-15 Michael Meissner PR target/79038 diff --git a/gcc/testsuite/gfortran.dg/pr79886.f90 b/gcc/testsuite/gfortran.dg/pr79886.f90 new file mode 100644 index 00000000000..a62cd1889c7 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr79886.f90 @@ -0,0 +1,17 @@ +! PR fortran/79886 +! { dg-do compile } +! { dg-options "-Wpadded" } + +subroutine pr79886 + type :: foo + integer (kind=1) :: a + integer (kind=8) :: b ! { dg-warning "padding struct to align" } + integer (kind=1) :: c + integer (kind=8) :: d ! { dg-warning "padding struct to align" } + end type + type (foo) :: f + f%a = 1 + f%b = 2 + f%c = 3 + f%d = 4 +end subroutine diff --git a/gcc/tree-diagnostic.c b/gcc/tree-diagnostic.c index 7edea0e69a7..4f211ed42b3 100644 --- a/gcc/tree-diagnostic.c +++ b/gcc/tree-diagnostic.c @@ -243,7 +243,7 @@ virt_loc_aware_diagnostic_finalizer (diagnostic_context *context, } /* Default tree printer. Handles declarations only. */ -static bool +bool default_tree_printer (pretty_printer *pp, text_info *text, const char *spec, int precision, bool wide, bool set_locus, bool hash) { diff --git a/gcc/tree-diagnostic.h b/gcc/tree-diagnostic.h index 01109445197..e95183f92f7 100644 --- a/gcc/tree-diagnostic.h +++ b/gcc/tree-diagnostic.h @@ -54,4 +54,7 @@ void virt_loc_aware_diagnostic_finalizer (diagnostic_context *, diagnostic_info *); void tree_diagnostics_defaults (diagnostic_context *context); +bool default_tree_printer (pretty_printer *, text_info *, const char *, + int, bool, bool, bool); + #endif /* ! GCC_TREE_DIAGNOSTIC_H */ -- 2.30.2