aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constexpr.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/constexpr.cc')
-rw-r--r--gcc/cp/constexpr.cc29
1 files changed, 22 insertions, 7 deletions
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 65b91ec..eabf7f8 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -7179,10 +7179,23 @@ cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t,
(TREE_TYPE (TREE_TYPE (sub)), TREE_TYPE (t)));
/* DR 1188 says we don't have to deal with this. */
if (!ctx->quiet)
- error_at (cp_expr_loc_or_input_loc (t),
- "accessing value of %qE through a %qT glvalue in a "
- "constant expression", build_fold_indirect_ref (sub),
- TREE_TYPE (t));
+ {
+ auto_diagnostic_group d;
+ error_at (cp_expr_loc_or_input_loc (t),
+ "accessing value of %qT object through a %qT "
+ "glvalue in a constant expression",
+ TREE_TYPE (TREE_TYPE (sub)), TREE_TYPE (t));
+ tree ob = build_fold_indirect_ref (sub);
+ if (DECL_P (ob))
+ {
+ if (DECL_ARTIFICIAL (ob))
+ inform (DECL_SOURCE_LOCATION (ob),
+ "%qT object created here", TREE_TYPE (ob));
+ else
+ inform (DECL_SOURCE_LOCATION (ob),
+ "%q#D declared here", ob);
+ }
+ }
*non_constant_p = true;
return t;
}
@@ -11602,12 +11615,14 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
}
return false;
}
+ tree ve = DECL_VALUE_EXPR (t);
/* Treat __PRETTY_FUNCTION__ inside a template function as
potentially-constant. */
- else if (DECL_PRETTY_FUNCTION_P (t)
- && DECL_VALUE_EXPR (t) == error_mark_node)
+ if (DECL_PRETTY_FUNCTION_P (t) && ve == error_mark_node)
return true;
- return RECUR (DECL_VALUE_EXPR (t), rval);
+ if (DECL_DECOMPOSITION_P (t) && TREE_CODE (ve) == TREE_VEC)
+ return RECUR (TREE_VEC_ELT (ve, 0), rval);
+ return RECUR (ve, rval);
}
if (want_rval
&& (now || !var_in_maybe_constexpr_fn (t))