Commit 0e521c64 by Steven G. Kargl

re PR fortran/91660 (Missing error on invalid type declaration)

2019-09-05  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/91660
	* decl.c (gfc_match_decl_type_spec): Improve and restore error
	message for malformed types-spec.

2019-09-05  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/91660
	* gfortran.dg/pdt_4.f03: Fix invalid code.
	* gfortran.dg/pr91660_1.f90: New test.
	* gfortran.dg/pr91660_2.f90: Ditto.

From-SVN: r275426
parent bb64bef6
2019-09-05 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/91660
* decl.c (gfc_match_decl_type_spec): Improve and restore error
message for malformed types-spec.
2019-09-04 Steven G. Kargl <kargl@gcvc.gnu.org> 2019-09-04 Steven G. Kargl <kargl@gcvc.gnu.org>
PR fortran/91650 PR fortran/91650
......
...@@ -4023,7 +4023,6 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag) ...@@ -4023,7 +4023,6 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag)
return MATCH_YES; return MATCH_YES;
} }
m = gfc_match (" type ("); m = gfc_match (" type (");
matched_type = (m == MATCH_YES); matched_type = (m == MATCH_YES);
if (matched_type) if (matched_type)
...@@ -4071,7 +4070,10 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag) ...@@ -4071,7 +4070,10 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag)
m = MATCH_YES; m = MATCH_YES;
if (matched_type && m == MATCH_YES && gfc_match_char (')') != MATCH_YES) if (matched_type && m == MATCH_YES && gfc_match_char (')') != MATCH_YES)
m = MATCH_ERROR; {
gfc_error ("Malformed type-spec at %C");
return MATCH_ERROR;
}
return m; return m;
} }
...@@ -4094,8 +4096,12 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag) ...@@ -4094,8 +4096,12 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag)
&& !gfc_notify_std (GFC_STD_F2008, "TYPE with " && !gfc_notify_std (GFC_STD_F2008, "TYPE with "
"intrinsic-type-spec at %C")) "intrinsic-type-spec at %C"))
return MATCH_ERROR; return MATCH_ERROR;
if (matched_type && gfc_match_char (')') != MATCH_YES) if (matched_type && gfc_match_char (')') != MATCH_YES)
return MATCH_ERROR; {
gfc_error ("Malformed type-spec at %C");
return MATCH_ERROR;
}
ts->type = BT_REAL; ts->type = BT_REAL;
ts->kind = gfc_default_double_kind; ts->kind = gfc_default_double_kind;
...@@ -4125,7 +4131,10 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag) ...@@ -4125,7 +4131,10 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag)
return MATCH_ERROR; return MATCH_ERROR;
if (matched_type && gfc_match_char (')') != MATCH_YES) if (matched_type && gfc_match_char (')') != MATCH_YES)
return MATCH_ERROR; {
gfc_error ("Malformed type-spec at %C");
return MATCH_ERROR;
}
ts->type = BT_COMPLEX; ts->type = BT_COMPLEX;
ts->kind = gfc_default_double_kind; ts->kind = gfc_default_double_kind;
...@@ -4146,7 +4155,13 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag) ...@@ -4146,7 +4155,13 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag)
if (m == MATCH_ERROR) if (m == MATCH_ERROR)
return m; return m;
m = gfc_match_char (')'); gfc_gobble_whitespace ();
if (gfc_peek_ascii_char () != ')')
{
gfc_error ("Malformed type-spec at %C");
return MATCH_ERROR;
}
m = gfc_match_char (')'); /* Burn closing ')'. */
} }
if (m != MATCH_YES) if (m != MATCH_YES)
......
2019-09-05 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/91660
* gfortran.dg/pdt_4.f03: Fix invalid code.
* gfortran.dg/pr91660_1.f90: New test.
* gfortran.dg/pr91660_2.f90: Ditto.
2019-09-05 Marek Polacek <polacek@redhat.com> 2019-09-05 Marek Polacek <polacek@redhat.com>
PR c++/91644 - ICE with constinit in function template. PR c++/91644 - ICE with constinit in function template.
......
...@@ -97,9 +97,9 @@ contains ...@@ -97,9 +97,9 @@ contains
type (mytype(4, *)) :: arg ! OK type (mytype(4, *)) :: arg ! OK
end subroutine end subroutine
subroutine bar(arg) ! { dg-error "is neither allocatable nor a pointer" } subroutine bar(arg) ! { dg-error "is neither allocatable nor a pointer" }
type (thytype(8, :, 4) :: arg type (thytype(8, :, 4)) :: arg
end subroutine end subroutine
subroutine foobar(arg) ! OK subroutine foobar(arg) ! OK
type (thytype(8, *, 4) :: arg type (thytype(8, *, 4)) :: arg
end subroutine end subroutine
end end
! { dg-do compile }
! PR fortran/91660
! Code contributed by Gerhard Steinmetz
program p
type t
end type
type (t x ! { dg-error "Malformed type-spec" }
x = t() ! { dg-error "Cannot convert" }
end
! { dg-do compile }
! PR fortran/91660
program foo
type(doubleprecision :: x ! { dg-error "Malformed type-spec" }
type(double precision :: y ! { dg-error "Malformed type-spec" }
type(character(len=3) :: a ! { dg-error "Malformed type-spec" }
type(doublecomplex :: b ! { dg-error "Malformed type-spec" }
type(double complex :: c ! { dg-error "Malformed type-spec" }
end program foo
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