This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[PATCH(es)] PR fortran/77391 -- RFC vote on which you prefer
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 26 Aug 2016 11:27:55 -0700
- Subject: [PATCH(es)] PR fortran/77391 -- RFC vote on which you prefer
- Authentication-results: sourceware.org; auth=none
Here are two possible patches for PR fortran/77391. The first
patch treats the invalid code as a GNU Fortran extension as
gfortran current accepts the invalid code. The second patch
enforces the standard. As I think gfortran should encourage
standard conformance, I am inclined to commit the second patch.
I will however commit the most popular of the two patches tomorrow.
Voting starts now and will remain open for 24 hours (give or take
a few hours depend on when I awaken).
Patch 1:
Index: decl.c
===================================================================
--- decl.c (revision 239762)
+++ decl.c (working copy)
@@ -4798,11 +4798,23 @@ gfc_match_data_decl (void)
ok:
/* If we have an old-style character declaration, and no new-style
- attribute specifications, then there a comma is optional between
+ attribute specifications, then a comma is optional between
the type specification and the variable list. */
if (m == MATCH_NO && current_ts.type == BT_CHARACTER && old_char_selector)
gfc_match_char (',');
+ /* F2008(C402): A colon shall not be used as a type-param-value except
+ in the declaration of an entity or component that has the POINTER
+ or ALLOCATABLE attribute. */
+ if (current_ts.type == BT_CHARACTER && current_ts.deferred
+ && !(current_attr.allocatable || current_attr.pointer)
+ && !gfc_notify_std (GFC_STD_GNU, "Deferred length type parameter "
+ "without POINTER or ALLOCATABLE attribute at %C"))
+ {
+ m = MATCH_ERROR;
+ goto cleanup;
+ }
+
/* Give the types/attributes to symbols that follow. Give the element
a number so that repeat character length expressions can be copied. */
elem = 1;
Patch 2:
Index: decl.c
===================================================================
--- decl.c (revision 239762)
+++ decl.c (working copy)
@@ -4798,11 +4798,24 @@ gfc_match_data_decl (void)
ok:
/* If we have an old-style character declaration, and no new-style
- attribute specifications, then there a comma is optional between
+ attribute specifications, then a comma is optional between
the type specification and the variable list. */
if (m == MATCH_NO && current_ts.type == BT_CHARACTER && old_char_selector)
gfc_match_char (',');
+ /* F2008(C402): A colon shall not be used as a type-param-value except
+ in the declaration of an entity or component that has the POINTER
+ or ALLOCATABLE attribute. */
+ if (current_ts.type == BT_CHARACTER && current_ts.deferred
+ && !(current_attr.allocatable || current_attr.pointer))
+ {
+
+ gfc_error ("Deferred length type parameter without POINTER or "
+ "ALLOCATABLE attribute at %C")
+ m = MATCH_ERROR;
+ goto cleanup;
+ }
+
/* Give the types/attributes to symbols that follow. Give the element
a number so that repeat character length expressions can be copied. */
elem = 1;
--
Steve