PR c++/68795: fix uninitialized close_paren_loc in cp_parser_postfix_expression
[gcc.git] / gcc / tree.c
index c8e143a545bfa2350221bb8c8405a78bd44c7fba..20470c53a305969a4e3bbee7ee6e107b0480e3f1 100644 (file)
@@ -1,5 +1,5 @@
 /* Language-independent node constructors for parse phase of GNU compiler.
-   Copyright (C) 1987-2015 Free Software Foundation, Inc.
+   Copyright (C) 1987-2016 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -282,7 +282,6 @@ unsigned const char omp_clause_num_ops[] =
   1, /* OMP_CLAUSE_IS_DEVICE_PTR  */
   2, /* OMP_CLAUSE__CACHE_  */
   1, /* OMP_CLAUSE_DEVICE_RESIDENT  */
-  1, /* OMP_CLAUSE_USE_DEVICE  */
   2, /* OMP_CLAUSE_GANG  */
   1, /* OMP_CLAUSE_ASYNC  */
   1, /* OMP_CLAUSE_WAIT  */
@@ -354,7 +353,6 @@ const char * const omp_clause_code_name[] =
   "is_device_ptr",
   "_cache_",
   "device_resident",
-  "use_device",
   "gang",
   "async",
   "wait",
@@ -1245,11 +1243,9 @@ static unsigned int
 get_int_cst_ext_nunits (tree type, const wide_int &cst)
 {
   gcc_checking_assert (cst.get_precision () == TYPE_PRECISION (type));
-  /* We need an extra zero HWI if CST is an unsigned integer with its
-     upper bit set, and if CST occupies a whole number of HWIs.  */
-  if (TYPE_UNSIGNED (type)
-      && wi::neg_p (cst)
-      && (cst.get_precision () % HOST_BITS_PER_WIDE_INT) == 0)
+  /* We need extra HWIs if CST is an unsigned integer with its
+     upper bit set.  */
+  if (TYPE_UNSIGNED (type) && wi::neg_p (cst))
     return cst.get_precision () / HOST_BITS_PER_WIDE_INT + 1;
   return cst.get_len ();
 }
@@ -1266,7 +1262,8 @@ build_new_int_cst (tree type, const wide_int &cst)
   if (len < ext_len)
     {
       --ext_len;
-      TREE_INT_CST_ELT (nt, ext_len) = 0;
+      TREE_INT_CST_ELT (nt, ext_len)
+       = zext_hwi (-1, cst.get_precision () % HOST_BITS_PER_WIDE_INT);
       for (unsigned int i = len; i < ext_len; ++i)
        TREE_INT_CST_ELT (nt, i) = -1;
     }
@@ -2294,8 +2291,6 @@ zerop (const_tree expr)
 int
 integer_zerop (const_tree expr)
 {
-  STRIP_NOPS (expr);
-
   switch (TREE_CODE (expr))
     {
     case INTEGER_CST:
@@ -2322,8 +2317,6 @@ integer_zerop (const_tree expr)
 int
 integer_onep (const_tree expr)
 {
-  STRIP_NOPS (expr);
-
   switch (TREE_CODE (expr))
     {
     case INTEGER_CST:
@@ -2350,8 +2343,6 @@ integer_onep (const_tree expr)
 int
 integer_each_onep (const_tree expr)
 {
-  STRIP_NOPS (expr);
-
   if (TREE_CODE (expr) == COMPLEX_CST)
     return (integer_onep (TREE_REALPART (expr))
            && integer_onep (TREE_IMAGPART (expr)));
@@ -2365,8 +2356,6 @@ integer_each_onep (const_tree expr)
 int
 integer_all_onesp (const_tree expr)
 {
-  STRIP_NOPS (expr);
-
   if (TREE_CODE (expr) == COMPLEX_CST
       && integer_all_onesp (TREE_REALPART (expr))
       && integer_all_onesp (TREE_IMAGPART (expr)))
@@ -2392,8 +2381,6 @@ integer_all_onesp (const_tree expr)
 int
 integer_minus_onep (const_tree expr)
 {
-  STRIP_NOPS (expr);
-
   if (TREE_CODE (expr) == COMPLEX_CST)
     return (integer_all_onesp (TREE_REALPART (expr))
            && integer_zerop (TREE_IMAGPART (expr)));
@@ -2407,8 +2394,6 @@ integer_minus_onep (const_tree expr)
 int
 integer_pow2p (const_tree expr)
 {
-  STRIP_NOPS (expr);
-
   if (TREE_CODE (expr) == COMPLEX_CST
       && integer_pow2p (TREE_REALPART (expr))
       && integer_zerop (TREE_IMAGPART (expr)))
@@ -2426,8 +2411,6 @@ integer_pow2p (const_tree expr)
 int
 integer_nonzerop (const_tree expr)
 {
-  STRIP_NOPS (expr);
-
   return ((TREE_CODE (expr) == INTEGER_CST
           && !wi::eq_p (expr, 0))
          || (TREE_CODE (expr) == COMPLEX_CST
@@ -2442,8 +2425,6 @@ integer_nonzerop (const_tree expr)
 int
 integer_truep (const_tree expr)
 {
-  STRIP_NOPS (expr);
-
   if (TREE_CODE (expr) == VECTOR_CST)
     return integer_all_onesp (expr);
   return integer_onep (expr);
@@ -2464,8 +2445,6 @@ fixed_zerop (const_tree expr)
 int
 tree_log2 (const_tree expr)
 {
-  STRIP_NOPS (expr);
-
   if (TREE_CODE (expr) == COMPLEX_CST)
     return tree_log2 (TREE_REALPART (expr));
 
@@ -2478,8 +2457,6 @@ tree_log2 (const_tree expr)
 int
 tree_floor_log2 (const_tree expr)
 {
-  STRIP_NOPS (expr);
-
   if (TREE_CODE (expr) == COMPLEX_CST)
     return tree_log2 (TREE_REALPART (expr));
 
@@ -2603,8 +2580,6 @@ tree_ctz (const_tree expr)
 int
 real_zerop (const_tree expr)
 {
-  STRIP_NOPS (expr);
-
   switch (TREE_CODE (expr))
     {
     case REAL_CST:
@@ -2633,8 +2608,6 @@ real_zerop (const_tree expr)
 int
 real_onep (const_tree expr)
 {
-  STRIP_NOPS (expr);
-
   switch (TREE_CODE (expr))
     {
     case REAL_CST:
@@ -2662,8 +2635,6 @@ real_onep (const_tree expr)
 int
 real_minus_onep (const_tree expr)
 {
-  STRIP_NOPS (expr);
-
   switch (TREE_CODE (expr))
     {
     case REAL_CST:
@@ -3257,8 +3228,6 @@ decl_address_ip_invariant_p (const_tree op)
    not handle arithmetic; that's handled in skip_simple_arithmetic and
    tree_invariant_p).  */
 
-static bool tree_invariant_p (tree t);
-
 static bool
 tree_invariant_p_1 (tree t)
 {
@@ -3308,7 +3277,7 @@ tree_invariant_p_1 (tree t)
 
 /* Return true if T is function-invariant.  */
 
-static bool
+bool
 tree_invariant_p (tree t)
 {
   tree inner = skip_simple_arithmetic (t);
@@ -3609,9 +3578,10 @@ type_contains_placeholder_1 (const_tree type)
              || CONTAINS_PLACEHOLDER_P (TYPE_MAX_VALUE (type)));
 
     case ARRAY_TYPE:
-      /* We have already checked the component type above, so just check the
-        domain type.  */
-      return type_contains_placeholder_p (TYPE_DOMAIN (type));
+      /* We have already checked the component type above, so just check
+        the domain type.  Flexible array members have a null domain.  */
+      return TYPE_DOMAIN (type) ?
+       type_contains_placeholder_p (TYPE_DOMAIN (type)) : false;
 
     case RECORD_TYPE:
     case UNION_TYPE:
@@ -5219,7 +5189,10 @@ free_lang_data_in_type (tree type)
       while (member)
        {
          if (TREE_CODE (member) == FIELD_DECL
-             || TREE_CODE (member) == TYPE_DECL)
+             || (TREE_CODE (member) == TYPE_DECL
+                 && !DECL_IGNORED_P (member)
+                 && debug_info_level > DINFO_LEVEL_TERSE
+                 && !is_redundant_typedef (member)))
            {
              if (prev)
                TREE_CHAIN (prev) = member;
@@ -5244,7 +5217,7 @@ free_lang_data_in_type (tree type)
       /* Remove TYPE_METHODS list.  While it would be nice to keep it
         to enable ODR warnings about different method lists, doing so
         seems to impractically increase size of LTO data streamed.
-        Keep the infrmation if TYPE_METHODS was non-NULL. This is used
+        Keep the information if TYPE_METHODS was non-NULL. This is used
         by function.c and pretty printers.  */
       if (TYPE_METHODS (type))
         TYPE_METHODS (type) = error_mark_node;
@@ -5694,7 +5667,10 @@ find_decls_types_r (tree *tp, int *ws, void *data)
          while (tem)
            {
              if (TREE_CODE (tem) == FIELD_DECL
-                 || TREE_CODE (tem) == TYPE_DECL)
+                 || (TREE_CODE (tem) == TYPE_DECL
+                     && !DECL_IGNORED_P (tem)
+                     && debug_info_level > DINFO_LEVEL_TERSE
+                     && !is_redundant_typedef (tem)))
                fld_worklist_push (tem, fld);
              tem = TREE_CHAIN (tem);
            }
@@ -11144,7 +11120,8 @@ maybe_build_call_expr_loc (location_t loc, combined_fn fn, tree type,
       if (direct_internal_fn_p (ifn))
        {
          tree_pair types = direct_internal_fn_types (ifn, type, argarray);
-         if (!direct_internal_fn_supported_p (ifn, types))
+         if (!direct_internal_fn_supported_p (ifn, types,
+                                              OPTIMIZE_FOR_BOTH))
            return NULL_TREE;
        }
       return build_call_expr_internal_loc_array (loc, ifn, type, n, argarray);
@@ -11633,7 +11610,6 @@ walk_tree_1 (tree *tp, walk_tree_fn func, void *data,
          /* FALLTHRU */
 
        case OMP_CLAUSE_DEVICE_RESIDENT:
-       case OMP_CLAUSE_USE_DEVICE:
        case OMP_CLAUSE_ASYNC:
        case OMP_CLAUSE_WAIT:
        case OMP_CLAUSE_WORKER:
@@ -13450,6 +13426,12 @@ gimple_canonical_types_compatible_p (const_tree t1, const_tree t2,
       {
        tree f1, f2;
 
+       /* Don't try to compare variants of an incomplete type, before
+          TYPE_FIELDS has been copied around.  */
+       if (!COMPLETE_TYPE_P (t1) && !COMPLETE_TYPE_P (t2))
+         return true;
+
+
        if (TYPE_REVERSE_STORAGE_ORDER (t1) != TYPE_REVERSE_STORAGE_ORDER (t2))
          return false;
 
@@ -13736,28 +13718,35 @@ verify_type (const_tree t)
        }
     }
   else if (RECORD_OR_UNION_TYPE_P (t))
-    for (tree fld = TYPE_FIELDS (t); fld; fld = TREE_CHAIN (fld))
-      {
-       /* TODO: verify properties of decls.  */
-       if (TREE_CODE (fld) == FIELD_DECL)
-         ;
-       else if (TREE_CODE (fld) == TYPE_DECL)
-         ;
-       else if (TREE_CODE (fld) == CONST_DECL)
-         ;
-       else if (TREE_CODE (fld) == VAR_DECL)
-         ;
-       else if (TREE_CODE (fld) == TEMPLATE_DECL)
-         ;
-       else if (TREE_CODE (fld) == USING_DECL)
-         ;
-       else
-         {
-           error ("Wrong tree in TYPE_FIELDS list");
-           debug_tree (fld);
-           error_found = true;
-         }
-      }
+    {
+      if (TYPE_FIELDS (t) && !COMPLETE_TYPE_P (t) && in_lto_p)
+       {
+         error ("TYPE_FIELDS defined in incomplete type");
+         error_found = true;
+       }
+      for (tree fld = TYPE_FIELDS (t); fld; fld = TREE_CHAIN (fld))
+       {
+         /* TODO: verify properties of decls.  */
+         if (TREE_CODE (fld) == FIELD_DECL)
+           ;
+         else if (TREE_CODE (fld) == TYPE_DECL)
+           ;
+         else if (TREE_CODE (fld) == CONST_DECL)
+           ;
+         else if (TREE_CODE (fld) == VAR_DECL)
+           ;
+         else if (TREE_CODE (fld) == TEMPLATE_DECL)
+           ;
+         else if (TREE_CODE (fld) == USING_DECL)
+           ;
+         else
+           {
+             error ("Wrong tree in TYPE_FIELDS list");
+             debug_tree (fld);
+             error_found = true;
+           }
+       }
+    }
   else if (TREE_CODE (t) == INTEGER_TYPE
           || TREE_CODE (t) == BOOLEAN_TYPE
           || TREE_CODE (t) == OFFSET_TYPE
@@ -13875,7 +13864,9 @@ nonnull_arg_p (const_tree arg)
   tree t, attrs, fntype;
   unsigned HOST_WIDE_INT arg_num;
 
-  gcc_assert (TREE_CODE (arg) == PARM_DECL && POINTER_TYPE_P (TREE_TYPE (arg)));
+  gcc_assert (TREE_CODE (arg) == PARM_DECL
+             && (POINTER_TYPE_P (TREE_TYPE (arg))
+                 || TREE_CODE (TREE_TYPE (arg)) == OFFSET_TYPE));
 
   /* The static chain decl is always non null.  */
   if (arg == cfun->static_chain_decl)
@@ -13930,7 +13921,7 @@ nonnull_arg_p (const_tree arg)
 /* Given location LOC, strip away any packed range information
    or ad-hoc information.  */
 
-static location_t
+location_t
 get_pure_location (location_t loc)
 {
   if (IS_ADHOC_LOC (loc))
@@ -13960,20 +13951,20 @@ set_block (location_t loc, tree block)
   return COMBINE_LOCATION_DATA (line_table, pure_loc, src_range, block);
 }
 
-void
+location_t
 set_source_range (tree expr, location_t start, location_t finish)
 {
   source_range src_range;
   src_range.m_start = start;
   src_range.m_finish = finish;
-  set_source_range (expr, src_range);
+  return set_source_range (expr, src_range);
 }
 
-void
+location_t
 set_source_range (tree expr, source_range src_range)
 {
   if (!EXPR_P (expr))
-    return;
+    return UNKNOWN_LOCATION;
 
   location_t pure_loc = get_pure_location (EXPR_LOCATION (expr));
   location_t adhoc = COMBINE_LOCATION_DATA (line_table,
@@ -13981,6 +13972,21 @@ set_source_range (tree expr, source_range src_range)
                                            src_range,
                                            NULL);
   SET_EXPR_LOCATION (expr, adhoc);
+  return adhoc;
+}
+
+location_t
+make_location (location_t caret, location_t start, location_t finish)
+{
+  location_t pure_loc = get_pure_location (caret);
+  source_range src_range;
+  src_range.m_start = start;
+  src_range.m_finish = finish;
+  location_t combined_loc = COMBINE_LOCATION_DATA (line_table,
+                                                  pure_loc,
+                                                  src_range,
+                                                  NULL);
+  return combined_loc;
 }
 
 /* Return the name of combined function FN, for debugging purposes.  */