User account creation filtered due to spam.

Bug 41579 - [OOP] Nesting of SELECT TYPE
Summary: [OOP] Nesting of SELECT TYPE
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 4.5.0
Assignee: janus
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2009-10-05 12:38 UTC by Tobias Burnus
Modified: 2016-11-16 12:06 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-10-08 20:27:58


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2009-10-05 12:38:49 UTC
See review comment http://gcc.gnu.org/ml/fortran/2009-09/msg00298.html

For two longer test cases, see 
http://gcc.gnu.org/ml/fortran/2009-09/msg00295.html


Currently, SELECT TYPE(type) uses:

+  /* Special case: If we're in a SELECT TYPE block,
+     replace the selector variable by a temporary.  */
+  if (gfc_current_state () == COMP_SELECT_TYPE
+      && st && st->n.sym == type_selector)
+    st = select_type_tmp;
+

That fails
(a) If the current state is not COMP_SELECT_TYPE
(b) If one nests SELECT TYPE

Example:

select type (mt2)
  type is(t2)
    mt2%i = 5
    select type(mt3)
      type is(t3)
        mt3%j = mt2%i
      class default
        stop 'error'
    end select
  class default
    stop 'error'
end select

        mt3%j = mt2%i
                     1
Error: 'i' at (1) is not a member of the 't1' structure
Comment 1 janus 2009-10-08 20:27:58 UTC
Mine (have a patch).
Comment 2 janus 2009-10-09 20:25:33 UTC
Subject: Bug 41579

Author: janus
Date: Fri Oct  9 20:25:19 2009
New Revision: 152600

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=152600
Log:
2009-10-09  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/41579
	* gfortran.h (gfc_select_type_stack): New struct, to be used as a stack
	for SELECT TYPE statements.
	(select_type_stack): New global variable.
	(type_selector,select_type_tmp): Removed.
	* match.c (type_selector,type_selector): Removed.
	(select_type_stack): New variable, serving as a stack for
	SELECT TYPE statements.
	(select_type_push,select_type_set_tmp): New functions.
	(gfc_match_select_type): Call select_type_push.
	(gfc_match_type_is): Call select_type_set_tmp.
	* parse.c (select_type_pop): New function.
	(parse_select_type_block): Call select_type_pop.
	* symbol.c (select_type_insert_tmp): New function.
	(gfc_find_sym_tree): Call select_type_insert_tmp.


2009-10-09  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/41579
	* gfortran.dg/select_type_6.f03: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/select_type_6.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/match.c
    trunk/gcc/fortran/parse.c
    trunk/gcc/fortran/symbol.c
    trunk/gcc/testsuite/ChangeLog

Comment 3 janus 2009-10-09 20:31:54 UTC
Fixed with r152600. Closing.