OSDN Git Service

gcc/ChangeLog:
[pf3gnuchains/gcc-fork.git] / gcc / fortran / trans-const.c
index 569aa7e..7ced6f4 100644 (file)
@@ -1,6 +1,6 @@
 /* Translation of constants
-   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software
-   Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   Free Software Foundation, Inc.
    Contributed by Paul Brook
 
 This file is part of GCC.
@@ -25,9 +25,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "tree.h"
-#include "ggc.h"
+#include "realmpfr.h"
 #include "toplev.h"
-#include "real.h"
 #include "double-int.h"
 #include "gfortran.h"
 #include "trans.h"
@@ -176,7 +175,7 @@ gfc_conv_string_init (tree length, gfc_expr * expr)
 void
 gfc_conv_const_charlen (gfc_charlen * cl)
 {
-  if (cl->backend_decl)
+  if (!cl || cl->backend_decl)
     return;
 
   if (cl->length && cl->length->expr_type == EXPR_CONSTANT)
@@ -307,9 +306,9 @@ gfc_conv_constant_to_tree (gfc_expr * expr)
                                                    expr->representation.string));
       else
        {
-         tree real = gfc_conv_mpfr_to_tree (expr->value.complex.r,
+         tree real = gfc_conv_mpfr_to_tree (mpc_realref (expr->value.complex),
                                          expr->ts.kind, expr->is_snan);
-         tree imag = gfc_conv_mpfr_to_tree (expr->value.complex.i,
+         tree imag = gfc_conv_mpfr_to_tree (mpc_imagref (expr->value.complex),
                                          expr->ts.kind, expr->is_snan);
 
          return build_complex (gfc_typenode_for_spec (&expr->ts),
@@ -340,20 +339,26 @@ void
 gfc_conv_constant (gfc_se * se, gfc_expr * expr)
 {
   /* We may be receiving an expression for C_NULL_PTR or C_NULL_FUNPTR.  If
-     so, they expr_type will not yet be an EXPR_CONSTANT.  We need to make
+     so, the expr_type will not yet be an EXPR_CONSTANT.  We need to make
      it so here.  */
-  if (expr->ts.type == BT_DERIVED && expr->ts.derived
-      && expr->ts.derived->attr.is_iso_c)
+  if (expr->ts.type == BT_DERIVED && expr->ts.u.derived
+      && expr->ts.u.derived->attr.is_iso_c)
     {
       if (expr->symtree->n.sym->intmod_sym_id == ISOCBINDING_NULL_PTR 
           || expr->symtree->n.sym->intmod_sym_id == ISOCBINDING_NULL_FUNPTR)
         {
           /* Create a new EXPR_CONSTANT expression for our local uses.  */
-          expr = gfc_int_expr (0);
+          expr = gfc_get_int_expr (gfc_default_integer_kind, NULL, 0);
         }
     }
 
-  gcc_assert (expr->expr_type == EXPR_CONSTANT);
+  if (expr->expr_type != EXPR_CONSTANT)
+    {
+      gfc_expr *e = gfc_get_int_expr (gfc_default_integer_kind, NULL, 0);
+      gfc_error ("non-constant initialization expression at %L", &expr->where);
+      se->expr = gfc_conv_constant_to_tree (e);
+      return;
+    }
 
   if (se->ss != NULL)
     {