aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-switch-conversion.c
diff options
context:
space:
mode:
authorOlivier Hainque <hainque@adacore.com>2017-03-10 11:16:21 +0000
committerOlivier Hainque <hainque@gcc.gnu.org>2017-03-10 11:16:21 +0000
commitf1b0632aabe6473bf810b5e901d979a4570b7de5 (patch)
tree288a78ad82886d01310221ae6121bb0e46d117d9 /gcc/tree-switch-conversion.c
parent2d9dd4fb867bffd009ebc85896dceb932559d90a (diff)
downloadgcc-f1b0632aabe6473bf810b5e901d979a4570b7de5.zip
gcc-f1b0632aabe6473bf810b5e901d979a4570b7de5.tar.gz
gcc-f1b0632aabe6473bf810b5e901d979a4570b7de5.tar.bz2
tree-switch-conversion (array_value_type): Start by resetting candidate type to it's main variant.
2017-03-10 Olivier Hainque <hainque@adacore.com> * tree-switch-conversion (array_value_type): Start by resetting candidate type to it's main variant. testsuite/ * gnat.dg/opt64.adb: New test. * gnat.dg/opt64_pkg.ads: New helper. * gnat.dg/opt64_pkg.adb: New helper. From-SVN: r246024
Diffstat (limited to 'gcc/tree-switch-conversion.c')
-rw-r--r--gcc/tree-switch-conversion.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index ce1d11d..1ccb4bd 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -935,9 +935,9 @@ constructor_contains_same_values_p (vec<constructor_elt, va_gc> *vec)
return prev;
}
-/* Return type which should be used for array elements, either TYPE,
- or for integral type some smaller integral type that can still hold
- all the constants. */
+/* Return type which should be used for array elements, either TYPE's
+ main variant or, for integral types, some smaller integral type
+ that can still hold all the constants. */
static tree
array_value_type (gswitch *swtch, tree type, int num,
@@ -949,6 +949,13 @@ array_value_type (gswitch *swtch, tree type, int num,
int sign = 0;
tree smaller_type;
+ /* Types with alignments greater than their size can reach here, e.g. out of
+ SRA. We couldn't use these as an array component type so get back to the
+ main variant first, which, for our purposes, is fine for other types as
+ well. */
+
+ type = TYPE_MAIN_VARIANT (type);
+
if (!INTEGRAL_TYPE_P (type))
return type;