[gcc/devel/omp/gcc-9] backport: re PR fortran/69499 ([F03] ICE-on-invalid on combining select type with wrong statement)

Tobias Burnus burnus@gcc.gnu.org
Thu Mar 5 14:01:00 GMT 2020


https://gcc.gnu.org/g:ccaf5f7bea4b0a34048119b071d9e6540cc8e683

commit ccaf5f7bea4b0a34048119b071d9e6540cc8e683
Author: Steven G. Kargl <kargl@gcc.gnu.org>
Date:   Thu Jun 20 23:39:29 2019 +0000

    backport: re PR fortran/69499 ([F03] ICE-on-invalid on combining select type with wrong statement)
    
    2019-06-20  Steven G. Kargl  <kargl@gcc.gnu.org>
    
    	Backport from mainline
    	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-20  Steven G. Kargl  <kargl@gcc.gnu.org>
    
    	Backport from mainline
    	PR fortran/69499
    	* gfortran.dg/pr69499.f90: New test.
    	* gfortran.dg/module_error_1.f90: Update dg-error string.
    
    From-SVN: r272531

Diff:
---
 gcc/fortran/ChangeLog                        | 7 +++++++
 gcc/fortran/match.c                          | 7 +++++++
 gcc/testsuite/ChangeLog                      | 7 +++++++
 gcc/testsuite/gfortran.dg/module_error_1.f90 | 2 +-
 gcc/testsuite/gfortran.dg/pr69499.f90        | 7 +++++++
 5 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 0395a1a..a7e08d4 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,6 +1,13 @@
 2019-06-20  Steven G. Kargl  <kargl@gcc.gnu.org>
 
 	Backport from mainline
+	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-20  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+	Backport from mainline
 	PR fortran/69398
 	* decl.c (attr_decl): Check for duplicate DIMENSION attribute for a
 	CLASS entity.
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index eba428f..bc780ce 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -6186,6 +6186,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)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f42fe58..5536a17 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,6 +1,13 @@
 2019-06-20  Steven G. Kargl  <kargl@gcc.gnu.org>
 
 	Backport from mainline
+	PR fortran/69499
+	* gfortran.dg/pr69499.f90: New test.
+	* gfortran.dg/module_error_1.f90: Update dg-error string.
+
+2019-06-20  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+	Backport from mainline
 	PR fortran/69398
 	* gfortran.dg/pr69398.f90: New test.
 
diff --git a/gcc/testsuite/gfortran.dg/module_error_1.f90 b/gcc/testsuite/gfortran.dg/module_error_1.f90
index 84decc0..1792be6 100644
--- a/gcc/testsuite/gfortran.dg/module_error_1.f90
+++ b/gcc/testsuite/gfortran.dg/module_error_1.f90
@@ -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
diff --git a/gcc/testsuite/gfortran.dg/pr69499.f90 b/gcc/testsuite/gfortran.dg/pr69499.f90
new file mode 100644
index 0000000..169c6ce
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr69499.f90
@@ -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



More information about the Gcc-cvs mailing list