Revert r244448
[platform/upstream/gcc.git] / gcc / fortran / expr.c
index c4a6ae1..7b95d20 100644 (file)
@@ -1,5 +1,5 @@
 /* Routines for manipulation of expression nodes.
-   Copyright (C) 2000-2016 Free Software Foundation, Inc.
+   Copyright (C) 2000-2017 Free Software Foundation, Inc.
    Contributed by Andy Vaught
 
 This file is part of GCC.
@@ -882,17 +882,16 @@ done:
 
 
 /* Determine if an expression is constant in the sense of F08:7.1.12.
- * This function expects that the expression has already been simplified.
- * FIXME: Return a bool, not an int.  */
+ * This function expects that the expression has already been simplified.  */
 
-int
+bool
 gfc_is_constant_expr (gfc_expr *e)
 {
   gfc_constructor *c;
   gfc_actual_arglist *arg;
 
   if (e == NULL)
-    return 1;
+    return true;
 
   switch (e->expr_type)
     {
@@ -902,7 +901,7 @@ gfc_is_constant_expr (gfc_expr *e)
                  || gfc_is_constant_expr (e->value.op.op2)));
 
     case EXPR_VARIABLE:
-      return 0;
+      return false;
 
     case EXPR_FUNCTION:
     case EXPR_PPC:
@@ -915,7 +914,7 @@ gfc_is_constant_expr (gfc_expr *e)
        {
          for (arg = e->value.function.actual; arg; arg = arg->next)
            if (!gfc_is_constant_expr (arg->expr))
-             return 0;
+             return false;
        }
 
       if (e->value.function.isym
@@ -923,13 +922,13 @@ gfc_is_constant_expr (gfc_expr *e)
              || e->value.function.isym->pure
              || e->value.function.isym->inquiry
              || e->value.function.isym->transformational))
-       return 1;
+       return true;
 
-      return 0;
+      return false;
 
     case EXPR_CONSTANT:
     case EXPR_NULL:
-      return 1;
+      return true;
 
     case EXPR_SUBSTRING:
       return e->ref == NULL || (gfc_is_constant_expr (e->ref->u.ss.start)
@@ -943,14 +942,14 @@ gfc_is_constant_expr (gfc_expr *e)
 
       for (; c; c = gfc_constructor_next (c))
        if (!gfc_is_constant_expr (c->expr))
-         return 0;
+         return false;
 
-      return 1;
+      return true;
 
 
     default:
       gfc_internal_error ("gfc_is_constant_expr(): Unknown expression type");
-      return 0;
+      return false;
     }
 }
 
@@ -3709,9 +3708,20 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue)
 
   if (rvalue->expr_type == EXPR_FUNCTION && !attr.pointer)
     {
-      gfc_error ("Target expression in pointer assignment "
-                "at %L must deliver a pointer result",
-                &rvalue->where);
+      /* F2008, C725.  For PURE also C1283.  Sometimes rvalue is a function call
+        to caf_get.  Map this to the same error message as below when it is
+        still a variable expression.  */
+      if (rvalue->value.function.isym
+         && rvalue->value.function.isym->id == GFC_ISYM_CAF_GET)
+       /* The test above might need to be extend when F08, Note 5.4 has to be
+          interpreted in the way that target and pointer with the same coindex
+          are allowed.  */
+       gfc_error ("Data target at %L shall not have a coindex",
+                  &rvalue->where);
+      else
+       gfc_error ("Target expression in pointer assignment "
+                  "at %L must deliver a pointer result",
+                  &rvalue->where);
       return false;
     }