* [Committed] PR fortran/69499 -- SELECT TYPE is executable statement
@ 2019-06-19 18:52 Steve Kargl
0 siblings, 0 replies; only message in thread
From: Steve Kargl @ 2019-06-19 18:52 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 528 bytes --]
I have committed the attach patch. It checks that
a SELECT TYPE construct does not appear in MODULE
or SUBMODULE scope as it is an executable statement.
2019-06-19 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/69499
* match.c (gfc_match_select_type): SELECT TYPE is an executable
statement, and cannot appear in MODULE or SUBMODULE scope.
2019-06-19 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/69499
* gfortran.dg/pr69499.f90: New test.
* gfortran.dg/module_error_1.f90: Update dg-error string.
--
Steve
[-- Attachment #2: pr69499.diff --]
[-- Type: text/x-diff, Size: 1550 bytes --]
Index: gcc/fortran/match.c
===================================================================
--- gcc/fortran/match.c (revision 272480)
+++ gcc/fortran/match.c (working copy)
@@ -6219,6 +6219,13 @@ gfc_match_select_type (void)
if (m != MATCH_YES)
return m;
+ if (gfc_current_state() == COMP_MODULE
+ || gfc_current_state() == COMP_SUBMODULE)
+ {
+ gfc_error ("SELECT TYPE at %C cannot appear in this scope");
+ return MATCH_ERROR;
+ }
+
gfc_current_ns = gfc_build_block_ns (ns);
m = gfc_match (" %n => %e", name, &expr2);
if (m == MATCH_YES)
Index: gcc/testsuite/gfortran.dg/pr69499.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr69499.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr69499.f90 (working copy)
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! PR fortran/69499
+! Contributed by Gerhard Steinmetz.
+module m
+ class(*) :: z ! { dg-error "must be dummy, allocatable or pointer" }
+ select type (x => z) ! { dg-error "cannot appear in this scope" }
+end
Index: gcc/testsuite/gfortran.dg/module_error_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/module_error_1.f90 (revision 272480)
+++ gcc/testsuite/gfortran.dg/module_error_1.f90 (working copy)
@@ -1,5 +1,5 @@
! { dg-do compile }
! PR fortran/50627
module kernels
- select type (args) ! { dg-error "Unexpected SELECT TYPE" }
+ select type (args) ! { dg-error "cannot appear in this scope" }
end module kernels
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-06-19 18:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-19 18:52 [Committed] PR fortran/69499 -- SELECT TYPE is executable statement Steve Kargl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).