diff options
Diffstat (limited to 'gcc/cp/constexpr.cc')
-rw-r--r-- | gcc/cp/constexpr.cc | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index 0f948db..7c8f2cc 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -1098,7 +1098,15 @@ explain_invalid_constexpr_fn (tree fun) body = massage_constexpr_body (fun, body); require_potential_rvalue_constant_expression (body); if (DECL_CONSTRUCTOR_P (fun)) - cx_check_missing_mem_inits (DECL_CONTEXT (fun), body, true); + { + cx_check_missing_mem_inits (DECL_CONTEXT (fun), body, true); + if (cxx_dialect > cxx11) + { + /* Also check the body, not just the ctor-initializer. */ + body = DECL_SAVED_TREE (fun); + require_potential_rvalue_constant_expression (body); + } + } } } } @@ -2429,6 +2437,7 @@ cxx_eval_dynamic_cast_fn (const constexpr_ctx *ctx, tree call, { if (!ctx->quiet) { + auto_diagnostic_group d; error_at (loc, "reference %<dynamic_cast%> failed"); inform (loc, "dynamic type %qT of its operand does " "not have a base class of type %qT", @@ -2484,6 +2493,7 @@ cxx_eval_dynamic_cast_fn (const constexpr_ctx *ctx, tree call, { if (!ctx->quiet) { + auto_diagnostic_group d; error_at (loc, "reference %<dynamic_cast%> failed"); inform (loc, "static type %qT of its operand is a " "non-public base class of dynamic type %qT", @@ -2516,6 +2526,7 @@ cxx_eval_dynamic_cast_fn (const constexpr_ctx *ctx, tree call, { if (!ctx->quiet) { + auto_diagnostic_group d; error_at (loc, "reference %<dynamic_cast%> failed"); inform (loc, "static type %qT of its operand is a non-public" " base class of dynamic type %qT", objtype, mdtype); @@ -2537,6 +2548,7 @@ cxx_eval_dynamic_cast_fn (const constexpr_ctx *ctx, tree call, { if (!ctx->quiet) { + auto_diagnostic_group d; error_at (loc, "reference %<dynamic_cast%> failed"); if (b_kind == bk_ambig) inform (loc, "%qT is an ambiguous base class of dynamic " @@ -2814,6 +2826,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, { if (!ctx->quiet) { + auto_diagnostic_group d; error_at (loc, "array deallocation of object " "allocated with non-array " "allocation"); @@ -2836,6 +2849,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, { if (!ctx->quiet) { + auto_diagnostic_group d; error_at (loc, "non-array deallocation of " "object allocated with array " "allocation"); @@ -4185,6 +4199,7 @@ diag_array_subscript (location_t loc, const constexpr_ctx *ctx, tree array, tree STRIP_ANY_LOCATION_WRAPPER (array); if (DECL_P (array)) { + auto_diagnostic_group d; if (TYPE_DOMAIN (arraytype)) error_at (loc, "array subscript value %qE is outside the bounds " "of array %qD of type %qT", sidx, array, arraytype); @@ -5830,6 +5845,7 @@ cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t, static void outside_lifetime_error (location_t loc, tree r) { + auto_diagnostic_group d; if (DECL_NAME (r) == heap_deleted_identifier) { /* Provide a more accurate message for deleted variables. */ @@ -9452,6 +9468,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, if (flags & tf_error) { tree cap = DECL_CAPTURED_VARIABLE (t); + auto_diagnostic_group d; if (constexpr_error (input_location, fundef_p, "lambda capture of %qE is not a " "constant expression", cap) |