From 162b5a21add6f291f4c57cc14e2c2e915cb2029c Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Thu, 2 Jun 2011 17:39:11 +0000 Subject: [PATCH] re PR fortran/49265 (Double colon in procedure-stmt (generic interface)) 2011-06-02 Steven G. Kargl PR fortran/49265 * decl.c (gfc_match_modproc): Allow for a double colon in a module procedure statement. * parse.c ( decode_statement): Deal with whitespace around :: in gfc_match_modproc. 2011-06-02 Steven G. Kargl PR fortran/49265 * gfortran.dg/module_procedure_double_colon_1.f90: New test. * gfortran.dg/module_procedure_double_colon_2.f90: New test. From-SVN: r174569 --- gcc/fortran/ChangeLog | 8 ++++++++ gcc/fortran/decl.c | 17 ++++++++++++++- gcc/fortran/parse.c | 2 +- gcc/testsuite/ChangeLog | 6 ++++++ .../module_procedure_double_colon_1.f90 | 23 +++++++++++++++++++++ .../module_procedure_double_colon_2.f90 | 24 ++++++++++++++++++++++ 6 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/module_procedure_double_colon_1.f90 create mode 100644 gcc/testsuite/gfortran.dg/module_procedure_double_colon_2.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c24489b..e7b567e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2011-06-02 Steven G. Kargl + + PR fortran/49265 + * decl.c (gfc_match_modproc): Allow for a double colon in a module + procedure statement. + * parse.c ( decode_statement): Deal with whitespace around :: in + gfc_match_modproc. + 2011-05-31 Tobias Burnus PR fortran/18918 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index e97168f..f914156 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -7016,6 +7016,7 @@ gfc_match_modproc (void) char name[GFC_MAX_SYMBOL_LEN + 1]; gfc_symbol *sym; match m; + locus old_locus; gfc_namespace *module_ns; gfc_interface *old_interface_head, *interface; @@ -7044,10 +7045,23 @@ gfc_match_modproc (void) end up with a syntax error and need to recover. */ old_interface_head = gfc_current_interface_head (); + /* Check if the F2008 optional double colon appears. */ + gfc_gobble_whitespace (); + old_locus = gfc_current_locus; + if (gfc_match ("::") == MATCH_YES) + { + if (gfc_notify_std (GFC_STD_F2008, "Fortran 2008: double colon in " + "MODULE PROCEDURE statement at %L", &old_locus) + == FAILURE) + return MATCH_ERROR; + } + else + gfc_current_locus = old_locus; + for (;;) { - locus old_locus = gfc_current_locus; bool last = false; + old_locus = gfc_current_locus; m = gfc_match_name (name); if (m == MATCH_NO) @@ -7059,6 +7073,7 @@ gfc_match_modproc (void) current namespace. */ if (gfc_match_eos () == MATCH_YES) last = true; + if (!last && gfc_match_char (',') != MATCH_YES) goto syntax; diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 80fcf00..a47b457 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -399,7 +399,7 @@ decode_statement (void) break; case 'm': - match ("module% procedure% ", gfc_match_modproc, ST_MODULE_PROC); + match ("module% procedure", gfc_match_modproc, ST_MODULE_PROC); match ("module", gfc_match_module, ST_MODULE); break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 61d8fde..18d03ed 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-06-02 Steven G. Kargl + + PR fortran/49265 + * gfortran.dg/module_procedure_double_colon_1.f90: New test. + * gfortran.dg/module_procedure_double_colon_2.f90: New test. + 2011-06-02 Eric Botcazou Hans-Peter Nilsson diff --git a/gcc/testsuite/gfortran.dg/module_procedure_double_colon_1.f90 b/gcc/testsuite/gfortran.dg/module_procedure_double_colon_1.f90 new file mode 100644 index 0000000..200f0ff --- /dev/null +++ b/gcc/testsuite/gfortran.dg/module_procedure_double_colon_1.f90 @@ -0,0 +1,23 @@ +! { dg-do compile } +! +! PR fortran/49265 +! Contributed by Erik Toussaint +! +module m1 + implicit none + interface foo + module procedure::bar + module procedure ::bar_none + module procedure:: none_bar + end interface +contains + subroutine bar + end subroutine + subroutine bar_none(i) + integer i + end subroutine + subroutine none_bar(x) + real x + end subroutine +end module +! { dg-final { cleanup-modules "m1" } } diff --git a/gcc/testsuite/gfortran.dg/module_procedure_double_colon_2.f90 b/gcc/testsuite/gfortran.dg/module_procedure_double_colon_2.f90 new file mode 100644 index 0000000..9300215 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/module_procedure_double_colon_2.f90 @@ -0,0 +1,24 @@ +! { dg-do compile } +! { dg-options "-std=f95" } +! +! PR fortran/49265 +! Contributed by Erik Toussaint +! +module m1 + implicit none + interface foo + module procedure::bar ! { dg-error "double colon" } + module procedure ::bar_none ! { dg-error "double colon" } + module procedure:: none_bar ! { dg-error "double colon" } + end interface +contains + subroutine bar + end subroutine + subroutine bar_none(i) + integer i + end subroutine + subroutine none_bar(x) + real x + end subroutine +end module +! { dg-final { cleanup-modules "m1" } } -- 2.7.4