Commit ea20e8be by Janus Weil

re PR fortran/85088 (improve diagnostic for bad INTENT declaration ('Invalid…

re PR fortran/85088 (improve diagnostic for bad INTENT declaration ('Invalid character in name at'))

2018-06-10  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/85088
	* decl.c (match_attr_spec): Synchronize the DECL_* enum values with the
	INTENT_* values from the enum 'sym_intent'. Call 'match_intent_spec'
	and remove a TODO note.
	* gfortran.h: Add a comment to sym_intent.


2018-06-10  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/85088
	* gfortran.dg/intent_decl_1.f90: New test case.

From-SVN: r261386
parent 3a579cbe
2018-06-10 Janus Weil <janus@gcc.gnu.org>
PR fortran/85088
* decl.c (match_attr_spec): Synchronize the DECL_* enum values with the
INTENT_* values from the enum 'sym_intent'. Call 'match_intent_spec'
and remove a TODO note.
* gfortran.h: Add a comment to sym_intent.
2018-06-09 Steven G. Kargl <kargl@gcc.gnu.org> 2018-06-09 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/38351 PR fortran/38351
......
...@@ -4726,9 +4726,10 @@ match_attr_spec (void) ...@@ -4726,9 +4726,10 @@ match_attr_spec (void)
{ {
/* Modifiers that can exist in a type statement. */ /* Modifiers that can exist in a type statement. */
enum enum
{ GFC_DECL_BEGIN = 0, { GFC_DECL_BEGIN = 0, DECL_ALLOCATABLE = GFC_DECL_BEGIN,
DECL_ALLOCATABLE = GFC_DECL_BEGIN, DECL_DIMENSION, DECL_EXTERNAL, DECL_IN = INTENT_IN, DECL_OUT = INTENT_OUT, DECL_INOUT = INTENT_INOUT,
DECL_IN, DECL_OUT, DECL_INOUT, DECL_INTRINSIC, DECL_OPTIONAL, DECL_DIMENSION, DECL_EXTERNAL,
DECL_INTRINSIC, DECL_OPTIONAL,
DECL_PARAMETER, DECL_POINTER, DECL_PROTECTED, DECL_PRIVATE, DECL_PARAMETER, DECL_POINTER, DECL_PROTECTED, DECL_PRIVATE,
DECL_STATIC, DECL_AUTOMATIC, DECL_STATIC, DECL_AUTOMATIC,
DECL_PUBLIC, DECL_SAVE, DECL_TARGET, DECL_VALUE, DECL_VOLATILE, DECL_PUBLIC, DECL_SAVE, DECL_TARGET, DECL_VALUE, DECL_VOLATILE,
...@@ -4739,6 +4740,9 @@ match_attr_spec (void) ...@@ -4739,6 +4740,9 @@ match_attr_spec (void)
/* GFC_DECL_END is the sentinel, index starts at 0. */ /* GFC_DECL_END is the sentinel, index starts at 0. */
#define NUM_DECL GFC_DECL_END #define NUM_DECL GFC_DECL_END
/* Make sure that values from sym_intent are safe to be used here. */
gcc_assert (INTENT_IN > 0);
locus start, seen_at[NUM_DECL]; locus start, seen_at[NUM_DECL];
int seen[NUM_DECL]; int seen[NUM_DECL];
unsigned int d; unsigned int d;
...@@ -4856,13 +4860,12 @@ match_attr_spec (void) ...@@ -4856,13 +4860,12 @@ match_attr_spec (void)
if (match_string_p ("nt")) if (match_string_p ("nt"))
{ {
/* Matched "intent". */ /* Matched "intent". */
/* TODO: Call match_intent_spec from here. */ d = match_intent_spec ();
if (gfc_match (" ( in out )") == MATCH_YES) if (d == INTENT_UNKNOWN)
d = DECL_INOUT; {
else if (gfc_match (" ( in )") == MATCH_YES) m = MATCH_ERROR;
d = DECL_IN; goto cleanup;
else if (gfc_match (" ( out )") == MATCH_YES) }
d = DECL_OUT;
} }
} }
else if (ch == 'r') else if (ch == 'r')
......
...@@ -291,7 +291,8 @@ enum procedure_type ...@@ -291,7 +291,8 @@ enum procedure_type
PROC_INTRINSIC, PROC_ST_FUNCTION, PROC_EXTERNAL PROC_INTRINSIC, PROC_ST_FUNCTION, PROC_EXTERNAL
}; };
/* Intent types. */ /* Intent types. Note that these values are also used in another enum in
decl.c (match_attr_spec). */
enum sym_intent enum sym_intent
{ INTENT_UNKNOWN = 0, INTENT_IN, INTENT_OUT, INTENT_INOUT { INTENT_UNKNOWN = 0, INTENT_IN, INTENT_OUT, INTENT_INOUT
}; };
......
2018-06-10 Janus Weil <janus@gcc.gnu.org>
PR fortran/85088
* gfortran.dg/intent_decl_1.f90: New test case.
2018-06-09 Steven G. Kargl <kargl@gcc.gnu.org> 2018-06-09 Steven G. Kargl <kargl@gcc.gnu.org>
* gfortran.dg/ieee/ieee_4.f90: xfail on i?86-*-freebsd* * gfortran.dg/ieee/ieee_4.f90: xfail on i?86-*-freebsd*
......
! { dg-do compile }
!
! PR 85088: improve diagnostic for bad INTENT declaration
!
! Contributed by Janus Weil <janus@gcc.gnu.org>
subroutine s(x, y, z)
integer, intent(int) :: x ! { dg-error "Bad INTENT specification" }
integer, intent :: y ! { dg-error "Bad INTENT specification" }
integer, inten :: z ! { dg-error "Invalid character" }
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment