public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PING -- [PATCH, fortran] PR 85982 -- ICE in resolve_component
@ 2020-04-01 17:19 Fritz Reese
  2020-04-01 18:00 ` Fritz Reese
  2020-04-02  7:50 ` Tobias Burnus
  0 siblings, 2 replies; 4+ messages in thread
From: Fritz Reese @ 2020-04-01 17:19 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 609 bytes --]

This simple patch was submitted some time ago (over 1 year), but got
lost without review. I have lately rebased and tested, and the patch
is still good. Is this OK to commit to trunk and for backport? I'd
like to port as far back as 7.

---
Fritz Reese

gcc/ChangeLog:
2020-04-01  Fritz Reese  <foreese@gcc.gnu.org>

       PR fortran/85982
       * fortran/decl.c (match_attr_spec): Lump COMP_STRUCTURE/COMP_MAP into
       attribute checking used by TYPE.

gcc/testsuite/ChangeLog:
2020-04-01  Fritz Reese  <foreese@gcc.gnu.org>

       PR fortran/85982
       * gfortran.dg/dec_structure_28.f90: New test.

[-- Attachment #2: pr85982.patch --]
[-- Type: text/x-patch, Size: 1953 bytes --]

commit 03ade661deaa606b005304814be9f723158ed55f
Author: Fritz Reese <foreese@gcc.gnu.org>
Date:   Fri Mar 20 13:03:42 2020 -0400

    Fix for fortran/85982

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 2f458c4faac..05503b2d3c7 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -5408,15 +5408,18 @@ match_attr_spec (void)
       if (d == DECL_STATIC && seen[DECL_SAVE])
 	continue;
 
-      if (gfc_current_state () == COMP_DERIVED
+      if (gfc_comp_struct (gfc_current_state ())
 	  && d != DECL_DIMENSION && d != DECL_CODIMENSION
 	  && d != DECL_POINTER   && d != DECL_PRIVATE
 	  && d != DECL_PUBLIC && d != DECL_CONTIGUOUS && d != DECL_NONE)
 	{
+	  const char* const state_name = (gfc_current_state () == COMP_DERIVED
+					  ? "TYPE" : "STRUCTURE");
 	  if (d == DECL_ALLOCATABLE)
 	    {
 	      if (!gfc_notify_std (GFC_STD_F2003, "ALLOCATABLE "
-				   "attribute at %C in a TYPE definition"))
+				   "attribute at %C in a %s definition",
+				   state_name))
 		{
 		  m = MATCH_ERROR;
 		  goto cleanup;
@@ -5425,7 +5428,8 @@ match_attr_spec (void)
 	  else if (d == DECL_KIND)
 	    {
 	      if (!gfc_notify_std (GFC_STD_F2003, "KIND "
-				   "attribute at %C in a TYPE definition"))
+				   "attribute at %C in a %s definition",
+				   state_name))
 		{
 		  m = MATCH_ERROR;
 		  goto cleanup;
@@ -5449,7 +5453,8 @@ match_attr_spec (void)
 	  else if (d == DECL_LEN)
 	    {
 	      if (!gfc_notify_std (GFC_STD_F2003, "LEN "
-				   "attribute at %C in a TYPE definition"))
+				   "attribute at %C in a %s definition",
+				   state_name))
 		{
 		  m = MATCH_ERROR;
 		  goto cleanup;
@@ -5472,8 +5477,8 @@ match_attr_spec (void)
 	    }
 	  else
 	    {
-	      gfc_error ("Attribute at %L is not allowed in a TYPE definition",
-			 &seen_at[d]);
+	      gfc_error ("Attribute at %L is not allowed in a %s definition",
+			 &seen_at[d], state_name);
 	      m = MATCH_ERROR;
 	      goto cleanup;
 	    }

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-02 16:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-01 17:19 PING -- [PATCH, fortran] PR 85982 -- ICE in resolve_component Fritz Reese
2020-04-01 18:00 ` Fritz Reese
2020-04-02  7:50 ` Tobias Burnus
2020-04-02 16:20   ` Fritz Reese

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).