[patch, fortran] PR 46659 - extend conversion warnings to assignments

Thomas Koenig tkoenig@netcologne.de
Mon Aug 15 17:49:00 GMT 2011


Am 14.08.2011 22:54, schrieb Tobias Burnus:
> Thomas Koenig wrote:
>> the attached patch extends conversion warnings to assignments.
>> OK for trunk?
>
> I get now two warnings for:
>
> complex(8), parameter :: z = cmplx (0.5, 0.5)
> r = z
> end

The problem is that gfc_check_assign is called twice for this, from
different code paths:


Breakpoint 1, gfc_check_assign (lvalue=0x7fffffffd8d0, rvalue=0x15bb020, 
conform=1)
     at ../../trunk/gcc/fortran/expr.c:3045 

3045    { 

(gdb) bt 

#0  gfc_check_assign (lvalue=0x7fffffffd8d0, rvalue=0x15bb020, 
conform=1)
     at ../../trunk/gcc/fortran/expr.c:3045 

#1  0x00000000004f70bb in gfc_check_assign_symbol (sym=0x15bb680, 
rvalue=0x15bb020)
     at ../../trunk/gcc/fortran/expr.c:3649 

#2  0x00000000004e0670 in add_init_expr_to_sym (name=Unhandled dwarf 
expression opcode 0xf3
) at ../../trunk/gcc/fortran/decl.c:1346 

#3  0x00000000004e87d0 in variable_decl (elem=<value optimized out>) 

     at ../../trunk/gcc/fortran/decl.c:2047 

#4  gfc_match_data_decl (elem=<value optimized out>) at 
../../trunk/gcc/fortran/decl.c:4124
#5  0x000000000052cb8a in match_word (subr=Unhandled dwarf expression 
opcode 0xf3
) at ../../trunk/gcc/fortran/parse.c:65 

#6  0x000000000052d3a0 in decode_statement () at 
../../trunk/gcc/fortran/parse.c:283
#7  decode_statement () at ../../trunk/gcc/fortran/parse.c:232 

#8  0x000000000052ea05 in next_free () at 
../../trunk/gcc/fortran/parse.c:731
#9  next_statement () at ../../trunk/gcc/fortran/parse.c:923 

#10 0x00000000005320de in gfc_parse_file () at 
../../trunk/gcc/fortran/parse.c:4382
#11 0x000000000056b486 in gfc_be_parse_file () at 
../../trunk/gcc/fortran/f95-lang.c:250
#12 0x00000000008fa978 in compile_file () at ../../trunk/gcc/toplev.c:548
#13 do_compile () at ../../trunk/gcc/toplev.c:1886
#14 toplev_main () at ../../trunk/gcc/toplev.c:1962
#15 0x00007ffff6f8aa7d in __libc_start_main () from /lib64/libc.so.6
#16 0x00000000004cade9 in _start () at ../sysdeps/x86_64/elf/start.S:113
(gdb) c
Continuing.

Breakpoint 1, gfc_check_assign (lvalue=0x7fffffffd9e0, rvalue=0x15bb020, 
conform=1)
     at ../../trunk/gcc/fortran/expr.c:3045
3045    {
(gdb) bt
#0  gfc_check_assign (lvalue=0x7fffffffd9e0, rvalue=0x15bb020, conform=1)
     at ../../trunk/gcc/fortran/expr.c:3045
#1  0x00000000004f70bb in gfc_check_assign_symbol (sym=0x15bb680, 
rvalue=0x15bb020)
     at ../../trunk/gcc/fortran/expr.c:3649
#2  0x000000000055a697 in traverse_ns (st=Unhandled dwarf expression 
opcode 0xf3
) at ../../trunk/gcc/fortran/symbol.c:3333
#3  0x000000000055fd8c in gfc_traverse_ns (ns=0x15ba590,
     func=0x548200 <resolve_values(gfc_symbol*)>) at 
../../trunk/gcc/fortran/symbol.c:3349
#4  0x00000000005475e1 in resolve_types (ns=0x15ba590) at 
../../trunk/gcc/fortran/resolve.c:13511
#5  0x000000000053c4e4 in gfc_resolve (ns=0x15ba590) at 
../../trunk/gcc/fortran/resolve.c:13593
#6  gfc_resolve (ns=0x15ba590) at ../../trunk/gcc/fortran/resolve.c:13581
#7  0x00000000005325cb in resolve_all_program_units 
(gfc_global_ns_list=<value optimized out>)
     at ../../trunk/gcc/fortran/parse.c:4247
#8  gfc_parse_file (gfc_global_ns_list=<value optimized out>)
     at ../../trunk/gcc/fortran/parse.c:4513
#9  0x000000000056b486 in gfc_be_parse_file () at 
../../trunk/gcc/fortran/f95-lang.c:250
#10 0x00000000008fa978 in compile_file () at ../../trunk/gcc/toplev.c:548
#11 do_compile () at ../../trunk/gcc/toplev.c:1886
#12 toplev_main () at ../../trunk/gcc/toplev.c:1962
#13 0x00007ffff6f8aa7d in __libc_start_main () from /lib64/libc.so.6
#14 0x00000000004cade9 in _start () at ../sysdeps/x86_64/elf/start.S:113


What's the best way here?  Add an "already checked" flag?  I don't want
to disable the test for complex.



More information about the Fortran mailing list