re PR fortran/50821 (3 new GCC HEAD@180266 regressions)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 21 Oct 2011 22:48:39 +0000 (22:48 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 21 Oct 2011 22:48:39 +0000 (22:48 +0000)
2011-10-20  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/50821
* check.c (gfc_check_ishftc): Check args are constant before
extracting the integer.

From-SVN: r180316

gcc/fortran/ChangeLog
gcc/fortran/check.c

index e58dd112aedc48d57dece3196004541f6734ec9c..251bd45fd260a748b6874e1fbfbfa3990ed7e944 100644 (file)
@@ -1,3 +1,9 @@
+2011-10-20  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/50821
+       * check.c (gfc_check_ishftc): Check args are constant before 
+       extracting the integer.
+
 2011-10-20  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/50514
index 9aaad01ca36144d268ca2dae9402ea5baf837818..34b3a68057ca66fd13aaef422b1bd3cd43e39cc1 100644 (file)
@@ -1967,22 +1967,29 @@ gfc_check_ishftc (gfc_expr *i, gfc_expr *shift, gfc_expr *size)
       if (less_than_bitsize1 ("I", i, "SIZE", size, true) == FAILURE)
        return FAILURE;
 
-      gfc_extract_int (size, &i3);
-      if (i3 <= 0)
+      if (size->expr_type == EXPR_CONSTANT)
        {
-         gfc_error ("SIZE at %L must be positive", &size->where);
-         return FAILURE;
-       }
+         gfc_extract_int (size, &i3);
+         if (i3 <= 0)
+           {
+             gfc_error ("SIZE at %L must be positive", &size->where);
+             return FAILURE;
+           }
 
-      gfc_extract_int (shift, &i2);
-      if (i2 < 0)
-       i2 = -i2;
+         if (shift->expr_type == EXPR_CONSTANT)
+           {
+             gfc_extract_int (shift, &i2);
+             if (i2 < 0)
+               i2 = -i2;
 
-      if (i2 > i3)
-       {
-         gfc_error ("The absolute value of SHIFT at %L must be less than "
-                    "or equal to SIZE at %L", &shift->where, &size->where);
-         return FAILURE;
+             if (i2 > i3)
+               {
+                 gfc_error ("The absolute value of SHIFT at %L must be less "
+                            "than or equal to SIZE at %L", &shift->where,
+                            &size->where);
+                 return FAILURE;
+               }
+            }
        }
     }
   else if (less_than_bitsize1 ("I", i, NULL, shift, true) == FAILURE)