Hi Tobias, I believe the attached patch should be safe to remove now that r16-4474-g2c1949bf152f8f has landed. We can confirm this by checking the codegen: https://godbolt.org/z/fvo1PG3bs. The output for the current trunk shows that the comp is no longer being emitted. Regression tested on x86_64-linux.
* * *
While working on this, I noticed a part of the code that I think we
can simplify:
```
if (TREE_TYPE (TREE_TYPE (new_val)) != TREE_TYPE (TREE_TYPE (old)))
{
tmp = gfc_create_var (TREE_TYPE (TREE_TYPE (old)), "new");
gfc_add_modify (&block, tmp, fold_convert (TREE_TYPE (tmp), new_val));
new_val = gfc_build_addr_expr (NULL_TREE, tmp);
}
```
I suspect this conversion is unnecessary for a couple of reasons:
1. Fortran 2018 and 2023 standards require the new argument to have
the same type and kind.
2. Even with older standards that might have been more lenient (like
possibly 2008), we typically only support one valid kind for different
types: ATOMIC_INT_KIND for integer and ATOMIC_LOGICAL_KIND for
logical.
My plan is to update the documentation to align with the latest
standard, remove this part for the new argument here, and add a check
to reject different kinds during resolving.
Since I'm not entirely 100% sure about this, I think it could be a
seperate patch.
Thanks,
Yuao
0001-fortran-remove-redundant-code-related-to-constant-po.patch
Description: Binary data
