diff options
Diffstat (limited to 'gcc/cp/constexpr.c')
-rw-r--r-- | gcc/cp/constexpr.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index ece2c8a..54c8b5e 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -97,6 +97,7 @@ ensure_literal_type_for_constexpr_object (tree decl) { if (DECL_DECLARED_CONSTEXPR_P (decl)) { + auto_diagnostic_group d; error ("the type %qT of %<constexpr%> variable %qD " "is not literal", type, decl); explain_non_literal_class (type); @@ -106,6 +107,7 @@ ensure_literal_type_for_constexpr_object (tree decl) { if (!is_instantiation_of_constexpr (current_function_decl)) { + auto_diagnostic_group d; error ("variable %qD of non-literal type %qT in %<constexpr%> " "function", decl, type); explain_non_literal_class (type); @@ -200,6 +202,7 @@ is_valid_constexpr_fn (tree fun, bool complain) ret = false; if (complain) { + auto_diagnostic_group d; error ("invalid type for parameter %d of %<constexpr%> " "function %q+#D", DECL_PARM_INDEX (parm), fun); explain_non_literal_class (TREE_TYPE (parm)); @@ -222,6 +225,7 @@ is_valid_constexpr_fn (tree fun, bool complain) ret = false; if (complain) { + auto_diagnostic_group d; error ("invalid return type %qT of %<constexpr%> function %q+D", rettype, fun); explain_non_literal_class (rettype); @@ -234,11 +238,15 @@ is_valid_constexpr_fn (tree fun, bool complain) && !CLASSTYPE_LITERAL_P (DECL_CONTEXT (fun))) { ret = false; - if (complain - && pedwarn (DECL_SOURCE_LOCATION (fun), OPT_Wpedantic, - "enclosing class of %<constexpr%> non-static member " - "function %q+#D is not a literal type", fun)) - explain_non_literal_class (DECL_CONTEXT (fun)); + if (complain) + { + auto_diagnostic_group d; + if (pedwarn (DECL_SOURCE_LOCATION (fun), OPT_Wpedantic, + "enclosing class of %<constexpr%> non-static" + " member function %q+#D is not a literal type", + fun)) + explain_non_literal_class (DECL_CONTEXT (fun)); + } } } else if (CLASSTYPE_VBASECLASSES (DECL_CONTEXT (fun))) @@ -818,6 +826,7 @@ cx_check_missing_mem_inits (tree ctype, tree body, bool complain) } if (!complain) return true; + auto_diagnostic_group d; error ("member %qD must be initialized by mem-initializer " "in %<constexpr%> constructor", field); inform (DECL_SOURCE_LOCATION (field), "declared here"); @@ -4303,6 +4312,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, { if (!ctx->quiet) { + auto_diagnostic_group d; error ("temporary of non-literal type %qT in a " "constant expression", TREE_TYPE (t)); explain_non_literal_class (TREE_TYPE (t)); @@ -5995,6 +6005,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, { if (flags & tf_error) { + auto_diagnostic_group d; error_at (loc, "temporary of non-literal type %qT in a " "constant expression", TREE_TYPE (t)); explain_non_literal_class (TREE_TYPE (t)); |