[Bug c/39843] -funsigned-bitfields discards "aligned" attribute

2021-08-05 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39843

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek  ---
So probably it should instead do:
  type = build_type_attribute_qual_variant (unsigned_type_for (type),
TYPE_ATTRIBUTES (type), TYPE_QUALS (type));
or so and similarly for C++?

[Bug c/39843] -funsigned-bitfields discards "aligned" attribute

2021-08-05 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39843

Andrew Pinski  changed:

   What|Removed |Added

 Target||ILP32

--- Comment #4 from Andrew Pinski  ---
I should note that you either have to edit the testcase to use int instead of
long or use an ILP32 target to get the failure.

[Bug c/39843] -funsigned-bitfields discards "aligned" attribute

2021-08-05 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39843

Andrew Pinski  changed:

   What|Removed |Added

   Last reconfirmed||2021-08-05
 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW

--- Comment #3 from Andrew Pinski  ---
Confirmed.
C front-end:
  /* Adjust the type if a bit-field is being declared,
 -funsigned-bitfields applied and the type is not explicitly
 "signed".  */
  if (bitfield && !flag_signed_bitfields && !declspecs->explicit_signed_p
  && TREE_CODE (type) == INTEGER_TYPE)
type = unsigned_type_for (type);


C++ front-end:
  /* Decide whether an integer type is signed or not.
 Optionally treat bitfields as signed by default.  */
  if (unsigned_p
  /* [class.bit]

 It is implementation-defined whether a plain (neither
 explicitly signed or unsigned) char, short, int, or long
 bit-field is signed or unsigned.

 Naturally, we extend this to long long as well.  Note that
 this does not include wchar_t.  */
  || (bitfield && !flag_signed_bitfields
  && !signed_p
  /* A typedef for plain `int' without `signed' can be
 controlled just like plain `int', but a typedef for
 `signed int' cannot be so controlled.  */
  && !(typedef_decl
   && C_TYPEDEF_EXPLICITLY_SIGNED (typedef_decl))
  && TREE_CODE (type) == INTEGER_TYPE
  && !same_type_p (TYPE_MAIN_VARIANT (type), wchar_type_node)))
{
  if (explicit_intN)
type = int_n_trees[declspecs->int_n_idx].unsigned_type;
  else if (longlong)
type = long_long_unsigned_type_node;
  else if (long_p)
type = long_unsigned_type_node;
  else if (short_p)
type = short_unsigned_type_node;
  else if (type == char_type_node)
type = unsigned_char_type_node;
  else if (typedef_decl)
type = unsigned_type_for (type);
  else
type = unsigned_type_node;
}

The problem is we have a typedef with aligned attribute on it but in both cases
we lose that.

[Bug c/39843] -funsigned-bitfields discards aligned attribute

2009-06-04 Thread mikpe at it dot uu dot se


--- Comment #2 from mikpe at it dot uu dot se  2009-06-04 09:22 ---
(In reply to comment #0)
 % gcc-snapshot -funsigned-bitfields testsuite/gcc.dg/bitfld-3.c
 % ./a.out
 Abort

Confirmed with gcc-4.4-20090602 and gcc-4.3-20090531 on i686-pc-linux-gnu. I
haven't been able to reproduce the problem on x86_64.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39843



[Bug c/39843] -funsigned-bitfields discards aligned attribute

2009-04-22 Thread mikpe at it dot uu dot se


--- Comment #1 from mikpe at it dot uu dot se  2009-04-22 08:05 ---
(In reply to comment #0)
 % gcc-snapshot -funsigned-bitfields testsuite/gcc.dg/bitfld-3.c
 % ./a.out
 Abort

Confirmed with gcc-4.3-20090419 on i686-pc-linux-gnu.


-- 

mikpe at it dot uu dot se changed:

   What|Removed |Added

 CC||mikpe at it dot uu dot se


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39843