From: jakub Date: Tue, 27 Sep 2011 19:17:31 +0000 (+0000) Subject: * trans-types.c (gfc_type_for_size): Return wider type X-Git-Tag: upstream/4.9.2~17472 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b04941de6611e7cade52181c61455272415beadf;p=platform%2Fupstream%2Flinaro-gcc.git * trans-types.c (gfc_type_for_size): Return wider type if no suitable narrower type has been found. (gfc_type_for_mode): Return NULL_TREE if gfc_type_for_size returned type doesn't have expected TYPE_MODE. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179290 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5900b63..99d2d3c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2011-09-27 Jakub Jelinek + + * trans-types.c (gfc_type_for_size): Return wider type + if no suitable narrower type has been found. + (gfc_type_for_mode): Return NULL_TREE if gfc_type_for_size + returned type doesn't have expected TYPE_MODE. + 2011-09-26 Janus Weil PR fortran/50515 diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index 43f1a19..aa8e43b 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -2791,18 +2791,29 @@ gfc_type_for_size (unsigned bits, int unsignedp) if (bits == TYPE_PRECISION (intTI_type_node)) return intTI_type_node; #endif + + if (bits <= TYPE_PRECISION (intQI_type_node)) + return intQI_type_node; + if (bits <= TYPE_PRECISION (intHI_type_node)) + return intHI_type_node; + if (bits <= TYPE_PRECISION (intSI_type_node)) + return intSI_type_node; + if (bits <= TYPE_PRECISION (intDI_type_node)) + return intDI_type_node; + if (bits <= TYPE_PRECISION (intTI_type_node)) + return intTI_type_node; } else { - if (bits == TYPE_PRECISION (unsigned_intQI_type_node)) + if (bits <= TYPE_PRECISION (unsigned_intQI_type_node)) return unsigned_intQI_type_node; - if (bits == TYPE_PRECISION (unsigned_intHI_type_node)) + if (bits <= TYPE_PRECISION (unsigned_intHI_type_node)) return unsigned_intHI_type_node; - if (bits == TYPE_PRECISION (unsigned_intSI_type_node)) + if (bits <= TYPE_PRECISION (unsigned_intSI_type_node)) return unsigned_intSI_type_node; - if (bits == TYPE_PRECISION (unsigned_intDI_type_node)) + if (bits <= TYPE_PRECISION (unsigned_intDI_type_node)) return unsigned_intDI_type_node; - if (bits == TYPE_PRECISION (unsigned_intTI_type_node)) + if (bits <= TYPE_PRECISION (unsigned_intTI_type_node)) return unsigned_intTI_type_node; } @@ -2823,7 +2834,10 @@ gfc_type_for_mode (enum machine_mode mode, int unsignedp) else if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT) base = gfc_complex_types; else if (SCALAR_INT_MODE_P (mode)) - return gfc_type_for_size (GET_MODE_PRECISION (mode), unsignedp); + { + tree type = gfc_type_for_size (GET_MODE_PRECISION (mode), unsignedp); + return type != NULL_TREE && mode == TYPE_MODE (type) ? type : NULL_TREE; + } else if (VECTOR_MODE_P (mode)) { enum machine_mode inner_mode = GET_MODE_INNER (mode);