+2016-08-05 Martin Sebor <msebor@redhat.com>
+
+ * constexpr.c (cxx_eval_store_expression): Remove hyphen from
+ the spelling of "constant-expression" in diagnostic messages
+ for consistency.
+ (cxx_eval_constant_expression): Same.
+ (cxx_eval_outermost_constant_expr): Same.
+ (potential_constant_expression_1): Same.
+
2016-08-05 Nathan Sidwell <nathan@acm.org>
PR c++/68724
/* A constant-expression cannot modify objects from outside the
constant-expression. */
if (!ctx->quiet)
- error ("modification of %qE is not a constant-expression", object);
+ error ("modification of %qE is not a constant expression", object);
*non_constant_p = true;
return t;
}
{
if (!ctx->quiet)
error_at (EXPR_LOC_OR_LOC (t, input_location),
- "a reinterpret_cast is not a constant-expression");
+ "a reinterpret_cast is not a constant expression");
*non_constant_p = true;
return t;
}
if (!ctx->quiet)
error_at (EXPR_LOC_OR_LOC (t, input_location),
"%<reinterpret_cast<%T>(%E)%> is not "
- "a constant-expression",
+ "a constant expression",
type, op);
*non_constant_p = true;
return t;
case OFFSET_REF:
if (!ctx->quiet)
error_at (EXPR_LOC_OR_LOC (t, input_location),
- "expression %qE is not a constant-expression", t);
+ "expression %qE is not a constant expression", t);
*non_constant_p = true;
break;
so for now just fail. */
if (!ctx->quiet)
error_at (EXPR_LOCATION (t),
- "statement is not a constant-expression");
+ "statement is not a constant expression");
}
else
internal_error ("unexpected expression %qE of kind %s", t,
{
if (!allow_non_constant)
error ("conversion from pointer type %qT "
- "to arithmetic type %qT in a constant-expression",
+ "to arithmetic type %qT in a constant expression",
TREE_TYPE (TREE_OPERAND (r, 0)), TREE_TYPE (r));
non_constant_p = true;
}
case AT_ENCODE_EXPR:
fail:
if (flags & tf_error)
- error ("expression %qE is not a constant-expression", t);
+ error ("expression %qE is not a constant expression", t);
return false;
case TYPEID_EXPR:
if (integer_zerop (denom))
{
if (flags & tf_error)
- error ("division by zero is not a constant-expression");
+ error ("division by zero is not a constant expression");
return false;
}
else
{
if (flags & tf_error)
error_at (location_of (t),
- "%<delete[]%> is not a constant-expression");
+ "%<delete[]%> is not a constant expression");
return false;
}
/* Fall through. */
want_rval, strict, tf_none))
return true;
if (flags & tf_error)
- error ("expression %qE is not a constant-expression", t);
+ error ("expression %qE is not a constant expression", t);
return false;
case VEC_INIT_EXPR:
if (breaks (target) || continues (target))
return true;
if (flags & tf_error)
- error ("%<goto%> is not a constant-expression");
+ error ("%<goto%> is not a constant expression");
return false;
}
+2016-08-05 Martin Sebor <msebor@redhat.com>
+
+ * g++.dg/cpp0x/constexpr-cast.C: Avoid assuming (void*)1 is spelled
+ 1ul in diagnostics. Remove hyphen from "constant-expression."
+ * g++.dg/cpp0x/constexpr-50060.C: Adjust.
+ * g++.dg/cpp0x/static_assert3.C: Same.
+ * g++.dg/cpp1y/constexpr-throw.C: Same.
+ * g++.dg/template/nontype3.C: Same.
+ * g++.dg/warn/overflow-warn-1.C: Same.
+ * g++.dg/warn/overflow-warn-3.C: Same.
+ * g++.dg/warn/overflow-warn-4.C: Same.
+
2016-08-05 David Malcolm <dmalcolm@redhat.com>
* gcc.dg/plugin/diagnostic-test-string-literals-1.c: New file.
struct T
{
- constexpr T (double a) : y {}, x ((y = 1, 0.8125)) {} // { dg-error "is not a constant-expression" "T" { target { ! c++14 } } }
+ constexpr T (double a) : y {}, x ((y = 1, 0.8125)) {} // { dg-error "is not a constant expression" "T" { target { ! c++14 } } }
double x;
int y;
};
constexpr void *q = reinterpret_cast<void*>(&i); // { dg-error "" "bug c++/49171" { xfail *-*-*-* } }
constexpr void *r0 = reinterpret_cast<void*>(1); // { dg-error "not a constant expression" }
-constexpr void *r1 = reinterpret_cast<void*>(sizeof 'x'); // { dg-error ".reinterpret_cast<void\\*>\\(1ul\\). is not a constant-expression" }
+constexpr void *r1 = reinterpret_cast<void*>(sizeof 'x'); // { dg-error ".reinterpret_cast<void\\*>\\(1\[ul\]\*\\). is not a constant expression" }
template <class T>
constexpr bool f ()
// { dg-do compile { target c++11 } }
static_assert(7 / 0, "X"); // { dg-error "non-constant condition" "non-constant" }
// { dg-warning "division by zero" "zero" { target *-*-* } 2 }
-// { dg-error "division by zero is not a constant-expression" "not a constant" { target *-*-* } 2 }
+// { dg-error "division by zero is not a constant expression" "not a constant" { target *-*-* } 2 }
constexpr void f2() {
if (true)
throw;
-} // { dg-error "not a constant-expression" }
+} // { dg-error "not a constant expression" }
constexpr void f3() {
if (false)
;
else
throw;
-}// { dg-error "not a constant-expression" }
+}// { dg-error "not a constant expression" }
constexpr void f4() {
throw;
-}// { dg-error "not a constant-expression" }
+}// { dg-error "not a constant expression" }
constexpr int fun(int n) {
switch (n) {
case 0:
return 1;
default:
- throw; // { dg-error "not a constant-expression" }
+ throw; // { dg-error "not a constant expression" }
}
}
void dep10(foo< PI[0] > *); // { dg-error "" "integral or enumeration" }
template <int I>
-void dep11(foo< *&I > *); // { dg-error "" "constant-expression" }
+void dep11(foo< *&I > *); // { dg-error "" "constant expression" }
template <int I>
-void dep12(foo< (&I)[4] > *); // { dg-error "" "constant-expression" }
+void dep12(foo< (&I)[4] > *); // { dg-error "" "constant expression" }
/* { dg-error "division by zero is not a constant.expression" "division" { target c++11 } 32 } */
/* { dg-warning "invalid conversion from" "convert" { target *-*-* } 56 } */
/* { dg-warning "invalid conversion from" "convert" { target c++11 } 58 } */
+/* { dg-error "division by zero is not a constant expression" "division" { target c++11 } 65 } */
/* { dg-error "is not a constant expression" "const" { target *-*-* } 65 } */
-/* { dg-error "division by zero is not a constant.expression" "division" { target c++11 } 65 } */
/* { dg-error "width not an integer constant" "bit.field" { target c++ } 32 } */
/* { dg-error "is not a constant expression" "division" { target c++ } 32 } */
switch (i)
{
case 0 * (1/0): /* { dg-warning "division by zero" } */
- ; /* { dg-error "is not a constant expression" "const" { target *-*-* } 67 } */
+ ; /* { dg-error "division by zero is not a constant expression" "division" { target c++11 } 67 } */
case 1 + 0 * (INT_MAX + 1): /* { dg-warning "integer overflow in expression" } */
/* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 69 } */
;
/* { dg-error "division by zero is not a constant.expression" "division" { target c++11 } 19 } */
/* { dg-error "division by zero is not a constant.expression" "division" { target c++11 } 32 } */
/* { dg-warning "invalid conversion from" "convert" { target c++11 } 60 } */
-/* { dg-error "division by zero is not a constant.expression" "division" { target c++11 } 67 } */
+/* { dg-error "not a constant expression" "constant" { target *-*-*-* } 67 } */
/* { dg-error "width not an integer constant" "bit.field" { target c++ } 32 } */
/* { dg-error "is not a constant expression" "division" { target c++ } 32 } */
switch (i)
{
case 0 * (1/0): /* { dg-warning "division by zero" } */
- ; /* { dg-error "is not a constant expression" "const" { target *-*-* } 70 } */
+ ; /* { dg-error "division by zero is not a constant expression" "division" { target c++11 } 70 } */
case 1 + 0 * (INT_MAX + 1): /* { dg-warning "integer overflow in expression" } */
/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 72 } */
;
/* { dg-error "division by zero is not a constant.expression" "division" { target c++11 } 19 } */
/* { dg-error "invalid conversion from" "convert" { target c++11 } 63 } */
/* { dg-error "division by zero is not a constant.expression" "division" { target c++11 } 34 } */
-/* { dg-error "division by zero is not a constant.expression" "division" { target c++11 } 70 } */
+/* { dg-error "is not a constant expression" "const" { target *-*-*-* } 70 } */
/* { dg-error "width not an integer constant" "bit.field" { target c++ } 34 } */
/* { dg-error "is not a constant expression" "division" { target c++ } 34 } */