Fortran test typebound_operator_7.f03 broken by non-Fortran commit. Confirm anyone?

Thomas Schwinge tschwinge@baylibre.com
Tue Oct 15 07:49:47 GMT 2024


Hi!

On 2024-10-14T21:18:17+0100, Sam James <sam@gentoo.org> wrote:
> Sam James <sam@gentoo.org> writes:
>> Andre Vehreschild <vehre@gmx.de> writes:
>>> [...] During latest regression testing of the Fortran suite I got
>>> typebound_operator_7.f03 failing with:
>>>
>>> typebound_operator_7.f03:94:25:
>>>
>>>    94 |   u = (u*2.0*4.0) + u*4.0
>>>       |                         1
>>> internal compiler error: tree check: expected function_decl, have indirect_ref
>>>    in DECL_FUNCTION_CODE, at tree.h:4329 0x3642f3e internal_error(char const*,
>>>    ...) /mnt/work_store/gcc/gcc.test/gcc/diagnostic-global-context.cc:517
>>> 0x1c0a703 tree_check_failed(tree_node const*, char const*, int, char const*,
>>>    ...) /mnt/work_store/gcc/gcc.test/gcc/tree.cc:9003
>>> 0xeb9150 tree_check(tree_node const*, char const*, int, char const*, tree_code)
>>> 	/mnt/work_store/gcc/gcc.test/gcc/tree.h:3921
>>> 0xf5725b DECL_FUNCTION_CODE(tree_node const*)
>>> 	/mnt/work_store/gcc/gcc.test/gcc/tree.h:4329
>>> 0xf383d6 update_builtin_function
>>> 	/mnt/work_store/gcc/gcc.test/gcc/fortran/trans-expr.cc:4405
>>> 0xf468b9 gfc_conv_procedure_call(gfc_se*, gfc_symbol*, gfc_actual_arglist*,
>>>    gfc_expr*, vec<tree_node*, va_gc, vl_embed>*)
>>>    /mnt/work_store/gcc/gcc.test/gcc/fortran/trans-expr.cc:8236 0xf48b0f
>>>    gfc_conv_function_expr
>>>    /mnt/work_store/gcc/gcc.test/gcc/fortran/trans-expr.cc:8815 0xf4ceda
>>>    gfc_conv_expr(gfc_se*, gfc_expr*)
>>>    /mnt/work_store/gcc/gcc.test/gcc/fortran/trans-expr.cc:9982 0xf40777
>>>    gfc_conv_procedure_call(gfc_se*, gfc_symbol*, gfc_actual_arglist*,
>>>    gfc_expr*, vec<tree_node*, va_gc, vl_embed>*)
>>>    /mnt/work_store/gcc/gcc.test/gcc/fortran/trans-expr.cc:6816 0xf48b0f
>>>    gfc_conv_function_expr
>>>    /mnt/work_store/gcc/gcc.test/gcc/fortran/trans-expr.cc:8815 0xf4ceda
>>>    gfc_conv_expr(gfc_se*, gfc_expr*)
>>>    /mnt/work_store/gcc/gcc.test/gcc/fortran/trans-expr.cc:9982 0xf40777
>>>    gfc_conv_procedure_call(gfc_se*, gfc_symbol*, gfc_actual_arglist*,
>>>    gfc_expr*, vec<tree_node*, va_gc, vl_embed>*)
>>>    /mnt/work_store/gcc/gcc.test/gcc/fortran/trans-expr.cc:6816 0xfb580a
>>>    gfc_trans_call(gfc_code*, bool, tree_node*, tree_node*, bool)
>>>    /mnt/work_store/gcc/gcc.test/gcc/fortran/trans-stmt.cc:425 0xed9363
>>>    trans_code /mnt/work_store/gcc/gcc.test/gcc/fortran/trans.cc:2434 0xed97d5
>>>    gfc_trans_code(gfc_code*)
>>>    /mnt/work_store/gcc/gcc.test/gcc/fortran/trans.cc:2713 0xf26342
>>>    gfc_generate_function_code(gfc_namespace*)
>>>    /mnt/work_store/gcc/gcc.test/gcc/fortran/trans-decl.cc:7958 0xed9819
>>>    gfc_generate_code(gfc_namespace*)
>>>    /mnt/work_store/gcc/gcc.test/gcc/fortran/trans.cc:2730 0xe544ee
>>>    translate_all_program_units
>>>    /mnt/work_store/gcc/gcc.test/gcc/fortran/parse.cc:7156 0xe54e23
>>>    gfc_parse_file() /mnt/work_store/gcc/gcc.test/gcc/fortran/parse.cc:7473
>>>    0xebf7ce gfc_be_parse_file
>>>    /mnt/work_store/gcc/gcc.test/gcc/fortran/f95-lang.cc:241

>> Tobias Burnus (1):
>>       Fortran: Use OpenACC's acc_on_device builtin, fix OpenMP' __builtin_is_initial_device

> Indeed: https://gcc.gnu.org/PR117136.

On 2024-10-13T10:21:01+0200, Tobias Burnus <tburnus@baylibre.com> wrote:
> Now pushed as r15-4298-g3269a722b7a036.

> --- a/gcc/fortran/trans-expr.cc
> +++ b/gcc/fortran/trans-expr.cc

>  static void
> -conv_function_val (gfc_se * se, gfc_symbol * sym, gfc_expr * expr,
> -		   gfc_actual_arglist *actual_args)
> +conv_function_val (gfc_se * se, bool *is_builtin, gfc_symbol * sym,
> +		   gfc_expr * expr, gfc_actual_arglist *actual_args)
>  {
>    tree tmp;
>  
> +  *is_builtin = false;
> [...]

Unconditionally initializes '*is_builtin' here...

> @@ -6324,6 +6366,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
>    gfc_actual_arglist *arg;
>    int has_alternate_specifier = 0;
>    bool need_interface_mapping;
> +  bool is_builtin;
>    bool callee_alloc;
>    bool ulim_copy;
>    gfc_typespec ts;
> @@ -8164,7 +8207,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
>  
>    /* Generate the actual call.  */
>    if (base_object == NULL_TREE)
> -    conv_function_val (se, sym, expr, args);
> +    conv_function_val (se, &is_builtin, sym, expr, args);
>    else
>      conv_base_obj_fcn_val (se, base_object, expr);
>  
> @@ -8189,6 +8232,9 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
>    fntype = TREE_TYPE (TREE_TYPE (se->expr));
>    se->expr = build_call_vec (TREE_TYPE (fntype), se->expr, arglist);
>  
> +  if (is_builtin)
> +    se->expr = update_builtin_function (se->expr, sym);
> +
>    /* Allocatable scalar function results must be freed and nullified
>       after use. This necessitates the creation of a temporary to
>       hold the result to prevent duplicate calls.  */

..., however: 'conv_function_val' is not always called here, and
therefore 'is_builtin' not always initialized, giving rise to
PR117136 "[15 regression] ICE for gfortran.dg/typebound_operator_11.f90 since r15-4298-g3269a722b7a036".
Based on Harald's analysis and patch, I've pushed to trunk branch
commit fa90febea9801d4255bf6a1e9f0fd998629c3c7c
"Fortran: Use OpenACC's acc_on_device builtin, fix OpenMP' __builtin_is_initial_device: Fix 'is_builtin' initialization",
see attached.


Grüße
 Thomas


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fortran-Use-OpenACC-s-acc_on_device-builtin-fix-Open.patch
Type: text/x-diff
Size: 1425 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/fortran/attachments/20241015/3d50b802/attachment.bin>


More information about the Fortran mailing list