]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* tree.c (cp_expr_location): New.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 19 Jun 2018 00:38:44 +0000 (00:38 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 19 Jun 2018 00:38:44 +0000 (00:38 +0000)
* cp-tree.h (cp_expr_loc_or_loc): New.
* call.c, cvt.c, constexpr.c, constraint.cc, cp-gimplify.c, decl.c,
error.c, init.c, lex.c, parser.c, pt.c, semantics.c, typeck.c,
typeck2.c: Use it instead of EXPR_LOC_OR_LOC.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@261728 138bc75d-0d04-0410-961f-82ee72b054a4

18 files changed:
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/constexpr.c
gcc/cp/constraint.cc
gcc/cp/cp-gimplify.c
gcc/cp/cp-tree.h
gcc/cp/cvt.c
gcc/cp/decl.c
gcc/cp/error.c
gcc/cp/init.c
gcc/cp/lex.c
gcc/cp/parser.c
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/cp/tree.c
gcc/cp/typeck.c
gcc/cp/typeck2.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic7.C

index 3e3b61038324b36107a361e5f571eeff7e97376f..7c903c553378033fc368800bbd470b39f64a9e42 100644 (file)
@@ -1,5 +1,11 @@
 2018-06-18  Jason Merrill  <jason@redhat.com>
 
+       * tree.c (cp_expr_location): New.
+       * cp-tree.h (cp_expr_loc_or_loc): New.
+       * call.c, cvt.c, constexpr.c, constraint.cc, cp-gimplify.c, decl.c,
+       error.c, init.c, lex.c, parser.c, pt.c, semantics.c, typeck.c,
+       typeck2.c: Use it instead of EXPR_LOC_OR_LOC.
+
        * parser.c (cp_parser_lambda_expression): Use a range for
        LAMBDA_EXPR_LOCATION.
 
index d222b41c0600583ca7b5d4db6e6493c12c9e7687..e417590e97d5b8954bb04dd6ae5f2133d4b6ddf1 100644 (file)
@@ -4025,7 +4025,7 @@ build_converted_constant_expr (tree type, tree expr, tsubst_flags_t complain)
   conversion *conv;
   void *p;
   tree t;
-  location_t loc = EXPR_LOC_OR_LOC (expr, input_location);
+  location_t loc = cp_expr_loc_or_loc (expr, input_location);
 
   if (error_operand_p (expr))
     return error_mark_node;
@@ -5003,12 +5003,12 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3,
           if (complain & tf_error)
             {
               if (VOID_TYPE_P (arg2_type))
-                error_at (EXPR_LOC_OR_LOC (arg3, loc),
+                error_at (cp_expr_loc_or_loc (arg3, loc),
                          "second operand to the conditional operator "
                          "is of type %<void%>, but the third operand is "
                          "neither a throw-expression nor of type %<void%>");
               else
-                error_at (EXPR_LOC_OR_LOC (arg2, loc),
+                error_at (cp_expr_loc_or_loc (arg2, loc),
                          "third operand to the conditional operator "
                          "is of type %<void%>, but the second operand is "
                          "neither a throw-expression nor of type %<void%>");
@@ -6622,7 +6622,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
   tree totype = convs->type;
   diagnostic_t diag_kind;
   int flags;
-  location_t loc = EXPR_LOC_OR_LOC (expr, input_location);
+  location_t loc = cp_expr_loc_or_loc (expr, input_location);
 
   if (convs->bad_p && !(complain & tf_error))
     return error_mark_node;
@@ -7127,7 +7127,7 @@ tree
 convert_arg_to_ellipsis (tree arg, tsubst_flags_t complain)
 {
   tree arg_type;
-  location_t loc = EXPR_LOC_OR_LOC (arg, input_location);
+  location_t loc = cp_expr_loc_or_loc (arg, input_location);
 
   /* [expr.call]
 
@@ -7434,7 +7434,7 @@ convert_for_arg_passing (tree type, tree val, tsubst_flags_t complain)
                     "argument of function call might be a candidate "
                     "for a format attribute");
        }
-      maybe_warn_parm_abi (type, EXPR_LOC_OR_LOC (val, input_location));
+      maybe_warn_parm_abi (type, cp_expr_loc_or_loc (val, input_location));
     }
   return val;
 }
@@ -8228,7 +8228,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
       tree type = TREE_TYPE (to);
       tree as_base = CLASSTYPE_AS_BASE (type);
       tree arg = argarray[1];
-      location_t loc = EXPR_LOC_OR_LOC (arg, input_location);
+      location_t loc = cp_expr_loc_or_loc (arg, input_location);
 
       if (is_really_empty_class (type))
        {
@@ -8788,7 +8788,7 @@ build_cxx_call (tree fn, int nargs, tree *argarray,
   tree fndecl;
 
   /* Remember roughly where this call is.  */
-  location_t loc = EXPR_LOC_OR_LOC (fn, input_location);
+  location_t loc = cp_expr_loc_or_loc (fn, input_location);
   fn = build_call_a (fn, nargs, argarray);
   SET_EXPR_LOCATION (fn, loc);
 
@@ -10679,7 +10679,7 @@ perform_implicit_conversion_flags (tree type, tree expr,
 {
   conversion *conv;
   void *p;
-  location_t loc = EXPR_LOC_OR_LOC (expr, input_location);
+  location_t loc = cp_expr_loc_or_loc (expr, input_location);
 
   if (TYPE_REF_P (type))
     expr = mark_lvalue_use (expr);
@@ -11013,7 +11013,7 @@ initialize_reference (tree type, tree expr,
 {
   conversion *conv;
   void *p;
-  location_t loc = EXPR_LOC_OR_LOC (expr, input_location);
+  location_t loc = cp_expr_loc_or_loc (expr, input_location);
 
   if (type == error_mark_node || error_operand_p (expr))
     return error_mark_node;
index 4670076a6fa57706bdf7319b1f5ec2db392d6529..0e6f3570cfa8bace9266c0f590de3d78e97d1238 100644 (file)
@@ -1412,7 +1412,7 @@ cxx_eval_internal_function (const constexpr_ctx *ctx, tree t,
 
     default:
       if (!ctx->quiet)
-       error_at (EXPR_LOC_OR_LOC (t, input_location),
+       error_at (cp_expr_loc_or_loc (t, input_location),
                  "call to internal function %qE", t);
       *non_constant_p = true;
       return t;
@@ -1427,7 +1427,7 @@ cxx_eval_internal_function (const constexpr_ctx *ctx, tree t,
 
   if (TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) == INTEGER_CST)
     {
-      location_t loc = EXPR_LOC_OR_LOC (t, input_location);
+      location_t loc = cp_expr_loc_or_loc (t, input_location);
       tree type = TREE_TYPE (TREE_TYPE (t));
       tree result = fold_binary_loc (loc, opcode, type,
                                     fold_convert_loc (loc, type, arg0),
@@ -1469,7 +1469,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
                          bool lval,
                          bool *non_constant_p, bool *overflow_p)
 {
-  location_t loc = EXPR_LOC_OR_LOC (t, input_location);
+  location_t loc = cp_expr_loc_or_loc (t, input_location);
   tree fun = get_function_named_in_call (t);
   constexpr_call new_call = { NULL, NULL, NULL, 0 };
   bool depth_ok;
@@ -3981,7 +3981,7 @@ cxx_eval_loop_expr (const constexpr_ctx *ctx, tree t,
       if (++count >= constexpr_loop_limit)
        {
          if (!ctx->quiet)
-           error_at (EXPR_LOC_OR_LOC (t, input_location),
+           error_at (cp_expr_loc_or_loc (t, input_location),
                      "%<constexpr%> loop iteration count exceeds limit of %d "
                      "(use -fconstexpr-loop-limit= to increase the limit)",
                      constexpr_loop_limit);
@@ -4597,7 +4597,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
       if (REINTERPRET_CAST_P (t))
        {
          if (!ctx->quiet)
-           error_at (EXPR_LOC_OR_LOC (t, input_location),
+           error_at (cp_expr_loc_or_loc (t, input_location),
                      "a reinterpret_cast is not a constant expression");
          *non_constant_p = true;
          return t;
@@ -4634,7 +4634,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
                if (TYPE_REF_P (type))
                  {
                    if (!ctx->quiet)
-                     error_at (EXPR_LOC_OR_LOC (t, input_location),
+                     error_at (cp_expr_loc_or_loc (t, input_location),
                                "dereferencing a null pointer");
                    *non_constant_p = true;
                    return t;
@@ -4646,7 +4646,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
                    if (!can_convert (type, from, tf_none))
                      {
                        if (!ctx->quiet)
-                         error_at (EXPR_LOC_OR_LOC (t, input_location),
+                         error_at (cp_expr_loc_or_loc (t, input_location),
                                    "conversion of %qT null pointer to %qT "
                                    "is not a constant expression",
                                    from, type);
@@ -4661,7 +4661,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
                     reinterpret_cast<void*>(sizeof 0)
                */
                if (!ctx->quiet)
-                 error_at (EXPR_LOC_OR_LOC (t, input_location),
+                 error_at (cp_expr_loc_or_loc (t, input_location),
                            "%<reinterpret_cast<%T>(%E)%> is not "
                            "a constant expression",
                            type, op);
@@ -4726,7 +4726,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
     case BASELINK:
     case OFFSET_REF:
       if (!ctx->quiet)
-        error_at (EXPR_LOC_OR_LOC (t, input_location),
+        error_at (cp_expr_loc_or_loc (t, input_location),
                  "expression %qE is not a constant expression", t);
       *non_constant_p = true;
       break;
@@ -5327,7 +5327,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
     return false;
   if (t == NULL_TREE)
     return true;
-  location_t loc = EXPR_LOC_OR_LOC (t, input_location);
+  location_t loc = cp_expr_loc_or_loc (t, input_location);
   if (TREE_THIS_VOLATILE (t) && !DECL_P (t))
     {
       if (flags & tf_error)
index 37eded17c941f42d48a5373091dfa6bec757a93a..9f9fb52356e53f33053a4355f294b4bde03559ae 100644 (file)
@@ -804,7 +804,7 @@ check_for_logical_overloads (tree t)
 
   if (DECL_OVERLOADED_OPERATOR_P (fn))
     {
-      location_t loc = EXPR_LOC_OR_LOC (t, input_location);
+      location_t loc = cp_expr_loc_or_loc (t, input_location);
       error_at (loc, "constraint %qE, uses overloaded operator", t);
       return true;
     }
@@ -2012,7 +2012,7 @@ satisfy_predicate_constraint (tree t, tree args,
   tree type = cv_unqualified (TREE_TYPE (expr));
   if (!same_type_p (type, boolean_type_node))
     {
-      error_at (EXPR_LOC_OR_LOC (expr, input_location),
+      error_at (cp_expr_loc_or_loc (expr, input_location),
                 "constraint %qE does not have type %qT",
                 expr, boolean_type_node);
       return boolean_false_node;
index 4567365b48bcf384fa763fc3ee4f5a09a64c9d38..16831fc710027dc86fb8548e562c27c0b309847b 100644 (file)
@@ -217,7 +217,7 @@ genericize_cp_loop (tree *stmt_p, location_t start_locus, tree cond, tree body,
     {
       /* If COND is constant, don't bother building an exit.  If it's false,
         we won't build a loop.  If it's true, any exits are in the body.  */
-      location_t cloc = EXPR_LOC_OR_LOC (cond, start_locus);
+      location_t cloc = cp_expr_loc_or_loc (cond, start_locus);
       exit = build1_loc (cloc, GOTO_EXPR, void_type_node,
                         get_bc_label (bc_break));
       exit = fold_build3_loc (cloc, COND_EXPR, void_type_node, cond,
@@ -579,7 +579,7 @@ int
 cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
 {
   int saved_stmts_are_full_exprs_p = 0;
-  location_t loc = EXPR_LOC_OR_LOC (*expr_p, input_location);
+  location_t loc = cp_expr_loc_or_loc (*expr_p, input_location);
   enum tree_code code = TREE_CODE (*expr_p);
   enum gimplify_status ret;
 
index b870954206649f9ad6bd0dd0a30c636933f008bd..ba6cc1a054c9bf6e481418f6e9a055d408de79b4 100644 (file)
@@ -47,6 +47,8 @@ c-common.h, not after.
    but not all node kinds do (e.g. constants, and references to
    params, locals, etc), so we stash a copy here.  */
 
+extern location_t cp_expr_location             (const_tree);
+
 class cp_expr
 {
 public:
@@ -54,7 +56,7 @@ public:
     m_value (NULL), m_loc (UNKNOWN_LOCATION) {}
 
   cp_expr (tree value) :
-    m_value (value), m_loc (EXPR_LOCATION (m_value)) {}
+    m_value (value), m_loc (cp_expr_location (m_value)) {}
 
   cp_expr (tree value, location_t loc):
     m_value (value), m_loc (loc) {}
@@ -7317,11 +7319,21 @@ extern tree finish_binary_fold_expr          (tree, tree, int);
 extern void require_complete_eh_spec_types     (tree, tree);
 extern void cxx_incomplete_type_diagnostic     (location_t, const_tree,
                                                 const_tree, diagnostic_t);
+
+inline location_t
+cp_expr_loc_or_loc (const_tree t, location_t or_loc)
+{
+  location_t loc = cp_expr_location (t);
+  if (loc == UNKNOWN_LOCATION)
+    loc = or_loc;
+  return loc;
+}
+
 inline void
 cxx_incomplete_type_diagnostic (const_tree value, const_tree type,
                                diagnostic_t diag_kind)
 {
-  cxx_incomplete_type_diagnostic (EXPR_LOC_OR_LOC (value, input_location),
+  cxx_incomplete_type_diagnostic (cp_expr_loc_or_loc (value, input_location),
                                  value, type, diag_kind);
 }
 
index bca9d05af664b71ec87ef2b7963bc68058df0e9d..da98414855626ba6b5f4dc78b8da431f109cc9e5 100644 (file)
@@ -77,7 +77,7 @@ cp_convert_to_pointer (tree type, tree expr, bool dofold,
   tree intype = TREE_TYPE (expr);
   enum tree_code form;
   tree rval;
-  location_t loc = EXPR_LOC_OR_LOC (expr, input_location);
+  location_t loc = cp_expr_loc_or_loc (expr, input_location);
 
   if (intype == error_mark_node)
     return error_mark_node;
@@ -419,7 +419,7 @@ convert_to_reference (tree reftype, tree expr, int convtype,
   tree rval = NULL_TREE;
   tree rval_as_conversion = NULL_TREE;
   bool can_convert_intype_to_type;
-  location_t loc = EXPR_LOC_OR_LOC (expr, input_location);
+  location_t loc = cp_expr_loc_or_loc (expr, input_location);
 
   if (TREE_CODE (type) == FUNCTION_TYPE
       && TREE_TYPE (expr) == unknown_type_node)
@@ -667,7 +667,7 @@ cp_convert_and_check (tree type, tree expr, tsubst_flags_t complain)
       folded_result = fold_simple (folded_result);
       if (!TREE_OVERFLOW_P (folded)
          && folded_result != error_mark_node)
-       warnings_for_convert_and_check (EXPR_LOC_OR_LOC (expr, input_location),
+       warnings_for_convert_and_check (cp_expr_loc_or_loc (expr, input_location),
                                        type, folded, folded_result);
     }
 
@@ -686,7 +686,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags,
   enum tree_code code = TREE_CODE (type);
   const char *invalid_conv_diag;
   tree e1;
-  location_t loc = EXPR_LOC_OR_LOC (expr, input_location);
+  location_t loc = cp_expr_loc_or_loc (expr, input_location);
   bool dofold = (convtype & CONV_FOLD);
 
   if (error_operand_p (e) || type == error_mark_node)
@@ -1001,7 +1001,7 @@ maybe_warn_nodiscard (tree expr, impl_conv_void implicit)
   tree call = expr;
   if (TREE_CODE (expr) == TARGET_EXPR)
     call = TARGET_EXPR_INITIAL (expr);
-  location_t loc = EXPR_LOC_OR_LOC (call, input_location);
+  location_t loc = cp_expr_loc_or_loc (call, input_location);
   tree callee = cp_get_callee (call);
   if (!callee)
     return;
@@ -1078,7 +1078,7 @@ maybe_warn_nodiscard (tree expr, impl_conv_void implicit)
 tree
 convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain)
 {
-  location_t loc = EXPR_LOC_OR_LOC (expr, input_location);
+  location_t loc = cp_expr_loc_or_loc (expr, input_location);
 
   if (expr == error_mark_node
       || TREE_TYPE (expr) == error_mark_node)
index 6d802c9e66df8c79ee12e14016798b6da228a809..90714cce0626d2f924777a292d7712ee2b5b213b 100644 (file)
@@ -3480,7 +3480,7 @@ pop_switch (void)
   location_t switch_location;
 
   /* Emit warnings as needed.  */
-  switch_location = EXPR_LOC_OR_LOC (cs->switch_stmt, input_location);
+  switch_location = cp_expr_loc_or_loc (cs->switch_stmt, input_location);
   const bool bool_cond_p
     = (SWITCH_STMT_TYPE (cs->switch_stmt)
        && TREE_CODE (SWITCH_STMT_TYPE (cs->switch_stmt)) == BOOLEAN_TYPE);
@@ -5410,7 +5410,7 @@ maybe_deduce_size_from_array_init (tree decl, tree init)
                                            do_default);
          if (failure == 1)
            {
-             error_at (EXPR_LOC_OR_LOC (initializer,
+             error_at (cp_expr_loc_or_loc (initializer,
                                         DECL_SOURCE_LOCATION (decl)),
                        "initializer fails to determine size of %qD", decl);
            }
@@ -6266,7 +6266,7 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups)
            }
          else if (init_len != 1 && TREE_CODE (type) != COMPLEX_TYPE)
            {
-             error_at (EXPR_LOC_OR_LOC (init, DECL_SOURCE_LOCATION (decl)),
+             error_at (cp_expr_loc_or_loc (init, DECL_SOURCE_LOCATION (decl)),
                        "scalar object %qD requires one element in "
                        "initializer", decl);
              TREE_TYPE (decl) = error_mark_node;
@@ -6311,7 +6311,7 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups)
            {
              /* Don't reshape if the class has constructors.  */
              if (cxx_dialect == cxx98)
-               error_at (EXPR_LOC_OR_LOC (init, DECL_SOURCE_LOCATION (decl)),
+               error_at (cp_expr_loc_or_loc (init, DECL_SOURCE_LOCATION (decl)),
                          "in C++98 %qD must be initialized by "
                          "constructor, not by %<{...}%>",
                          decl);
@@ -6407,7 +6407,7 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups)
              && DECL_INITIAL (decl)
              && TREE_CODE (DECL_INITIAL (decl)) == STRING_CST
              && PAREN_STRING_LITERAL_P (DECL_INITIAL (decl)))
-           warning_at (EXPR_LOC_OR_LOC (DECL_INITIAL (decl),
+           warning_at (cp_expr_loc_or_loc (DECL_INITIAL (decl),
                                         DECL_SOURCE_LOCATION (decl)),
                        0, "array %qD initialized by parenthesized "
                        "string literal %qE",
index f567c527ec88376eeacf0ab87e6e5a0c1a0b58e3..6a261132afb95a43ea0085e566eec332d80cd3cb 100644 (file)
@@ -3031,7 +3031,7 @@ location_of (tree t)
     return DECL_SOURCE_LOCATION (t);
   if (TREE_CODE (t) == DEFAULT_ARG)
     return defarg_location (t);
-  return EXPR_LOC_OR_LOC (t, input_location);
+  return cp_expr_loc_or_loc (t, input_location);
 }
 
 /* Now the interfaces from error et al to dump_type et al. Each takes an
index acf9c9b7c32f3e79fa3b717066dbe4dd36793076..57697d67035481d22edd01f5c41f576293dcd73e 100644 (file)
@@ -553,7 +553,7 @@ get_nsdmi (tree member, bool in_ctor, tsubst_flags_t complain)
     {
       init = DECL_INITIAL (DECL_TI_TEMPLATE (member));
       location_t expr_loc
-       = EXPR_LOC_OR_LOC (init, DECL_SOURCE_LOCATION (member));
+       = cp_expr_loc_or_loc (init, DECL_SOURCE_LOCATION (member));
       tree *slot;
       if (TREE_CODE (init) == DEFAULT_ARG)
        /* Unparsed.  */;
@@ -742,7 +742,7 @@ maybe_warn_list_ctor (tree member, tree init)
   if (!begin)
     return;
 
-  location_t loc = EXPR_LOC_OR_LOC (init, input_location);
+  location_t loc = cp_expr_loc_or_loc (init, input_location);
   warning_at (loc, OPT_Winit_list_lifetime,
             "initializing %qD from %qE does not extend the lifetime "
             "of the underlying array", member, begin);
@@ -1740,7 +1740,7 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain)
     return error_mark_node;
 
   location_t init_loc = (init
-                        ? EXPR_LOC_OR_LOC (init, input_location)
+                        ? cp_expr_loc_or_loc (init, input_location)
                         : location_of (exp));
 
   TREE_READONLY (exp) = 0;
@@ -2571,7 +2571,7 @@ find_flexarray_init (tree t, tree init)
 static void
 warn_placement_new_too_small (tree type, tree nelts, tree size, tree oper)
 {
-  location_t loc = EXPR_LOC_OR_LOC (oper, input_location);
+  location_t loc = cp_expr_loc_or_loc (oper, input_location);
 
   /* The number of bytes to add to or subtract from the size of the provided
      buffer based on an offset into an array or an array element reference.
@@ -2963,7 +2963,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
        {
          if (complain & tf_error)
            {
-             error_at (EXPR_LOC_OR_LOC (inner_nelts, input_location),
+             error_at (cp_expr_loc_or_loc (inner_nelts, input_location),
                        "array size in new-expression must be constant");
              cxx_constant_value(inner_nelts);
            }
@@ -2992,7 +2992,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
     {
       if (complain & tf_warning_or_error)
        {
-         pedwarn (EXPR_LOC_OR_LOC (outer_nelts, input_location), OPT_Wvla,
+         pedwarn (cp_expr_loc_or_loc (outer_nelts, input_location), OPT_Wvla,
                   typedef_variant_p (orig_type)
                   ? G_("non-constant array new length must be specified "
                        "directly, not by typedef")
@@ -4109,7 +4109,7 @@ build_vec_init (tree base, tree maxindex, tree init,
   tree obase = base;
   bool xvalue = false;
   bool errors = false;
-  location_t loc = (init ? EXPR_LOC_OR_LOC (init, input_location)
+  location_t loc = (init ? cp_expr_loc_or_loc (init, input_location)
                    : location_of (base));
 
   if (TREE_CODE (atype) == ARRAY_TYPE && TYPE_DOMAIN (atype))
index 4d30eb5c85d57cc5c6a370b7024192d2c9b81fbd..c47ae1dd5a18f3e7ed76cbe32081486a96c939e7 100644 (file)
@@ -491,7 +491,7 @@ tree
 unqualified_name_lookup_error (tree name, location_t loc)
 {
   if (loc == UNKNOWN_LOCATION)
-    loc = EXPR_LOC_OR_LOC (name, input_location);
+    loc = cp_expr_loc_or_loc (name, input_location);
 
   if (IDENTIFIER_ANY_OP_P (name))
     error_at (loc, "%qD not defined", name);
index ae9267e6d83c4319d875f4e0ddd49b82f03a8894..c6206fc353ce287506a99c0c5c75f7350c9ec963 100644 (file)
@@ -22350,7 +22350,7 @@ cp_parser_initializer_list (cp_parser* parser, bool* non_constant_p)
          {
            if (IDENTIFIER_MARKED (designator))
              {
-               error_at (EXPR_LOC_OR_LOC (val, input_location),
+               error_at (cp_expr_loc_or_loc (val, input_location),
                          "%<.%s%> designator used multiple times in "
                          "the same initializer list",
                          IDENTIFIER_POINTER (designator));
@@ -34812,7 +34812,7 @@ cp_parser_omp_for_cond (cp_parser *parser, tree decl)
          || CLASS_TYPE_P (TREE_TYPE (decl))))
     return cond;
 
-  return build_x_binary_op (EXPR_LOC_OR_LOC (cond, input_location),
+  return build_x_binary_op (cp_expr_loc_or_loc (cond, input_location),
                            TREE_CODE (cond),
                            TREE_OPERAND (cond, 0), ERROR_MARK,
                            TREE_OPERAND (cond, 1), ERROR_MARK,
index b783b5e1436505211eefe44f1ec13bae453ab11b..1ecc6fb373db092f1e04b48bfd2fec2062150436 100644 (file)
@@ -4058,7 +4058,7 @@ check_for_bare_parameter_packs (tree t, location_t loc /* = UNKNOWN_LOCATION */)
   if (parameter_packs) 
     {
       if (loc == UNKNOWN_LOCATION)
-       loc = EXPR_LOC_OR_LOC (t, input_location);
+       loc = cp_expr_loc_or_loc (t, input_location);
       error_at (loc, "parameter packs not expanded with %<...%>:");
       while (parameter_packs)
         {
@@ -6297,7 +6297,7 @@ static bool
 check_valid_ptrmem_cst_expr (tree type, tree expr,
                             tsubst_flags_t complain)
 {
-  location_t loc = EXPR_LOC_OR_LOC (expr, input_location);
+  location_t loc = cp_expr_loc_or_loc (expr, input_location);
   tree orig_expr = expr;
   STRIP_NOPS (expr);
   if (null_ptr_cst_p (expr))
@@ -6516,7 +6516,7 @@ unify_arg_conversion (bool explain_p, tree to_type,
                      tree from_type, tree arg)
 {
   if (explain_p)
-    inform (EXPR_LOC_OR_LOC (arg, input_location),
+    inform (cp_expr_loc_or_loc (arg, input_location),
            "  cannot convert %qE (type %qT) to type %qT",
            arg, from_type, to_type);
   return unify_invalid (explain_p);
@@ -6593,7 +6593,7 @@ static tree
 convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
 {
   tree expr_type;
-  location_t loc = EXPR_LOC_OR_LOC (expr, input_location);
+  location_t loc = cp_expr_loc_or_loc (expr, input_location);
   tree orig_expr = expr;
 
   /* Detect immediately string literals as invalid non-type argument.
@@ -16580,8 +16580,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
     return t;
 
   loc = input_location;
-  if (EXPR_HAS_LOCATION (t))
-    input_location = EXPR_LOCATION (t);
+  if (location_t eloc = cp_expr_location (t))
+    input_location = eloc;
   if (STATEMENT_CODE_P (TREE_CODE (t)))
     current_stmt_tree ()->stmts_are_full_exprs_p = STMT_IS_FULL_EXPR_P (t);
 
@@ -17693,8 +17693,8 @@ tsubst_copy_and_build (tree t,
     return t;
 
   loc = input_location;
-  if (EXPR_HAS_LOCATION (t))
-    input_location = EXPR_LOCATION (t);
+  if (location_t eloc = cp_expr_location (t))
+    input_location = eloc;
 
   /* N3276 decltype magic only applies to calls at the top level or on the
      right side of a comma.  */
@@ -18351,10 +18351,10 @@ tsubst_copy_and_build (tree t,
 
                    bool diag = true;
                    if (in_lambda)
-                     error_at (EXPR_LOC_OR_LOC (t, input_location),
+                     error_at (cp_expr_loc_or_loc (t, input_location),
                                msg, function);
                    else
-                     diag = permerror (EXPR_LOC_OR_LOC (t, input_location),
+                     diag = permerror (cp_expr_loc_or_loc (t, input_location),
                                        msg, function);
                    if (diag)
                      {
@@ -18369,7 +18369,7 @@ tsubst_copy_and_build (tree t,
                          /* Can't say anything more.  */;
                        else if (DECL_CLASS_SCOPE_P (fn))
                          {
-                           location_t loc = EXPR_LOC_OR_LOC (t,
+                           location_t loc = cp_expr_loc_or_loc (t,
                                                              input_location);
                            inform (loc,
                                    "declarations in dependent base %qT are "
@@ -18425,13 +18425,13 @@ tsubst_copy_and_build (tree t,
              gcc_assert (nargs == 1);
              if (vec_safe_length (call_args) != 1)
                {
-                 error_at (EXPR_LOC_OR_LOC (t, input_location),
+                 error_at (cp_expr_loc_or_loc (t, input_location),
                            "wrong number of arguments to "
                            "%<__builtin_launder%>");
                  ret = error_mark_node;
                }
              else
-               ret = finish_builtin_launder (EXPR_LOC_OR_LOC (t,
+               ret = finish_builtin_launder (cp_expr_loc_or_loc (t,
                                                               input_location),
                                              (*call_args)[0], complain);
              break;
@@ -23590,7 +23590,7 @@ maybe_instantiate_noexcept (tree fn, tsubst_flags_t complain)
       else if (!(added = !fns->add (fn)))
        {
          /* If hash_set::add returns true, the element was already there.  */
-         location_t loc = EXPR_LOC_OR_LOC (DEFERRED_NOEXCEPT_PATTERN (noex),
+         location_t loc = cp_expr_loc_or_loc (DEFERRED_NOEXCEPT_PATTERN (noex),
                                            DECL_SOURCE_LOCATION (fn));
          error_at (loc,
                    "exception specification of %qD depends on itself",
@@ -25780,7 +25780,7 @@ resolve_typename_type (tree type, bool only_current_p)
 
             [temp.names]: In a qualified-id of a declarator-id, the keyword
             template shall not appear at the top level.  */
-         pedwarn (EXPR_LOC_OR_LOC (fullname, input_location), OPT_Wpedantic,
+         pedwarn (cp_expr_loc_or_loc (fullname, input_location), OPT_Wpedantic,
                   "keyword %<template%> not allowed in declarator-id");
          tmpl = decl;
        }
index 55791894221beb7ec8eaf8f551ca7aa9e40ae5f3..2356940a6bbd943c510e8491321b8b8cc2f7a936 100644 (file)
@@ -658,7 +658,7 @@ maybe_convert_cond (tree cond)
       && !TREE_NO_WARNING (cond)
       && warn_parentheses)
     {
-      warning_at (EXPR_LOC_OR_LOC (cond, input_location), OPT_Wparentheses,
+      warning_at (cp_expr_loc_or_loc (cond, input_location), OPT_Wparentheses,
                  "suggest parentheses around assignment used as truth value");
       TREE_NO_WARNING (cond) = 1;
     }
@@ -2382,7 +2382,7 @@ finish_call_expr (tree fn, vec<tree, va_gc> **args, bool disallow_virtual,
          || any_type_dependent_arguments_p (*args))
        {
          result = build_min_nt_call_vec (orig_fn, *args);
-         SET_EXPR_LOCATION (result, EXPR_LOC_OR_LOC (fn, input_location));
+         SET_EXPR_LOCATION (result, cp_expr_loc_or_loc (fn, input_location));
          KOENIG_LOOKUP_P (result) = koenig_p;
          if (is_overloaded_fn (fn))
            {
index a88481db1e0d066d4e8fa88a7904be377273ca34..4e91dbb75dac1c7206c2f98f55fb97c69c97add8 100644 (file)
@@ -479,8 +479,8 @@ build_target_expr (tree decl, tree value, tsubst_flags_t complain)
        return error_mark_node;
     }
   t = build4 (TARGET_EXPR, type, decl, value, t, NULL_TREE);
-  if (EXPR_HAS_LOCATION (value))
-    SET_EXPR_LOCATION (t, EXPR_LOCATION (value));
+  if (location_t eloc = cp_expr_location (value))
+    SET_EXPR_LOCATION (t, eloc);
   /* We always set TREE_SIDE_EFFECTS so that expand_expr does not
      ignore the TARGET_EXPR.  If there really turn out to be no
      side-effects, then the optimizer should be able to get rid of
@@ -5454,6 +5454,26 @@ cp_tree_code_length (enum tree_code code)
     }
 }
 
+/* Like EXPR_LOCATION, but also handle some tcc_exceptional that have
+   locations.  */
+
+location_t
+cp_expr_location (const_tree t_)
+{
+  tree t = CONST_CAST_TREE (t_);
+  if (t == NULL_TREE)
+    return UNKNOWN_LOCATION;
+  switch (TREE_CODE (t))
+    {
+    case LAMBDA_EXPR:
+      return LAMBDA_EXPR_LOCATION (t);
+    case STATIC_ASSERT:
+      return STATIC_ASSERT_SOURCE_LOCATION (t);
+    default:
+      return EXPR_LOCATION (t);
+    }
+}
+
 /* Implement -Wzero_as_null_pointer_constant.  Return true if the
    conditions for the warning hold, false otherwise.  */
 bool
index b033afd9884d5806dea1e4d1e2f888af33047a44..936de9fe5c6cf890577e0a07a5b2e499b42d84cd 100644 (file)
@@ -1990,7 +1990,7 @@ decay_conversion (tree exp,
 {
   tree type;
   enum tree_code code;
-  location_t loc = EXPR_LOC_OR_LOC (exp, input_location);
+  location_t loc = cp_expr_loc_or_loc (exp, input_location);
 
   type = TREE_TYPE (exp);
   if (type == error_mark_node)
@@ -2254,7 +2254,7 @@ static tree
 rationalize_conditional_expr (enum tree_code code, tree t,
                               tsubst_flags_t complain)
 {
-  location_t loc = EXPR_LOC_OR_LOC (t, input_location);
+  location_t loc = cp_expr_loc_or_loc (t, input_location);
 
   /* For MIN_EXPR or MAX_EXPR, fold-const.c has arranged things so that
      the first operand is always the one to be used if both operands
@@ -6041,7 +6041,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert,
 {
   /* No default_conversion here.  It causes trouble for ADDR_EXPR.  */
   tree arg = xarg;
-  location_t location = EXPR_LOC_OR_LOC (arg, input_location);
+  location_t location = cp_expr_loc_or_loc (arg, input_location);
   tree argtype = 0;
   const char *errstring = NULL;
   tree val;
@@ -6593,7 +6593,7 @@ build_x_compound_expr_from_list (tree list, expr_list_kind exp,
       && !CONSTRUCTOR_IS_DIRECT_INIT (expr))
     {
       if (complain & tf_error)
-       pedwarn (EXPR_LOC_OR_LOC (expr, input_location), 0,
+       pedwarn (cp_expr_loc_or_loc (expr, input_location), 0,
                 "list-initializer for non-class type must not "
                 "be parenthesized");
       else
@@ -8802,7 +8802,7 @@ convert_for_assignment (tree type, tree rhs,
                }
              else if (fndecl)
                {
-                 error_at (EXPR_LOC_OR_LOC (rhs, input_location),
+                 error_at (cp_expr_loc_or_loc (rhs, input_location),
                            "cannot convert %qH to %qI",
                            rhstype, type);
                  inform (get_fndecl_argument_location (fndecl, parmnum),
@@ -8904,7 +8904,7 @@ convert_for_assignment (tree type, tree rhs,
       && TREE_CODE (TREE_TYPE (rhs)) != BOOLEAN_TYPE
       && (complain & tf_warning))
     {
-      location_t loc = EXPR_LOC_OR_LOC (rhs, input_location);
+      location_t loc = cp_expr_loc_or_loc (rhs, input_location);
 
       warning_at (loc, OPT_Wparentheses,
                  "suggest parentheses around assignment used as truth value");
@@ -9016,7 +9016,7 @@ maybe_warn_about_returning_address_of_local (tree retval)
 {
   tree valtype = TREE_TYPE (DECL_RESULT (current_function_decl));
   tree whats_returned = fold_for_warn (retval);
-  location_t loc = EXPR_LOC_OR_LOC (retval, input_location);
+  location_t loc = cp_expr_loc_or_loc (retval, input_location);
 
   for (;;)
     {
index 40233e68716736f1a72261955d39b692cb5734c7..ca87b438bd3b551ab12642fb5131cbf649cd42f2 100644 (file)
@@ -959,7 +959,7 @@ check_narrowing (tree type, tree init, tsubst_flags_t complain)
 
   if (!ok)
     {
-      location_t loc = EXPR_LOC_OR_LOC (init, input_location);
+      location_t loc = cp_expr_loc_or_loc (init, input_location);
       if (cxx_dialect == cxx98)
        {
          if (complain & tf_warning)
@@ -1032,7 +1032,7 @@ digest_init_r (tree type, tree init, int nested, int flags,
   if (TREE_CODE (init) == NON_LVALUE_EXPR)
     init = TREE_OPERAND (init, 0);
 
-  location_t loc = EXPR_LOC_OR_LOC (init, input_location);
+  location_t loc = cp_expr_loc_or_loc (init, input_location);
 
   /* Initialization of an array of chars from a string constant. The initializer
      can be optionally enclosed in braces, but reshape_init has already removed
@@ -1293,7 +1293,7 @@ process_init_constructor_array (tree type, tree init, int nested,
       if (nested == 2 && !domain && !vec_safe_is_empty (v))
        {
          if (complain & tf_error)
-           error_at (EXPR_LOC_OR_LOC (init, input_location),
+           error_at (cp_expr_loc_or_loc (init, input_location),
                      "initialization of flexible array member "
                      "in a nested context");
          return PICFLAG_ERRONEOUS;
index c5355b0a8d8935deb18f6c90e9c817322fcaa09f..c8ed0f6e5f0a52364acb53677cb1c8ea5e573fa7 100644 (file)
@@ -4,9 +4,9 @@
 template<typename ... Args>
 static void foo()
 {
-  [](Args, int x) {
+  [](Args, int x) {            // { dg-error "packs not expanded" }
     x;
-  };                           // { dg-error "packs not expanded" }
+  };
 }
 int main()
 {