+2017-11-21 Martin Liska <mliska@suse.cz>
+
+ * class.c (finalize_literal_type_property): Add quotes for
+ constexpr keyword.
+ (explain_non_literal_class): Likewise.
+ * constexpr.c (ensure_literal_type_for_constexpr_object): Likewise.
+ (is_valid_constexpr_fn): Likewise.
+ (check_constexpr_ctor_body): Likewise.
+ (register_constexpr_fundef): Likewise.
+ (explain_invalid_constexpr_fn): Likewise.
+ (cxx_eval_builtin_function_call): Likewise.
+ (cxx_eval_call_expression): Likewise.
+ (cxx_eval_loop_expr): Likewise.
+ (potential_constant_expression_1): Likewise.
+ * decl.c (check_previous_goto_1): Likewise.
+ (check_goto): Likewise.
+ (grokfndecl): Likewise.
+ (grokdeclarator): Likewise.
+ * error.c (maybe_print_constexpr_context): Likewise.
+ * method.c (process_subob_fn): Likewise.
+ (defaulted_late_check): Likewise.
+ * parser.c (cp_parser_compound_statement): Likewise.
+
2017-11-21 Marc Glisse <marc.glisse@inria.fr>
* constexpr.c (cxx_eval_constant_expression,
DECL_DECLARED_CONSTEXPR_P (fn) = false;
if (!DECL_GENERATED_P (fn)
&& pedwarn (DECL_SOURCE_LOCATION (fn), OPT_Wpedantic,
- "enclosing class of constexpr non-static member "
+ "enclosing class of %<constexpr%> non-static member "
"function %q+#D is not a literal type", fn))
explain_non_literal_class (t);
}
{
inform (UNKNOWN_LOCATION,
" %q+T is not an aggregate, does not have a trivial "
- "default constructor, and has no constexpr constructor that "
+ "default constructor, and has no %<constexpr%> constructor that "
"is not a copy or move constructor", t);
if (type_has_non_user_provided_default_constructor (t))
/* Note that we can't simply call locate_ctor because when the
{
if (DECL_DECLARED_CONSTEXPR_P (decl))
{
- error ("the type %qT of constexpr variable %qD is not literal",
- type, decl);
+ error ("the type %qT of %<constexpr%> variable %qD "
+ "is not literal", type, decl);
explain_non_literal_class (type);
}
else
{
ret = false;
if (complain)
- error ("inherited constructor %qD is not constexpr",
+ error ("inherited constructor %qD is not %<constexpr%>",
DECL_INHERITED_CTOR (fun));
}
else
ret = false;
if (complain)
{
- error ("invalid type for parameter %d of constexpr "
+ error ("invalid type for parameter %d of %<constexpr%> "
"function %q+#D", DECL_PARM_INDEX (parm), fun);
explain_non_literal_class (TREE_TYPE (parm));
}
ret = false;
if (complain)
inform (DECL_SOURCE_LOCATION (fun),
- "lambdas are implicitly constexpr only in C++17 and later");
+ "lambdas are implicitly %<constexpr%> only in C++17 and later");
}
else if (!DECL_CONSTRUCTOR_P (fun))
{
ret = false;
if (complain)
{
- error ("invalid return type %qT of constexpr function %q+D",
+ error ("invalid return type %qT of %<constexpr%> function %q+D",
rettype, fun);
explain_non_literal_class (rettype);
}
ret = false;
if (complain
&& pedwarn (DECL_SOURCE_LOCATION (fun), OPT_Wpedantic,
- "enclosing class of constexpr non-static member "
+ "enclosing class of %<constexpr%> non-static member "
"function %q+#D is not a literal type", fun))
explain_non_literal_class (DECL_CONTEXT (fun));
}
if (!ok)
{
if (complain)
- error ("constexpr constructor does not have empty body");
+ error ("%<constexpr%> constructor does not have empty body");
DECL_DECLARED_CONSTEXPR_P (current_function_decl) = false;
}
return ok;
if (massaged == NULL_TREE || massaged == error_mark_node)
{
if (!DECL_CONSTRUCTOR_P (fun))
- error ("body of constexpr function %qD not a return-statement", fun);
+ error ("body of %<constexpr%> function %qD not a return-statement",
+ fun);
return NULL;
}
input_location set to our caller's location. */
input_location = DECL_SOURCE_LOCATION (fun);
inform (input_location,
- "%qD is not usable as a constexpr function because:", fun);
+ "%qD is not usable as a %<constexpr%> function because:", fun);
}
/* First check the declaration. */
if (is_valid_constexpr_fn (fun, true))
comes from cp_maybe_instrument_return. */
if (DECL_FUNCTION_CODE (fun) == BUILT_IN_UNREACHABLE
&& EXPR_LOCATION (t) == BUILTINS_LOCATION)
- error ("constexpr call flows off the end of the function");
+ error ("%<constexpr%> call flows off the end of the function");
else
{
new_call = build_call_array_loc (EXPR_LOCATION (t), TREE_TYPE (t),
if (TREE_CODE (fun) != FUNCTION_DECL)
{
if (!ctx->quiet && !*non_constant_p)
- error_at (loc, "expression %qE does not designate a constexpr "
+ error_at (loc, "expression %qE does not designate a %<constexpr%> "
"function", fun);
*non_constant_p = true;
return t;
if (!ctx->quiet)
{
if (!lambda_static_thunk_p (fun))
- error_at (loc, "call to non-constexpr function %qD", fun);
+ error_at (loc, "call to non-%<constexpr%> function %qD", fun);
explain_invalid_constexpr_fn (fun);
}
*non_constant_p = true;
if (!depth_ok)
{
if (!ctx->quiet)
- error ("constexpr evaluation depth exceeds maximum of %d (use "
+ error ("%<constexpr%> evaluation depth exceeds maximum of %d (use "
"-fconstexpr-depth= to increase the maximum)",
max_constexpr_depth);
*non_constant_p = true;
if (result == NULL_TREE && !*non_constant_p)
{
if (!ctx->quiet)
- error ("constexpr call flows off the end "
+ error ("%<constexpr%> call flows off the end "
"of the function");
*non_constant_p = true;
}
{
if (!ctx->quiet)
error_at (EXPR_LOC_OR_LOC (t, input_location),
- "constexpr loop iteration count exceeds limit of %d "
+ "%<constexpr%> loop iteration count exceeds limit of %d "
"(use -fconstexpr-loop-limit= to increase the limit)",
constexpr_loop_limit);
*non_constant_p = true;
{
if (flags & tf_error)
{
- error_at (loc, "call to non-constexpr function %qD",
+ error_at (loc, "call to non-%<constexpr%> function %qD",
fun);
explain_invalid_constexpr_fn (fun);
}
else if (ent->in_transaction_scope)
inform (input_location, " enters synchronized or atomic statement");
else if (ent->in_constexpr_if)
- inform (input_location, " enters constexpr if statement");
+ inform (input_location, " enters %<constexpr%> if statement");
}
if (ent->in_omp_scope)
if (inlinep & 1)
error ("cannot declare %<::main%> to be inline");
if (inlinep & 2)
- error ("cannot declare %<::main%> to be constexpr");
+ error ("cannot declare %<::main%> to be %<constexpr%>");
if (!publicp)
error ("cannot declare %<::main%> to be static");
inlinep = 0;
unqualified_id);
else if (constexpr_p && !initialized)
{
- error ("constexpr static data member %qD must have an "
+ error ("%<constexpr%> static data member %qD must have an "
"initializer", decl);
constexpr_p = false;
}
}
else if (constexpr_p && DECL_EXTERNAL (decl))
{
- error ("declaration of constexpr variable %qD is not a definition",
- decl);
+ error ("declaration of %<constexpr%> variable %qD "
+ "is not a definition", decl);
constexpr_p = false;
}
const char *s = expr_as_string (t, 0);
if (context->show_column)
pp_verbatim (context->printer,
- _("%r%s:%d:%d:%R in constexpr expansion of %qs"),
+ _("%r%s:%d:%d:%R in %<constexpr%> expansion of %qs"),
"locus", xloc.file, xloc.line, xloc.column, s);
else
pp_verbatim (context->printer,
- _("%r%s:%d:%R in constexpr expansion of %qs"),
+ _("%r%s:%d:%R in %<constexpr%> expansion of %qs"),
"locus", xloc.file, xloc.line, s);
pp_newline (context->printer);
}
if (diag)
{
inform (DECL_SOURCE_LOCATION (fn),
- "defaulted constructor calls non-constexpr %qD", fn);
+ "defaulted constructor calls non-%<constexpr%> %qD", fn);
explain_invalid_constexpr_fn (fn);
}
}
if (!CLASSTYPE_TEMPLATE_INSTANTIATION (ctx))
{
error ("explicitly defaulted function %q+D cannot be declared "
- "as constexpr because the implicit declaration is not "
- "constexpr:", fn);
+ "as %<constexpr%> because the implicit declaration is not "
+ "%<constexpr%>:", fn);
explain_implicit_non_constexpr (fn);
}
DECL_DECLARED_CONSTEXPR_P (fn) = false;
if (DECL_DECLARED_CONSTEXPR_P (current_function_decl)
&& !function_body && cxx_dialect < cxx14)
pedwarn (input_location, OPT_Wpedantic,
- "compound-statement in constexpr function");
+ "compound-statement in %<constexpr%> function");
/* Begin the compound-statement. */
compound_stmt = begin_compound_stmt (bcs_flags);
/* If the next keyword is `__label__' we have a label declaration. */
+2017-11-21 Martin Liska <mliska@suse.cz>
+
+ * g++.dg/cpp0x/constexpr-48089.C: Add quotes for constexpr
+ keyword; add dg-message for 'in .constexpr. expansion of '.
+ * g++.dg/cpp0x/constexpr-50060.C: Likewise.
+ * g++.dg/cpp0x/constexpr-60049.C: Likewise.
+ * g++.dg/cpp0x/constexpr-70323.C: Likewise.
+ * g++.dg/cpp0x/constexpr-70323a.C: Likewise.
+ * g++.dg/cpp0x/constexpr-cast.C: Likewise.
+ * g++.dg/cpp0x/constexpr-diag3.C: Likewise.
+ * g++.dg/cpp0x/constexpr-ex1.C: Likewise.
+ * g++.dg/cpp0x/constexpr-generated1.C: Likewise.
+ * g++.dg/cpp0x/constexpr-ice16.C: Likewise.
+ * g++.dg/cpp0x/constexpr-ice5.C: Likewise.
+ * g++.dg/cpp0x/constexpr-incomplete2.C: Likewise.
+ * g++.dg/cpp0x/constexpr-neg1.C: Likewise.
+ * g++.dg/cpp0x/constexpr-recursion.C: Likewise.
+ * g++.dg/cpp0x/constexpr-shift1.C: Likewise.
+ * g++.dg/cpp1y/constexpr-70265-1.C: Likewise.
+ * g++.dg/cpp1y/constexpr-70265-2.C: Likewise.
+ * g++.dg/cpp1y/constexpr-79655.C: Likewise.
+ * g++.dg/cpp1y/constexpr-new.C: Likewise.
+ * g++.dg/cpp1y/constexpr-return2.C: Likewise.
+ * g++.dg/cpp1y/constexpr-shift1.C: Likewise.
+ * g++.dg/cpp1y/constexpr-throw.C: Likewise.
+ * g++.dg/cpp1z/constexpr-lambda6.C: Likewise.
+ * g++.dg/ext/constexpr-vla1.C: Likewise.
+ * g++.dg/ext/constexpr-vla2.C: Likewise.
+ * g++.dg/ext/constexpr-vla3.C: Likewise.
+ * g++.dg/cpp0x/static_assert10.C: Likewise.
+ * g++.dg/cpp1y/pr63996.C: Likewise.
+ * g++.dg/cpp1y/pr68180.C: Likewise.
+ * g++.dg/cpp1y/pr77830.C: Likewise.
+ * g++.dg/ubsan/pr63956.C: Likewise.
+
2017-11-21 Jakub Jelinek <jakub@redhat.com>
PR c++/83045
int v;
};
-constexpr s bang; // { dg-error "" }
+constexpr s bang; // { dg-error "|" }
struct R {
int i,j;
int y;
};
-static_assert (S (6.5).x == 0.8125, ""); // { dg-error "non-constant condition for static assertion|in constexpr expansion" "" { target { ! c++14 } } }
+static_assert (S (6.5).x == 0.8125, ""); // { dg-error "non-constant condition for static assertion|in .constexpr. expansion" "" { target { ! c++14 } } }
static_assert (T (6.5).x == 0.8125, ""); // { dg-error "non-constant condition for static assertion|called in a constant expression" "" { target { ! c++14 } } }
constexpr int X = __CHAR_BIT__ * sizeof (int) + 1;
-constexpr int x1 = f1 (X);
-constexpr int x2 = f2 (-1);
-constexpr int x3 = f3 (-1);
-constexpr int x4 = f4 (X);
-constexpr int x5 = f5 (-1);
+constexpr int x1 = f1 (X); // { dg-message "in .constexpr. expansion of" }
+constexpr int x2 = f2 (-1); // { dg-message "in .constexpr. expansion of" }
+constexpr int x3 = f3 (-1); // { dg-message "in .constexpr. expansion of" }
+constexpr int x4 = f4 (X); // { dg-message "in .constexpr. expansion of" }
+constexpr int x5 = f5 (-1); // { dg-message "in .constexpr. expansion of" }
constexpr int y1 = 1 << X; // { dg-error "shift expression" }
constexpr int y2 = 1 << -1; // { dg-error "shift expression" }
constexpr int overflow_if_0 (int i) { return __INT_MAX__ + !i; }
constexpr int overflow_if_1 (int i) { return __INT_MAX__ + i; }
-constexpr bool i0_0 = overflow_if_0 (0); // { dg-error "overflow in constant expression" }
+constexpr bool i0_0 = overflow_if_0 (0); // { dg-error "overflow in constant expression|in .constexpr. expansion of " }
constexpr bool i0_1 = overflow_if_0 (1);
constexpr bool i1_0 = overflow_if_1 (0);
-constexpr bool i1_1 = overflow_if_1 (1); // { dg-error "overflow in constant expression" }
+constexpr bool i1_1 = overflow_if_1 (1); // { dg-error "overflow in constant expression|in .constexpr. expansion of " }
constexpr int overflow_if_0 (int i) { return __INT_MAX__ + !i; }
constexpr int overflow_if_1 (int i) { return __INT_MAX__ + i; }
-constexpr bool i0_0 = overflow_if_0 (0); // { dg-error "overflow in constant expression" }
+constexpr bool i0_0 = overflow_if_0 (0); // { dg-error "overflow in constant expression|in .constexpr. expansion of" }
constexpr bool i0_1 = overflow_if_0 (1);
constexpr bool i1_0 = overflow_if_1 (0);
-constexpr bool i1_1 = overflow_if_1 (1); // { dg-error "overflow in constant expression" }
+constexpr bool i1_1 = overflow_if_1 (1); // { dg-error "overflow in constant expression|in .constexpr. expansion of" }
#endif
}
-constexpr bool b = f<int>(); // { dg-error "not a constant expression" }
+constexpr bool b = f<int>(); // { dg-error "not a constant expression|in .constexpr. expansion of " }
// --------------------
-struct complex // { dg-message "no constexpr constructor" }
+struct complex // { dg-message "no .constexpr. constructor" }
{
complex(double r, double i) : re(r), im(i) { }
constexpr double real() const { return re; } // { dg-error "not a literal type" "" { target c++11_only } }
};
constexpr complex co1(0, 1); // { dg-error "not literal" }
-constexpr double dd2 = co1.real(); // { dg-error "" }
+constexpr double dd2 = co1.real(); // { dg-error "|in .constexpr. expansion of " }
// --------------------
-struct base // { dg-message "no constexpr constructor" }
+struct base // { dg-message "no .constexpr. constructor" }
{
int _M_i;
base() : _M_i(5) { }
struct derived : public base // { dg-message "base class" }
{
- constexpr derived(): base() { } // { dg-error "non-constexpr function" }
+ constexpr derived(): base() { } // { dg-error "non-.constexpr. function" }
};
constexpr derived obj; // { dg-error "not literal" }
{
int _M_i; // { dg-message "does not initialize" }
- constexpr Def() = default; // { dg-error "implicit declaration is not constexpr" }
+ constexpr Def() = default; // { dg-error "implicit declaration is not .constexpr." }
};
constexpr Def defobj; // { dg-error "uninitialized" }
// 2 invoked with non-const args
-double x5 = 1.0; // { dg-message "not declared .constexpr" }
+double x5 = 1.0; // { dg-message "not declared .constexpr." }
constexpr complex unit(x5, 0); // { dg-error "x5|argument" } error: x5 non-constant
const complex one(x5, 0); // OK, ‘‘ordinary const’’ -- dynamic
// initialization
}
};
constexpr resource f(resource d)
-{ return d; } // { dg-error "non-constexpr" }
-constexpr resource d = f(9); // { dg-message "constexpr" }
+{ return d; } // { dg-error "non-.constexpr." }
+constexpr resource d = f(9); // { dg-message ".constexpr." }
// 4.4 floating-point constant expressions
// We should complain about this.
template<> constexpr int A<int>::f()
-{ return g(); } // { dg-error "non-constexpr" }
+{ return g(); } // { dg-error "non-.constexpr." }
// But not about this.
struct B
struct Foo {
constexpr Foo(const unsigned i) : val(i) {}
constexpr Foo operator-(const Foo &rhs) const {
- return assert(val >= rhs.val), Foo(val - rhs.val); // { dg-error "call to non-constexpr" }
+ return assert(val >= rhs.val), Foo(val - rhs.val); // { dg-error "call to non-.constexpr." }
}
unsigned val;
};
-constexpr Foo foo(Foo(1) - Foo(2));
+constexpr Foo foo(Foo(1) - Foo(2)); // { dg-message "in .constexpr. expansion of " }
struct B
{
A a[1];
- constexpr B() : a() {} // { dg-error "non-constant|non-constexpr" }
+ constexpr B() : a() {} // { dg-error "non-constant|non-.constexpr." }
};
C<D> c;
};
-constexpr D d {}; // { dg-error "non-constexpr function" }
+constexpr D d {}; // { dg-error "non-.constexpr. function" }
constexpr int square(int x); // { dg-message "never defined" }
// error: pixel is a type
-constexpr struct pixel { // { dg-error "constexpr" }
+constexpr struct pixel { // { dg-error ".constexpr." }
int x;
int y;
// OK: declaration
// error: square not defined, so small(2) not constant (5.19), so constexpr
// not satisfied
-constexpr pixel small(2); // { dg-message "in constexpr expansion" }
+constexpr pixel small(2); // { dg-message "in .constexpr. expansion of " }
// error: not for parameters
int next(constexpr int x) { // { dg-error "parameter" }
int r = 1;
while (--n > 0) r *= x;
return r;
-} // { dg-error "body of constexpr function" "" { target c++11_only } }
+} // { dg-error "body of .constexpr. function" "" { target c++11_only } }
class debug_flag {
public:
// { dg-do compile { target c++11 } }
// { dg-options "-fconstexpr-depth=5" }
// { dg-prune-output "in constexpr expansion" }
-constexpr int f (int i) { return f (i-1); }
-constexpr int i = f(42); // { dg-error "constexpr evaluation depth" }
+constexpr int f (int i) { return f (i-1); } // { dg-message "in .constexpr. expansion of " }
+constexpr int i = f(42); // { dg-error ".constexpr. evaluation depth|in .constexpr. expansion of " }
return i << j; // { dg-error "is negative" }
}
-constexpr int i1 = fn1 (1, -1);
+constexpr int i1 = fn1 (1, -1); // { dg-message "in .constexpr. expansion of " }
constexpr int
fn2 (int i, int j)
return i << j; // { dg-error "is >= than the precision of the left operand" }
}
-constexpr int i2 = fn2 (1, 200);
+constexpr int i2 = fn2 (1, 200); // { dg-message "in .constexpr. expansion of " }
constexpr int
fn3 (int i, int j)
return i << j; // { dg-error "is negative" }
}
-constexpr int i3 = fn3 (-1, 2);
+constexpr int i3 = fn3 (-1, 2); // { dg-message "in .constexpr. expansion of " }
constexpr int
fn4 (int i, int j)
return i << j; // { dg-error "overflows" }
}
-constexpr int i4 = fn4 (__INT_MAX__, 2);
+constexpr int i4 = fn4 (__INT_MAX__, 2); // { dg-message "in .constexpr. expansion of " }
constexpr int
fn5 (int i, int j)
return i << j; // { dg-error "is >= than the precision of the left operand" }
}
-constexpr int i6 = fn6 (1, -1);
+constexpr int i6 = fn6 (1, -1); // { dg-message "in .constexpr. expansion of " }
constexpr int
fn7 (int i, int j)
return i >> j; // { dg-error "is negative" }
}
-constexpr int i7 = fn7 (1, -1);
+constexpr int i7 = fn7 (1, -1); // { dg-message "in .constexpr. expansion of " }
constexpr int
fn8 (int i, int j)
return i >> j; // { dg-error "is >= than the precision of the left operand" }
}
-constexpr int i9 = fn9 (1, 200);
+constexpr int i9 = fn9 (1, 200); // { dg-message "in .constexpr. expansion of " }
template<typename T> bool foo(T)
{
int i;
- static_assert(foo(i), "Error"); // { dg-error "non-constant condition|not usable|non-constexpr" }
+ static_assert(foo(i), "Error"); // { dg-error "non-constant condition|not usable|non-.constexpr." }
return true;
}
return t;
}
-static_assert (foo (1) == 0, ""); // { dg-error "non-constant" }
+static_assert (foo (1) == 0, ""); // { dg-error "non-constant|in .constexpr. expansion of " }
return t;
}
-static_assert (foo (1) == 0, ""); // { dg-error "non-constant" }
+static_assert (foo (1) == 0, ""); // { dg-error "non-constant|in .constexpr. expansion of " }
return a[y];
}
-constexpr int b = foo (0, -1); // { dg-error "is outside the bounds" }
-constexpr int c = foo (0, 6); // { dg-error "is outside the bounds" }
-constexpr int d = foo (6, 0); // { dg-error "is outside the bounds" }
-constexpr int e = foo (-1, 0); // { dg-error "is outside the bounds" }
+constexpr int b = foo (0, -1); // { dg-error "is outside the bounds|in .constexpr. expansion of " }
+constexpr int c = foo (0, 6); // { dg-error "is outside the bounds|in .constexpr. expansion of " }
+constexpr int d = foo (6, 0); // { dg-error "is outside the bounds|in .constexpr. expansion of " }
+constexpr int e = foo (-1, 0); // { dg-error "is outside the bounds|in .constexpr. expansion of " }
static_assert (foo (5, 5) == 0, "");
static_assert (foo (4, 5) == 6, "");
static_assert (foo (5, 4) == 5, "");
if (b) {
return nullptr;
} else {
- return new int{42}; // { dg-error "call to non-constexpr" }
+ return new int{42}; // { dg-error "call to non-.constexpr." }
}
}
static_assert(f4(true) == nullptr, "");
-static_assert(f4(false) == nullptr, ""); // { dg-error "non-constant condition" }
+static_assert(f4(false) == nullptr, ""); // { dg-error "non-.constant. condition|" }
{
}
-constexpr int i = f(42); // { dg-error "flows off the end" }
+constexpr int i = f(42); // { dg-error "flows off the end|in .constexpr. expansion of " }
{
return ((__PTRDIFF_TYPE__) &p) << a; // { dg-error "is not a constant expression" }
}
-constexpr __PTRDIFF_TYPE__ r = bar (2);
+constexpr __PTRDIFF_TYPE__ r = bar (2); // { dg-message "in .constexpr. expansion of" }
constexpr __PTRDIFF_TYPE__ s = bar (0); // { dg-error "conversion from pointer" }
}
static_assert(fun(0), "");
-static_assert(fun(1), ""); // { dg-error "non-constant" }
+static_assert(fun(1), ""); // { dg-error "non-constant|in .constexpr. expansion of" }
int a[i] = { }; // { dg-error "forbids variable length" }
}
-constexpr int j = foo (1); // { dg-error "flows off the end" }
-
+constexpr int j = foo (1); // { dg-error "flows off the end|in .constexpr. expansion of" }
}
float32x4_t foo(float32x4_t x) {
- constexpr float32x4_t v = fill(1.f); // { dg-error "not a constant" }
+ constexpr float32x4_t v = fill(1.f); // { dg-error "not a constant||in .constexpr. expansion of " }
return x+v;
}
const char *s[]{a...};
P<sizeof...(a)> p{};
for (auto i = 0; i < sizeof...(a); ++i)
- p.foo (s[i], i);
+ p.foo (s[i], i); // { dg-message "in .constexpr. expansion of " }
return p;
}
int
main ()
{
- constexpr auto a = bar ("", ""); // { dg-error "outside the bounds of array type" }
+ constexpr auto a = bar ("", ""); // { dg-error "outside the bounds of array type|in .constexpr. expansion of " }
}
// expression.
auto two = monoid(2);
if (!(two() == 2)) __builtin_abort(); // OK, not a constant expression.
- static_assert(add(one)(one)() == two()); // { dg-error "" } two() is not a constant expression
+ static_assert(add(one)(one)() == two()); // { dg-error "|in .constexpr. expansion of " } two() is not a constant expression
static_assert(add(one)(one)() == monoid(2)()); // OK
}
}
constexpr int n1 = fn_ok (3);
-constexpr int n2 = fn_not_ok (3); // { dg-error "array subscript" }
+constexpr int n2 = fn_not_ok (3); // { dg-error "array subscript|in .constexpr. expansion of " }
fn_bad (int n)
{
__extension__ int a [n] = { 0 };
- int z = a [0] + (n ? fn_bad (n - 1) : 0);
+ int z = a [0] + (n ? fn_bad (n - 1) : 0); // { dg-message "in .constexpr. expansion of " }
return z;
}
}
constexpr int i1 = fn_ok (3);
-constexpr int i2 = fn_bad (3); // { dg-error "array subscript" }
+constexpr int i2 = fn_bad (3); // { dg-error "array subscript|in .constexpr. expansion of " }
return z;
}
-constexpr int n = foo (3); // { dg-error "array subscript" }
+constexpr int n = foo (3); // { dg-error "array subscript|in .constexpr. expansion of " }
}
constexpr int i1 = fn1 (5, 3);
-constexpr int i2 = fn1 (5, -2); // { dg-message "in constexpr expansion" }
-constexpr int i3 = fn1 (5, sizeof (int) * __CHAR_BIT__); // { dg-message "in constexpr expansion" }
-constexpr int i4 = fn1 (5, 256); // { dg-message "in constexpr expansion" }
+constexpr int i2 = fn1 (5, -2); // { dg-message "in .constexpr. expansion" }
+constexpr int i3 = fn1 (5, sizeof (int) * __CHAR_BIT__); // { dg-message "in .constexpr. expansion" }
+constexpr int i4 = fn1 (5, 256); // { dg-message "in .constexpr. expansion" }
constexpr int i5 = fn1 (5, 2);
-constexpr int i6 = fn1 (-2, 4); // { dg-message "in constexpr expansion" }
+constexpr int i6 = fn1 (-2, 4); // { dg-message "in .constexpr. expansion" }
constexpr int i7 = fn1 (0, 2);
SA (i1 == 40);
}
constexpr int j1 = fn2 (4, 1);
-constexpr int j2 = fn2 (4, -1); // { dg-message "in constexpr expansion" }
-constexpr int j3 = fn2 (10, sizeof (int) * __CHAR_BIT__); // { dg-message "in constexpr expansion" }
-constexpr int j4 = fn2 (1, 256); // { dg-message "in constexpr expansion" }
+constexpr int j2 = fn2 (4, -1); // { dg-message "in .constexpr. expansion" }
+constexpr int j3 = fn2 (10, sizeof (int) * __CHAR_BIT__); // { dg-message "in .constexpr. expansion" }
+constexpr int j4 = fn2 (1, 256); // { dg-message "in .constexpr. expansion" }
constexpr int j5 = fn2 (5, 2);
constexpr int j6 = fn2 (-2, 4);
constexpr int j7 = fn2 (0, 4);
}
constexpr int k1 = fn3 (8, 4);
-constexpr int k2 = fn3 (7, 0); // { dg-message "in constexpr expansion" }
-constexpr int k3 = fn3 (INT_MIN, -1); // { dg-error "overflow in constant expression" }
+constexpr int k2 = fn3 (7, 0); // { dg-message "in .constexpr. expansion" }
+constexpr int k3 = fn3 (INT_MIN, -1); // { dg-error "overflow in constant expression|in .constexpr. expansion of " }
SA (k1 == 2);
}
constexpr float l1 = fn4 (5.0, 3.0);
-constexpr float l2 = fn4 (7.0, 0.0); // { dg-message "in constexpr expansion" }
+constexpr float l2 = fn4 (7.0, 0.0); // { dg-message "in .constexpr. expansion" }
constexpr int
fn5 (const int *a, int b)
constexpr int m1[4] = { 1, 2, 3, 4 };
constexpr int m2 = fn5 (m1, 3);
-constexpr int m3 = fn5 (m1, 4); // { dg-error "array subscript" }
+constexpr int m3 = fn5 (m1, 4); // { dg-error "array subscript|in .constexpr. expansion of " }
constexpr int
fn6 (const int &a, int b)
constexpr int n1 = 7;
constexpr int n2 = fn7 (&n1, 5);
-constexpr int n3 = fn7 ((const int *) 0, 8); // { dg-error "null pointer" }
+constexpr int n3 = fn7 ((const int *) 0, 8); // { dg-error "null pointer|in .constexpr. expansion of " }
constexpr int
fn8 (int i)
}
constexpr int o1 = fn8 (9);
-constexpr int o2 = fn8 (10); // { dg-error "array subscript" }
+constexpr int o2 = fn8 (10); // { dg-error "array subscript|in .constexpr. expansion of " }
constexpr int
fn9 (int a, int b)
}
constexpr int p1 = fn9 (42, 7);
-constexpr int p2 = fn9 (__INT_MAX__, 1); // { dg-error "overflow in constant expression" }
+constexpr int p2 = fn9 (__INT_MAX__, 1); // { dg-error "overflow in constant expression|in .constexpr. expansion of " }
constexpr int p3 = fn9 (__INT_MAX__, -1);
constexpr int p4 = fn9 (INT_MIN, 1);
-constexpr int p5 = fn9 (INT_MIN, -1); // { dg-error "overflow in constant expression" }
+constexpr int p5 = fn9 (INT_MIN, -1); // { dg-error "overflow in constant expression|in .constexpr. expansion of " }
SA (p1 == 49);
SA (p3 == __INT_MAX__ - 1);
}
constexpr int q1 = fn10 (10, 10);
-constexpr int q2 = fn10 (__INT_MAX__, 2); // { dg-error "overflow in constant expression" }
-constexpr int q3 = fn10 (INT_MIN, 2); // { dg-error "overflow in constant expression" }
+constexpr int q2 = fn10 (__INT_MAX__, 2); // { dg-error "overflow in constant expression|in .constexpr. expansion of " }
+constexpr int q3 = fn10 (INT_MIN, 2); // { dg-error "overflow in constant expression|in .constexpr. expansion of " }
constexpr int q4 = fn10 (-1, -1);
SA (q1 == 100);
}
constexpr int r1 = fn11 (3.4);
-constexpr int r2 = fn11 (__builtin_inf ()); // { dg-error "overflow in constant expression" }
+constexpr int r2 = fn11 (__builtin_inf ()); // { dg-error "overflow in constant expression|in .constexpr. expansion of " }
constexpr int
fn12 (int i)
}
constexpr int s1 = fn12 (1);
-constexpr int s2 = fn12 (42);
+constexpr int s2 = fn12 (42); // { dg-message "in .constexpr. expansion of " }
SA (s1 == 11);