[gcc(refs/users/mikael/heads/refactor_descriptor_v206 .01)] Vérification type descripteur classe
Mikael Morin via Gcc-cvs <[email protected]>
| Newsgroups | gmane.comp.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://gcc.gnu.org/g:892e514b77594080e41594d89c71c4337e687527 commit 892e514b77594080e41594d89c71c4337e687527 Author: Mikael Morin <[email protected]> Date: Thu Aug 20 12:57:31 2026 +0200 Vérification type descripteur classe Ajout fonction is_class_container_type Diff: --- gcc/fortran/trans-descriptor.cc | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc index 0b6da8d9231c..aee8611982d3 100644 --- a/gcc/fortran/trans-descriptor.cc +++ b/gcc/fortran/trans-descriptor.cc @@ -898,6 +898,27 @@ gfc_set_descriptor_from_scalar (stmtblock_t *block, tree descr, tree scalar) } +/* Return true if TYPE is the type of a class container, or the pointer to such + a type. Otherwise return false. If CLASS_TYPE is not nullptr, set its + target to the class descriptor type in the true case, and leave it unmodified + in the false case. */ + +static bool +is_class_container_type (tree type, tree *class_type = nullptr) +{ + if (POINTER_TYPE_P (type)) + type = TREE_TYPE (type); + if (GFC_CLASS_TYPE_P (type)) + { + if (class_type != nullptr) + *class_type = type; + return true; + } + + return false; +} + + /* Add code to BLOCK initializing the scalar descriptor DESCR, so that it represents the same data as the middle-end scalar class descriptor SCALAR corresponding to the front-end scalar polymorphic expression SCALAR_EXPR. @@ -914,7 +935,9 @@ gfc_set_descriptor_from_scalar_class (stmtblock_t *block, tree descr, : scalar_type; gfc_conv_descriptor_dtype_set (block, descr, gfc_get_dtype_rank_type (0, etype)); - tree tmp = gfc_class_data_get (scalar); + tree tmp = scalar; + if (is_class_container_type (TREE_TYPE (tmp))) + tmp = gfc_class_data_get (tmp); if (!POINTER_TYPE_P (TREE_TYPE (tmp))) tmp = gfc_build_addr_expr (NULL_TREE, tmp);