* [Committed] PR fortran/88269 -- Check for missing UNIT/NEWUNIT
@ 2018-12-10 20:05 Steve Kargl
0 siblings, 0 replies; only message in thread
From: Steve Kargl @ 2018-12-10 20:05 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 526 bytes --]
The attach patch has been coommitted to 7-branch, 8-branch,
and trunk after successful regression testing.
2018-12-10 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/88269
* io.c (io_constraint): Update macro. If locus line buffer is NULL,
use gfc_current_locus in error messages.
(check_io_constraints): Catch missing IO UNIT in write and read
statements. io_constraint macro is incompatible here.
2018-12-10 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/88269
* gfortran.dg/pr88269.f90: New test.
--
Steve
[-- Attachment #2: pr88269.diff --]
[-- Type: text/x-diff, Size: 1470 bytes --]
Index: gcc/fortran/io.c
===================================================================
--- gcc/fortran/io.c (revision 266958)
+++ gcc/fortran/io.c (working copy)
@@ -3678,10 +3678,13 @@ static match
check_io_constraints (io_kind k, gfc_dt *dt, gfc_code *io_code,
locus *spec_end)
{
-#define io_constraint(condition,msg,arg)\
+#define io_constraint(condition, msg, arg)\
if (condition) \
{\
- gfc_error(msg,arg);\
+ if ((arg)->lb != NULL)\
+ gfc_error ((msg), (arg));\
+ else\
+ gfc_error ((msg), &gfc_current_locus);\
m = MATCH_ERROR;\
}
@@ -3741,11 +3744,14 @@ if (condition) \
if (expr && expr->ts.type != BT_CHARACTER)
{
- io_constraint (gfc_pure (NULL) && (k == M_READ || k == M_WRITE),
- "IO UNIT in %s statement at %C must be "
+ if (gfc_pure (NULL) && (k == M_READ || k == M_WRITE))
+ {
+ gfc_error ("IO UNIT in %s statement at %C must be "
"an internal file in a PURE procedure",
io_kind_name (k));
-
+ return MATCH_ERROR;
+ }
+
if (k == M_READ || k == M_WRITE)
gfc_unset_implicit_pure (NULL);
}
Index: gcc/testsuite/gfortran.dg/pr88269.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr88269.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr88269.f90 (working copy)
@@ -0,0 +1,6 @@
+! { dg-do compile }
+! PR fortran/88269
+program p
+ write (end=1e1) ! { dg-error "tag not allowed" }
+end
+
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-12-10 20:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-10 20:05 [Committed] PR fortran/88269 -- Check for missing UNIT/NEWUNIT 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).