@@ -4191,30 +4191,36 @@ gfc_get_pdt_instance (gfc_actual_arglist *param_list, gfc_symbol **sym,
41914191 to obtain the instance of the extended type. */
41924192 if (gfc_current_state () != COMP_DERIVED
41934193 && c1 == pdt->components
4194- && ( c1->ts .type == BT_DERIVED || c1-> ts . type == BT_CLASS)
4195- && c1->ts .u .derived && c1-> ts . u . derived -> attr . pdt_template
4194+ && c1->ts .type == BT_DERIVED
4195+ && c1->ts .u .derived
41964196 && gfc_get_derived_super_type (*sym) == c2->ts .u .derived )
41974197 {
4198- gfc_formal_arglist *f;
4198+ if (c1->ts .u .derived ->attr .pdt_template )
4199+ {
4200+ gfc_formal_arglist *f;
41994201
4200- old_param_spec_list = type_param_spec_list;
4202+ old_param_spec_list = type_param_spec_list;
42014203
4202- /* Obtain a spec list appropriate to the extended type..*/
4203- actual_param = gfc_copy_actual_arglist (type_param_spec_list);
4204- type_param_spec_list = actual_param;
4205- for (f = c1->ts .u .derived ->formal ; f && f->next ; f = f->next )
4206- actual_param = actual_param->next ;
4207- if (actual_param)
4208- {
4209- gfc_free_actual_arglist (actual_param->next );
4210- actual_param->next = NULL ;
4211- }
4204+ /* Obtain a spec list appropriate to the extended type..*/
4205+ actual_param = gfc_copy_actual_arglist (type_param_spec_list);
4206+ type_param_spec_list = actual_param;
4207+ for (f = c1->ts .u .derived ->formal ; f && f->next ; f = f->next )
4208+ actual_param = actual_param->next ;
4209+ if (actual_param)
4210+ {
4211+ gfc_free_actual_arglist (actual_param->next );
4212+ actual_param->next = NULL ;
4213+ }
42124214
4213- /* Now obtain the PDT instance for the extended type. */
4214- c2->param_list = type_param_spec_list;
4215- m = gfc_get_pdt_instance (type_param_spec_list, &c2->ts .u .derived ,
4216- &c2->param_list );
4217- type_param_spec_list = old_param_spec_list;
4215+ /* Now obtain the PDT instance for the extended type. */
4216+ c2->param_list = type_param_spec_list;
4217+ m = gfc_get_pdt_instance (type_param_spec_list,
4218+ &c2->ts .u .derived ,
4219+ &c2->param_list );
4220+ type_param_spec_list = old_param_spec_list;
4221+ }
4222+ else
4223+ c2->ts = c1->ts ;
42184224
42194225 c2->ts .u .derived ->refs ++;
42204226 gfc_set_sym_referenced (c2->ts .u .derived );
0 commit comments