decl.c (finish_enum_value_list): Use the specified mode.

2016-05-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        * decl.c (finish_enum_value_list): Use the specified mode.

testsuite:
2016-05-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        * c-c++-common/pr69669.c: Check the used mode.

From-SVN: r236458
This commit is contained in:
Bernd Edlinger 2016-05-19 12:27:31 +00:00 committed by Bernd Edlinger
parent f3510625cf
commit 4bf8dbe16a
4 changed files with 24 additions and 0 deletions

View file

@ -1,3 +1,7 @@
2016-05-19 Bernd Edlinger <bernd.edlinger@hotmail.de>
* decl.c (finish_enum_value_list): Use the specified mode.
2016-05-18 Jason Merrill <jason@redhat.com>
* pt.c (value_dependent_expression_p): Tweak new cases to better

View file

@ -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++)

View file

@ -1,3 +1,7 @@
2016-05-19 Bernd Edlinger <bernd.edlinger@hotmail.de>
* c-c++-common/pr69669.c: Check the used mode.
2016-05-19 Maxim Ostapenko <m.ostapenko@samsung.com>
PR sanitizer/64354

View file

@ -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" } } */