[PATCH] Fix type homogeneity bug

Eric Botcazou ebotcazou@adacore.com
Sun Mar 30 16:26:00 GMT 2008


Hi,

The attached Ada testcase triggers a type checking failure:

p.adb: In function 'P':
p.adb:1: error: type mismatch in binary expression
system__unsigned_types__long_long_unsigned

p__Tb1S___XP1

p__Tb2S___XP1

D.202 = D.200 & D.201

introduced by the constant folder.  It is passed:

(gdb) frame 4
#4  0x0890c2f5 in fold_build2_stat (code=BIT_IOR_EXPR, type=0x55704a90,
    op0=0x557054a0, op1=0x557054c0)
    at /home/eric/gnat/gnat-head/src/gcc/fold-const.c:13370
13370     tem = fold_binary (code, type, op0, op1);

(gdb) p debug_tree(type)
 <integer_type 0x55704a90 system__unsigned_types__long_long_unsigned 
sizes-gimplified public visited unsigned DI

(gdb) p debug_tree(op0)
 <nop_expr 0x557054a0
    type <integer_type 0x55704a90 system__unsigned_types__long_long_unsigned 
sizes-gimplified public visited unsigned DI
        size <integer_cst 0x556dd71c constant invariant visited 64>
        unit size <integer_cst 0x556dd738 constant invariant visited 8>
        align 64 symtab 0 alias set -1 canonical type 0x55704a90 precision 64 
min <integer_cst 0x556ff594 0> max <integer_cst 0x556ff578 -1> RM size 
<integer_cst 0x556dd71c 64>>

    arg 0 <bit_not_expr 0x55705420
        type <integer_type 0x55704a28 p__Tb1S___XP1 type <integer_type 
0x55704a90 system__unsigned_types__long_long_unsigned>

(gdb) p debug_tree(op1)
 <nop_expr 0x557054c0
    type <integer_type 0x55704a90 system__unsigned_types__long_long_unsigned 
sizes-gimplified public visited unsigned DI
        size <integer_cst 0x556dd71c constant invariant visited 64>
        unit size <integer_cst 0x556dd738 constant invariant visited 8>
        align 64 symtab 0 alias set -1 canonical type 0x55704a90 precision 64 
min <integer_cst 0x556ff594 0> max <integer_cst 0x556ff578 -1> RM size 
<integer_cst 0x556dd71c 64>>

    arg 0 <bit_not_expr 0x55705480
        type <integer_type 0x55704f70 p__Tb2S___XP1 type <integer_type 
0x55704a90 system__unsigned_types__long_long_unsigned>

and yields:

 <bit_and_expr 0x556e1558
    type <integer_type 0x55704a90 system__unsigned_types__long_long_unsigned 
sizes-gimplified public visited unsigned DI
        size <integer_cst 0x556dd71c constant invariant visited 64>
        unit size <integer_cst 0x556dd738 constant invariant visited 8>
        align 64 symtab 0 alias set -1 canonical type 0x55704a90 precision 64 
min <integer_cst 0x556ff594 0> max <integer_cst 0x556ff578 -1> RM size 
<integer_cst 0x556dd71c 64>>

    arg 0 <component_ref 0x556e8118
        type <integer_type 0x55704a28 p__Tb1S___XP1 type <integer_type 
0x55704a90 system__unsigned_types__long_long_unsigned>

    arg 1 <component_ref 0x556e8140
        type <integer_type 0x55704f70 p__Tb2S___XP1 type <integer_type 
0x55704a90 system__unsigned_types__long_long_unsigned>


Tested on x86_64-suse-linux, OK for mainline?


2008-03-30  Eric Botcazou  <ebotcazou@adacore.com>

	* fold-const.c (fold_binary) <BIT_IOR_EXPR>: Add missing conversions.


2008-03-30  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/bit_packed_array2.adb: New test.


-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-diff
Size: 591 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080330/96b05513/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bit_packed_array2.adb
Type: text/x-adasrc
Size: 324 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080330/96b05513/attachment-0001.bin>


More information about the Gcc-patches mailing list