]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/91589 (ICE in gfc_conv_component_ref, at fortran/trans-expr.c:2447)
authorPaul Thomas <pault@gcc.gnu.org>
Sat, 7 Sep 2019 14:41:25 +0000 (14:41 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Sat, 7 Sep 2019 14:41:25 +0000 (14:41 +0000)
2019-09-07  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/91589
* primary.c (gfc_match_varspec): Return MATCH_NO on an apparent
component ref, when the primary type is intrinsic.

2019-09-07  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/91589
* gfortran.dg/pr91589.f90 : New test.

From-SVN: r275487

gcc/fortran/ChangeLog
gcc/fortran/primary.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr91589.f90 [new file with mode: 0644]

index 5450a3279b8806d82d735eded9cf0e5bf9426814..d718706e6e4cc20dd4e41ab1085594313995de01 100644 (file)
@@ -1,3 +1,10 @@
+2019-09-07  Paul Thomas  <pault@gcc.gnu.org>
+
+       Backport from mainline
+       PR fortran/91589
+       * primary.c (gfc_match_varspec): Return MATCH_NO on an apparent
+       component ref, when the primary type is intrinsic.
+
 2019-09-05  Harald Anlauf  <anlauf@gmx.de>
 
        Backport from mainline
        PR fortran/90563
        * frontend-passes.c (insert_index): Suppress errors while
        simplifying the resulting expression.
+
 2019-08-13  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/88072
index 4af1db5f4bda81ede57deef0f9976c6769a68878..a69f71acf7e6b87328263b4e78524b261843e679 100644 (file)
@@ -1990,6 +1990,7 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag,
   match m;
   bool unknown;
   bool inquiry;
+  bool intrinsic;
   locus old_loc;
   char sep;
 
@@ -2194,11 +2195,15 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag,
       if (m != MATCH_YES)
        return MATCH_ERROR;
 
+      intrinsic = false;
       if (primary->ts.type != BT_CLASS && primary->ts.type != BT_DERIVED)
        {
          inquiry = is_inquiry_ref (name, &tmp);
          if (inquiry)
            sym = NULL;
+
+         if (sep == '%' && primary->ts.type != BT_UNKNOWN)
+           intrinsic = true;
        }
       else
        inquiry = false;
@@ -2258,12 +2263,16 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag,
          break;
        }
 
-      if (!inquiry)
+      if (!inquiry && !intrinsic)
        component = gfc_find_component (sym, name, false, false, &tmp);
       else
        component = NULL;
 
-      if (component == NULL && !inquiry)
+      /* In some cases, returning MATCH_NO gives a better error message. Most
+        cases return "Unclassifiable statement at..."  */
+      if (intrinsic && !inquiry)
+       return MATCH_NO;
+      else if (component == NULL && !inquiry)
        return MATCH_ERROR;
 
       /* Extend the reference chain determined by gfc_find_component or
index 5e3c22d06301d75ee8693124922ecf7518165002..ce8dd86c4490ee5a2928b8a6c45dd6764317dbbd 100644 (file)
@@ -1,3 +1,9 @@
+2019-09-07  Paul Thomas  <pault@gcc.gnu.org>
+
+       Backport from mainline
+       PR fortran/91589
+       * gfortran.dg/pr91589.f90 : New test.
+
 2019-09-05  Harald Anlauf  <anlauf@gmx.de>
 
        Backport from mainline
        Backport from mainline.
        2019-05-15  Iain Sandoe  <iain@sandoe.co.uk>
 
-       * lib/target-supports.exp 
+       * lib/target-supports.exp
        (check_effective_target_powerpc_p8vector_ok): No support for Darwin.
        (check_effective_target_powerpc_p9vector_ok): Likewise.
        (check_effective_target_powerpc_float128_sw_ok): Likewise.
diff --git a/gcc/testsuite/gfortran.dg/pr91589.f90 b/gcc/testsuite/gfortran.dg/pr91589.f90
new file mode 100644 (file)
index 0000000..d02cb64
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do compile }
+!
+! Check the fix for PR91589, in which the invalid expression caused an ICE.
+! Other statements using this invalid expression cause "Unclassifiable statement at..."
+!
+! Contributed by Gerhardt Steinmetz  <gscfq@t-online.de>
+!
+program p
+   type t
+      integer :: a
+   end type
+   type(t) :: x = t(1)
+   call sub (x%a%a)   ! { dg-error "Syntax error in argument list" }
+end
+