Blame SOURCES/0012-Allow-old-style-initializers-in-derived-types.patch

3db796
From 5d5a6c9d8c5a8db252d972ec32dd70d2510404fb Mon Sep 17 00:00:00 2001
3db796
From: Jim MacArthur <jim.macarthur@codethink.co.uk>
3db796
Date: Thu, 4 Feb 2016 16:00:30 +0000
3db796
Subject: [PATCH 12/23] Allow old-style initializers in derived types
3db796
3db796
This allows simple declarations in derived types and structures, such as:
3db796
    LOGICAL*1      NIL      /0/
3db796
Only single value expressions are allowed at the moment.
3db796
3db796
This feature is enabled by the `-std=extra-legacy` compiler flag.
3db796
---
3db796
3db796
       0012-Allow-old-style-initializers-in-derived-types.patch
3db796
    
3db796
        Drop unnecessary whitespace
3db796
3db796
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
3db796
index c90f9de..3ad9c2c 100644
3db796
--- a/gcc/fortran/decl.c
3db796
+++ b/gcc/fortran/decl.c
3db796
@@ -2437,12 +2437,30 @@ variable_decl (int elem)
3db796
          but not components of derived types.  */
3db796
       else if (gfc_current_state () == COMP_DERIVED)
3db796
 	{
3db796
-	  gfc_error ("Invalid old style initialization for derived type "
3db796
-		     "component at %C");
3db796
-	  m = MATCH_ERROR;
3db796
-	  goto cleanup;
3db796
-	}
3db796
+	  if (gfc_option.allow_std & GFC_STD_EXTRA_LEGACY)
3db796
+	    {
3db796
+	      /* Attempt to match an old-style initializer which is a simple
3db796
+		 integer or character expression; this will not work with
3db796
+		 multiple values. */
3db796
+	      m = gfc_match_init_expr (&initializer);
3db796
+	      if (m == MATCH_ERROR)
3db796
+		goto cleanup;
3db796
+	      else if (m == MATCH_YES)
3db796
+		{
3db796
+		  m = gfc_match ("/");
3db796
+		  if (m != MATCH_YES)
3db796
+		    goto cleanup;
3db796
+		}
3db796
+	    }
3db796
+	  else
3db796
 
3db796
+	    {
3db796
+	      gfc_error ("Invalid old style initialization for derived type "
3db796
+			 "component at %C");
3db796
+	      m = MATCH_ERROR;
3db796
+	      goto cleanup;
3db796
+	    }
3db796
+	}
3db796
       /* For structure components, read the initializer as a special
3db796
          expression and let the rest of this function apply the initializer
3db796
          as usual.  */