decl.c (gfc_match_derived_decl): Dummy argument cannot be a derived type.
authorSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 15 Jun 2019 22:10:54 +0000 (22:10 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 15 Jun 2019 22:10:54 +0000 (22:10 +0000)
2019-06-15  Steven G. Kargl  <kargl@gcc.gnu.org>

* decl.c (gfc_match_derived_decl): Dummy argument cannot be a derived
 type.

2019-06-15  Steven G. Kargl  <kargl@gcc.gnu.org>

* gfortran.dg/dummy_derived_typed.f90: New test.

From-SVN: r272333

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/dummy_derived_typed.f90 [new file with mode: 0644]

index ddb2353..921a6fc 100644 (file)
@@ -1,3 +1,8 @@
+2019-06-15  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       * decl.c (gfc_match_derived_decl): Dummy argument cannot be a derived
+       type.
+
 2019-06-14  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        * arith.c (arith_power): Rework overflow of an integer to an integer
index 1c785a4..5fc06e4 100644 (file)
@@ -10193,6 +10193,13 @@ gfc_match_derived_decl (void)
       && !gfc_add_function (&gensym->attr, gensym->name, NULL))
     return MATCH_ERROR;
 
+  if (gensym->attr.dummy)
+    {
+      gfc_error ("Dummy argument %qs at %L cannot be a derived type at %C",
+                name, &gensym->declared_at);
+      return MATCH_ERROR;
+    }
+
   sym = gfc_find_dt_in_generic (gensym);
 
   if (sym && (sym->components != NULL || sym->attr.zero_comp))
index 411d496..3a1a1e7 100644 (file)
@@ -1,3 +1,7 @@
+2019-06-15  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       * gfortran.dg/dummy_derived_typed.f90: New test.
+
 2019-06-15  Jan Hubicka  <hubicka@ucw.cz>
 
        * gcc.dg/tree-ssa/alias-access-path-2.c: New testcase.
diff --git a/gcc/testsuite/gfortran.dg/dummy_derived_typed.f90 b/gcc/testsuite/gfortran.dg/dummy_derived_typed.f90
new file mode 100644 (file)
index 0000000..5c9b3ca
--- /dev/null
@@ -0,0 +1,5 @@
+! { dg-do compile }
+subroutine s(t)   ! { dg-error "Dummy argument" }
+   type t         ! { dg-error "cannot be a derived" }
+   end type       ! { dg-error "Expecting END SUBROUTINE" }
+end