OSDN Git Service

2010-05-10 Janus Weil <janus@gcc.gnu.org>
authorjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 10 May 2010 12:54:25 +0000 (12:54 +0000)
committerMasaki Muranaka <monaka@monami-software.com>
Sun, 23 May 2010 05:04:17 +0000 (14:04 +0900)
PR fortran/44044
* match.c (gfc_match_select_type): Move error message to
resolve_select_type.
* resolve.c (resolve_select_type): Error message moved here from
gfc_match_select_type. Correctly set type of temporary.

2010-05-10  Janus Weil  <janus@gcc.gnu.org>

PR fortran/44044
* gfortran.dg/class_7.f03: Modified.
* gfortran.dg/select_type_1.f03: Modified.
* gfortran.dg/select_type_12.f03: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159217 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/match.c
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog

index 2b488fc..d168a3b 100644 (file)
@@ -1,3 +1,11 @@
+2010-05-10  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/44044
+       * match.c (gfc_match_select_type): Move error message to
+       resolve_select_type.
+       * resolve.c (resolve_select_type): Error message moved here from
+       gfc_match_select_type. Correctly set type of temporary.
+
 2010-05-10  Richard Guenther  <rguenther@suse.de>
 
        * trans-decl.c (gfc_build_library_function_decl): Split out
index 5f25e96..3dfe088 100644 (file)
@@ -4314,7 +4314,10 @@ gfc_match_select_type (void)
       expr1->expr_type = EXPR_VARIABLE;
       if (gfc_get_sym_tree (name, NULL, &expr1->symtree, false))
        return MATCH_ERROR;
-      expr1->symtree->n.sym->ts = expr2->ts;
+      if (expr2->ts.type == BT_UNKNOWN)
+       expr1->symtree->n.sym->attr.untyped = 1;
+      else
+       expr1->symtree->n.sym->ts = expr2->ts;
       expr1->symtree->n.sym->attr.referenced = 1;
       expr1->symtree->n.sym->attr.class_ok = 1;
     }
@@ -4337,14 +4340,6 @@ gfc_match_select_type (void)
       return MATCH_ERROR;
     }
 
-  /* Check for F03:C813.  */
-  if (expr1->ts.type != BT_CLASS && !(expr2 && expr2->ts.type == BT_CLASS))
-    {
-      gfc_error ("Selector shall be polymorphic in SELECT TYPE statement "
-                "at %C");
-      return MATCH_ERROR;
-    }
-
   new_st.op = EXEC_SELECT_TYPE;
   new_st.expr1 = expr1;
   new_st.expr2 = expr2;
index 9852af8..5afb08d 100644 (file)
@@ -7078,8 +7078,21 @@ resolve_select_type (gfc_code *code)
   ns = code->ext.ns;
   gfc_resolve (ns);
 
+  /* Check for F03:C813.  */
+  if (code->expr1->ts.type != BT_CLASS
+      && !(code->expr2 && code->expr2->ts.type == BT_CLASS))
+    {
+      gfc_error ("Selector shall be polymorphic in SELECT TYPE statement "
+                "at %L", &code->loc);
+      return;
+    }
+
   if (code->expr2)
-    selector_type = code->expr2->ts.u.derived->components->ts.u.derived;
+    {
+      if (code->expr1->symtree->n.sym->attr.untyped)
+       code->expr1->symtree->n.sym->ts = code->expr2->ts;
+      selector_type = code->expr2->ts.u.derived->components->ts.u.derived;
+    }
   else
     selector_type = code->expr1->ts.u.derived->components->ts.u.derived;
 
index 3fc7164..e9ab06a 100644 (file)
@@ -1,3 +1,10 @@
+2010-05-10  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/44044
+       * gfortran.dg/class_7.f03: Modified.
+       * gfortran.dg/select_type_1.f03: Modified.
+       * gfortran.dg/select_type_12.f03: New.
+
 2010-05-10  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/44050