From 96010094bdf67de48831fd1c6b3e96bf3da93aa5 Mon Sep 17 00:00:00 2001 From: pault <pault@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Sun, 14 Aug 2005 16:15:40 +0000 Subject: [PATCH] 2005-08-14 Paul Thomas <pault@gcc.gnu.org> PR fortran/21432. * io.c (match_io): Add code to implement PRINT namelist. 2005-08-14 Paul Thomas <pault@gcc.gnu.org> PR fortran/21432. * gfortran.dg/namelist_print_1.f: New test of functionality of PRINT namelist. * gfortran.dg/namelist_print_2.f: New test to check that PRINT namelist generates error with -std=f95. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@103079 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 5 ++++ gcc/fortran/io.c | 24 ++++++++++++++++++++ gcc/testsuite/ChangeLog | 8 +++++++ gcc/testsuite/gfortran.dg/namelist_print_1.f | 13 +++++++++++ gcc/testsuite/gfortran.dg/namelist_print_2.f | 13 +++++++++++ 5 files changed, 63 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/namelist_print_1.f create mode 100644 gcc/testsuite/gfortran.dg/namelist_print_2.f diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 158123a2143e..152ab005eefd 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2005-08-14 Paul Thomas <pault@gcc.gnu.org> + + PR fortran/21432. + * io.c (match_io): Add code to implement PRINT namelist. + 2005-08-14 Canqun Yang <canqun@nudt.edu.cn> * trans-stmt.c (gfc_trans_arithmetic_if): Optimized in case of equal diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 78899aa8453f..5b27eadc5443 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -2133,6 +2133,30 @@ match_io (io_kind k) if (gfc_match_char ('(') == MATCH_NO) { + /* Treat the non-standard case of PRINT namelist. */ + if (k == M_PRINT && (gfc_match_name (name) == MATCH_YES) + && !gfc_find_symbol (name, NULL, 1, &sym) + && (sym->attr.flavor == FL_NAMELIST)) + { + if (gfc_notify_std (GFC_STD_GNU, "PRINT namelist at " + "%C is an extension") == FAILURE) + { + m = MATCH_ERROR; + goto cleanup; + } + if (gfc_match_eos () == MATCH_NO) + { + gfc_error ("Namelist followed by I/O list at %C"); + m = MATCH_ERROR; + goto cleanup; + } + + dt->io_unit = default_unit (k); + dt->namelist = sym; + goto get_io_list; + } + + if (k == M_WRITE) goto syntax; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 482d19649fbf..b11e726d68dc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2005-08-14 Paul Thomas <pault@gcc.gnu.org> + + PR fortran/21432. + * gfortran.dg/namelist_print_1.f: New test of functionality of + PRINT namelist. + * gfortran.dg/namelist_print_2.f: New test to check that PRINT + namelist generates error with -std=f95. + 2005-08-14 Ira Rosen <irar@il.ibm.com> PR tree-optimization/23119 diff --git a/gcc/testsuite/gfortran.dg/namelist_print_1.f b/gcc/testsuite/gfortran.dg/namelist_print_1.f new file mode 100644 index 000000000000..dfd2841f0229 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/namelist_print_1.f @@ -0,0 +1,13 @@ +! Test Non standard PRINT namelist - PR21432 +! +! Contributor Paul Thomas <pault@gcc.gnu.org> +! +! { dg-do run } +! { dg-options "-std=gnu" } + + real x + namelist /mynml/ x + x = 1 +! ( dg-output "^" } + print mynml ! { dg-output "&MYNML(\n|\r\n|\r) X= 1.000000 , /(\n|\r\n|\r)" } + end diff --git a/gcc/testsuite/gfortran.dg/namelist_print_2.f b/gcc/testsuite/gfortran.dg/namelist_print_2.f new file mode 100644 index 000000000000..c37e3591d17f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/namelist_print_2.f @@ -0,0 +1,13 @@ +! Test Non standard PRINT namelist - PR21432 is +! not accepted by -std=f95 +! +! Contributor Paul Thomas <pault@gcc.gnu.org> +! +! { dg-do compile } +! { dg-options "-std=f95" } +! + real x + namelist /mynml/ x + x = 1 + print mynml ! { dg-error "PRINT namelist.*extension" "" } + end -- GitLab