From 4bf8dbe16aa168e50fa240d2d368d439e07208d8 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Thu, 19 May 2016 12:27:31 +0000 Subject: [PATCH] decl.c (finish_enum_value_list): Use the specified mode. 2016-05-19 Bernd Edlinger * decl.c (finish_enum_value_list): Use the specified mode. testsuite: 2016-05-19 Bernd Edlinger * c-c++-common/pr69669.c: Check the used mode. From-SVN: r236458 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/decl.c | 13 +++++++++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/c-c++-common/pr69669.c | 3 +++ 4 files changed, 24 insertions(+) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 81baa89a30d..66c04a6f359 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2016-05-19 Bernd Edlinger + + * decl.c (finish_enum_value_list): Use the specified mode. + 2016-05-18 Jason Merrill * pt.c (value_dependent_expression_p): Tweak new cases to better diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d493a776a0c..7eabf53847f 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -13346,6 +13346,19 @@ finish_enum_value_list (tree enumtype) use_short_enum = flag_short_enums || lookup_attribute ("packed", TYPE_ATTRIBUTES (enumtype)); + /* If the precision of the type was specified with an attribute and it + was too small, give an error. Otherwise, use it. */ + if (TYPE_PRECISION (enumtype)) + { + if (precision > TYPE_PRECISION (enumtype)) + error ("specified mode too small for enumeral values"); + else + { + use_short_enum = true; + precision = TYPE_PRECISION (enumtype); + } + } + for (itk = (use_short_enum ? itk_char : itk_int); itk != itk_none; itk++) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4f20c2cd63e..037d1401e3a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-05-19 Bernd Edlinger + + * c-c++-common/pr69669.c: Check the used mode. + 2016-05-19 Maxim Ostapenko PR sanitizer/64354 diff --git a/gcc/testsuite/c-c++-common/pr69669.c b/gcc/testsuite/c-c++-common/pr69669.c index 9940afe8ffb..ebeb4109ffa 100644 --- a/gcc/testsuite/c-c++-common/pr69669.c +++ b/gcc/testsuite/c-c++-common/pr69669.c @@ -1,5 +1,6 @@ /* PR c/69669 */ /* { dg-do compile } */ +/* { dg-options "-fdump-rtl-final" } */ enum __attribute__((mode(QI))) E { F = 1 }; @@ -8,3 +9,5 @@ foo (enum E *x, int y) { *x = (enum E) y; } + +/* { dg-final { scan-rtl-dump-times "mem:QI" 1 "final" } } */ -- 2.30.2