+2019-10-09 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * decl.c (grok_ctor_properties): Use DECL_SOURCE_LOCATION.
+ * typeck.c (cp_build_binary_op): Use the op_location_t argument
+ in many error messages.
+
2019-10-08 Martin Sebor <msebor@redhat.com>
PR c++/92001
or implicitly defined), there's no need to worry about their
existence. Theoretically, they should never even be
instantiated, but that's hard to forestall. */
- error ("invalid constructor; you probably meant %<%T (const %T&)%>",
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "invalid constructor; you probably meant %<%T (const %T&)%>",
ctype, ctype);
return false;
}
if (t != error_mark_node)
{
if (complain & tf_error)
- permerror (input_location, "assuming cast to type %qT from overloaded function",
+ permerror (location,
+ "assuming cast to type %qT from overloaded function",
TREE_TYPE (t));
op0 = t;
}
if (t != error_mark_node)
{
if (complain & tf_error)
- permerror (input_location, "assuming cast to type %qT from overloaded function",
+ permerror (location,
+ "assuming cast to type %qT from overloaded function",
TREE_TYPE (t));
op1 = t;
}
{
if ((complain & tf_warning)
&& c_inhibit_evaluation_warnings == 0)
- warning (OPT_Wshift_count_negative,
- "right shift count is negative");
+ warning_at (location, OPT_Wshift_count_negative,
+ "right shift count is negative");
}
else
{
if (compare_tree_int (const_op1, TYPE_PRECISION (type0)) >= 0
&& (complain & tf_warning)
&& c_inhibit_evaluation_warnings == 0)
- warning (OPT_Wshift_count_overflow,
- "right shift count >= width of type");
+ warning_at (location, OPT_Wshift_count_overflow,
+ "right shift count >= width of type");
}
}
/* Avoid converting op1 to result_type later. */
&& tree_int_cst_sgn (const_op0) < 0
&& (complain & tf_warning)
&& c_inhibit_evaluation_warnings == 0)
- warning (OPT_Wshift_negative_value,
- "left shift of negative value");
+ warning_at (location, OPT_Wshift_negative_value,
+ "left shift of negative value");
if (TREE_CODE (const_op1) == INTEGER_CST)
{
if (tree_int_cst_lt (const_op1, integer_zero_node))
{
if ((complain & tf_warning)
&& c_inhibit_evaluation_warnings == 0)
- warning (OPT_Wshift_count_negative,
- "left shift count is negative");
+ warning_at (location, OPT_Wshift_count_negative,
+ "left shift count is negative");
}
else if (compare_tree_int (const_op1,
TYPE_PRECISION (type0)) >= 0)
{
if ((complain & tf_warning)
&& c_inhibit_evaluation_warnings == 0)
- warning (OPT_Wshift_count_overflow,
- "left shift count >= width of type");
+ warning_at (location, OPT_Wshift_count_overflow,
+ "left shift count >= width of type");
}
else if (TREE_CODE (const_op0) == INTEGER_CST
&& (complain & tf_warning))
if ((complain & tf_warning)
&& c_inhibit_evaluation_warnings == 0
&& (FLOAT_TYPE_P (type0) || FLOAT_TYPE_P (type1)))
- warning (OPT_Wfloat_equal,
- "comparing floating-point with %<==%> or %<!=%> is unsafe");
+ warning_at (location, OPT_Wfloat_equal,
+ "comparing floating-point with %<==%> "
+ "or %<!=%> is unsafe");
if (complain & tf_warning)
{
tree stripped_orig_op0 = tree_strip_any_location_wrapper (orig_op0);
&& !integer_zerop (cp_fully_fold (op1)))
|| (TREE_CODE (stripped_orig_op1) == STRING_CST
&& !integer_zerop (cp_fully_fold (op0))))
- warning (OPT_Waddress, "comparison with string literal results "
- "in unspecified behavior");
+ warning_at (location, OPT_Waddress,
+ "comparison with string literal results in "
+ "unspecified behavior");
}
build_type = boolean_type_node;
if (char_type_p (TREE_TYPE (orig_op1)))
{
auto_diagnostic_group d;
- if (warning (OPT_Wpointer_compare,
- "comparison between pointer and zero character "
- "constant"))
- inform (input_location,
- "did you mean to dereference the pointer?");
+ if (warning_at (location, OPT_Wpointer_compare,
+ "comparison between pointer and zero character "
+ "constant"))
+ inform (location,
+ "did you mean to dereference the pointer?");
}
warn_for_null_address (location, op0, complain);
}
if (char_type_p (TREE_TYPE (orig_op0)))
{
auto_diagnostic_group d;
- if (warning (OPT_Wpointer_compare,
+ if (warning_at (location, OPT_Wpointer_compare,
"comparison between pointer and zero character "
"constant"))
- inform (input_location,
+ inform (location,
"did you mean to dereference the pointer?");
}
warn_for_null_address (location, op1, complain);
else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
{
result_type = type0;
- if (complain & tf_error)
- permerror (input_location, "ISO C++ forbids comparison between pointer and integer");
+ if (complain & tf_error)
+ permerror (location, "ISO C++ forbids comparison between "
+ "pointer and integer");
else
return error_mark_node;
}
{
result_type = type1;
if (complain & tf_error)
- permerror (input_location, "ISO C++ forbids comparison between pointer and integer");
+ permerror (location, "ISO C++ forbids comparison between "
+ "pointer and integer");
else
return error_mark_node;
}
|| TREE_CODE (orig_op1) == STRING_CST)
{
if (complain & tf_warning)
- warning (OPT_Waddress, "comparison with string literal results "
- "in unspecified behavior");
+ warning_at (location, OPT_Waddress,
+ "comparison with string literal results "
+ "in unspecified behavior");
}
if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE)
{
result_type = type0;
if (extra_warnings && (complain & tf_warning))
- warning (OPT_Wextra,
- "ordered comparison of pointer with integer zero");
+ warning_at (location, OPT_Wextra,
+ "ordered comparison of pointer with integer zero");
}
else if (code1 == POINTER_TYPE && null_ptr_cst_p (orig_op0))
{
result_type = type1;
if (extra_warnings && (complain & tf_warning))
- warning (OPT_Wextra,
- "ordered comparison of pointer with integer zero");
+ warning_at (location, OPT_Wextra,
+ "ordered comparison of pointer with integer zero");
}
else if (null_ptr_cst_p (orig_op0) && null_ptr_cst_p (orig_op1))
/* One of the operands must be of nullptr_t type. */
{
result_type = type0;
if (complain & tf_error)
- permerror (input_location, "ISO C++ forbids comparison between pointer and integer");
- else
+ permerror (location, "ISO C++ forbids comparison between "
+ "pointer and integer");
+ else
return error_mark_node;
}
else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE)
{
result_type = type1;
if (complain & tf_error)
- permerror (input_location, "ISO C++ forbids comparison between pointer and integer");
- else
+ permerror (location, "ISO C++ forbids comparison between "
+ "pointer and integer");
+ else
return error_mark_node;
}
+2019-10-09 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * c-c++-common/Waddress-1.c: Test locations too.
+ * c-c++-common/Wpointer-compare-1.c: Likewise.
+ * c-c++-common/Wshift-count-negative-1.c: Likewise.
+ * c-c++-common/Wshift-count-overflow-1.c: Likewise.
+ * c-c++-common/Wshift-negative-value-1.c: Likewise.
+ * c-c++-common/Wshift-negative-value-2.c: Likewise.
+ * c-c++-common/Wshift-negative-value-5.c: Likewise.
+ * c-c++-common/pr48418.c: Likewise.
+ * c-c++-common/pr65830.c: Likewise.
+ * c-c++-common/pr69764.c: Likewise.
+ * g++.dg/cpp0x/constexpr-array-ptr10.C: Likewise.
+ * g++.dg/cpp0x/nullptr37.C: Likewise.
+ * g++.dg/template/crash126.C: Likewise.
+ * g++.dg/template/crash129.C: Likewise.
+ * g++.dg/warn/Wextra-3.C: Likewise.
+ * g++.dg/warn/Wfloat-equal-1.C: Likewise.
+ * g++.dg/warn/Wstring-literal-comparison-1.C: Likewise.
+ * g++.dg/warn/Wstring-literal-comparison-2.C: Likewise.
+ * g++.dg/warn/pointer-integer-comparison.C: Likewise.
+ * g++.old-deja/g++.jason/crash8.C: Likewise.
+
2019-10-09 Richard Biener <rguenther@suse.de>
* gcc.dg/vect/vect-outer-call-1.c: New testcase.
foo ()
{
return "foo1" != (void *) 0 /* { dg-bogus "comparison with string literal results in unspecified behavior" } */
- && "foo2" != (const char *) ((void *) 0) /* { dg-bogus "comparison with string literal results in unspecified behavior" } */
- && "foo3" != (const char *) ((void *) (10 - 10)) /* { dg-bogus "comparison with string literal results in unspecified behavior" } */
- && "foo4" != (const char *) ((void *) (&e - &e)) /* { dg-warning "comparison with string literal results in unspecified behavior" "" { target c } } */
- && "foo5" != "foo6"; /* { dg-warning "comparison with string literal results in unspecified behavior" } */
+ && "foo2" != (const char *) ((void *) 0) /* { dg-bogus "comparison with string literal results in unspecified behavior" } */
+ && "foo3" != (const char *) ((void *) (10 - 10)) /* { dg-bogus "comparison with string literal results in unspecified behavior" } */
+ && "foo4" != (const char *) ((void *) (&e - &e)) /* { dg-warning "15:comparison with string literal results in unspecified behavior" "" { target c } } */
+ && "foo5" != "foo6"; /* { dg-warning "15:comparison with string literal results in unspecified behavior" } */
}
{
int r = 0;
- r += p == '\0'; /* { dg-warning "comparison between pointer and zero character" } */
- r += p == L'\0'; /* { dg-warning "comparison between pointer and zero character" } */
- r += p != '\0'; /* { dg-warning "comparison between pointer and zero character" } */
- r += p != L'\0'; /* { dg-warning "comparison between pointer and zero character" } */
+ r += p == '\0'; /* { dg-warning "10:comparison between pointer and zero character" } */
+ r += p == L'\0'; /* { dg-warning "10:comparison between pointer and zero character" } */
+ r += p != '\0'; /* { dg-warning "10:comparison between pointer and zero character" } */
+ r += p != L'\0'; /* { dg-warning "10:comparison between pointer and zero character" } */
- r += '\0' == p; /* { dg-warning "comparison between pointer and zero character" } */
- r += L'\0' == p; /* { dg-warning "comparison between pointer and zero character" } */
- r += '\0' != p; /* { dg-warning "comparison between pointer and zero character" } */
- r += L'\0' != p; /* { dg-warning "comparison between pointer and zero character" } */
+ r += '\0' == p; /* { dg-warning "13:comparison between pointer and zero character" } */
+ r += L'\0' == p; /* { dg-warning "14:comparison between pointer and zero character" } */
+ r += '\0' != p; /* { dg-warning "13:comparison between pointer and zero character" } */
+ r += L'\0' != p; /* { dg-warning "14:comparison between pointer and zero character" } */
- r += q == '\0'; /* { dg-warning "comparison between pointer and zero character" } */
- r += q == L'\0'; /* { dg-warning "comparison between pointer and zero character" } */
- r += q != '\0'; /* { dg-warning "comparison between pointer and zero character" } */
- r += q != L'\0'; /* { dg-warning "comparison between pointer and zero character" } */
+ r += q == '\0'; /* { dg-warning "10:comparison between pointer and zero character" } */
+ r += q == L'\0'; /* { dg-warning "10:comparison between pointer and zero character" } */
+ r += q != '\0'; /* { dg-warning "10:comparison between pointer and zero character" } */
+ r += q != L'\0'; /* { dg-warning "10:comparison between pointer and zero character" } */
- r += '\0' == q; /* { dg-warning "comparison between pointer and zero character" } */
- r += L'\0' == q; /* { dg-warning "comparison between pointer and zero character" } */
- r += '\0' != q; /* { dg-warning "comparison between pointer and zero character" } */
- r += L'\0' != q; /* { dg-warning "comparison between pointer and zero character" } */
+ r += '\0' == q; /* { dg-warning "13:comparison between pointer and zero character" } */
+ r += L'\0' == q; /* { dg-warning "14:comparison between pointer and zero character" } */
+ r += '\0' != q; /* { dg-warning "13:comparison between pointer and zero character" } */
+ r += L'\0' != q; /* { dg-warning "14:comparison between pointer and zero character" } */
return r;
}
{
int r = 0;
- r += p == (char) 0; /* { dg-warning "comparison between pointer and zero character" } */
- r += p != (char) 0; /* { dg-warning "comparison between pointer and zero character" } */
+ r += p == (char) 0; /* { dg-warning "10:comparison between pointer and zero character" } */
+ r += p != (char) 0; /* { dg-warning "10:comparison between pointer and zero character" } */
- r += (char) 0 == p; /* { dg-warning "comparison between pointer and zero character" } */
- r += (char) 0 != p; /* { dg-warning "comparison between pointer and zero character" } */
+ r += (char) 0 == p; /* { dg-warning "17:comparison between pointer and zero character" } */
+ r += (char) 0 != p; /* { dg-warning "17:comparison between pointer and zero character" } */
return r;
}
void foo()
{
- unsigned i1 = 1U << -1; /* { dg-warning "left shift count is negative" } */
- unsigned i2 = 1U >> -1; /* { dg-warning "right shift count is negative" } */
+ unsigned i1 = 1U << -1; /* { dg-warning "20:left shift count is negative" } */
+ unsigned i2 = 1U >> -1; /* { dg-warning "20:right shift count is negative" } */
}
void foo()
{
- unsigned i1 = 1U << (sizeof(unsigned) * __CHAR_BIT__); /* { dg-warning "left shift count >= width of type" } */
- unsigned i2 = 1U >> (sizeof(unsigned) * __CHAR_BIT__); /* { dg-warning "right shift count >= width of type" } */
+ unsigned i1 = 1U << (sizeof(unsigned) * __CHAR_BIT__); /* { dg-warning "20:left shift count >= width of type" } */
+ unsigned i2 = 1U >> (sizeof(unsigned) * __CHAR_BIT__); /* { dg-warning "20:right shift count >= width of type" } */
}
enum E {
A = 0 << 1,
B = 1 << 1,
- C = -1 << 1, /* { dg-warning "left shift of negative value|not an integer constant" } */
+ C = -1 << 1, /* { dg-warning "10:left shift of negative value|not an integer constant" } */
/* { dg-error "left operand of shift expression" "shift" { target c++ } .-1 } */
D = 0 >> 1,
E = 1 >> 1,
int r = 0;
r += z << x;
r += o << x;
- r += m << x; /* { dg-warning "left shift of negative value" } */
+ r += m << x; /* { dg-warning "10:left shift of negative value" } */
r += 0 << x;
r += 1 << x;
- r += -1 << x; /* { dg-warning "left shift of negative value" } */
+ r += -1 << x; /* { dg-warning "11:left shift of negative value" } */
r += -1U << x;
return r;
}
enum E {
A = 0 << 1,
B = 1 << 1,
- C = -1 << 1, /* { dg-warning "left shift of negative value" } */
+ C = -1 << 1, /* { dg-warning "10:left shift of negative value" } */
/* { dg-error "not an integer constant" "no constant" { target c++ } .-1 } */
/* { dg-error "left operand of shift expression" "shift" { target c++ } .-2 } */
D = 0 >> 1,
int r = 0;
r += z << x;
r += o << x;
- r += m << x; /* { dg-warning "left shift of negative value" } */
+ r += m << x; /* { dg-warning "10:left shift of negative value" } */
r += 0 << x;
r += 1 << x;
- r += -1 << x; /* { dg-warning "left shift of negative value" } */
+ r += -1 << x; /* { dg-warning "11:left shift of negative value" } */
r += -1U << x;
return r;
}
enum E {
A = 0 << 1,
B = 1 << 1,
- C = -1 << 1, /* { dg-warning "left shift of negative value" } */
+ C = -1 << 1, /* { dg-warning "10:left shift of negative value" } */
D = 0 >> 1,
E = 1 >> 1,
F = -1 >> 1
int r = 0;
r += z << x;
r += o << x;
- r += m << x; /* { dg-warning "left shift of negative value" } */
+ r += m << x; /* { dg-warning "10:left shift of negative value" } */
r += 0 << x;
r += 1 << x;
- r += -1 << x; /* { dg-warning "left shift of negative value" } */
+ r += -1 << x; /* { dg-warning "11:left shift of negative value" } */
r += -1U << x;
return r;
}
const int a = sizeof (int) * __CHAR_BIT__;
const int b = -7;
int c = 0;
- c += x << a; /* { dg-warning "left shift count >= width of type" } */
- c += x << b; /* { dg-warning "left shift count is negative" } */
- c += x << (sizeof (int) * __CHAR_BIT__); /* { dg-warning "left shift count >= width of type" } */
- c += x << -7; /* { dg-warning "left shift count is negative" } */
- c += x >> a; /* { dg-warning "right shift count >= width of type" } */
- c += x >> b; /* { dg-warning "right shift count is negative" } */
- c += x >> (sizeof (int) * __CHAR_BIT__); /* { dg-warning "right shift count >= width of type" } */
- c += x >> -7; /* { dg-warning "right shift count is negative" } */
+ c += x << a; /* { dg-warning "10:left shift count >= width of type" } */
+ c += x << b; /* { dg-warning "10:left shift count is negative" } */
+ c += x << (sizeof (int) * __CHAR_BIT__); /* { dg-warning "10:left shift count >= width of type" } */
+ c += x << -7; /* { dg-warning "10:left shift count is negative" } */
+ c += x >> a; /* { dg-warning "10:right shift count >= width of type" } */
+ c += x >> b; /* { dg-warning "10:right shift count is negative" } */
+ c += x >> (sizeof (int) * __CHAR_BIT__); /* { dg-warning "10:right shift count >= width of type" } */
+ c += x >> -7; /* { dg-warning "10:right shift count is negative" } */
return c;
}
const int a = sizeof (int) * __CHAR_BIT__;
const int b = -7;
int c = 0;
- c += x << a; /* { dg-bogus "left shift count >= width of type" } */
- c += x << b; /* { dg-bogus "left shift count is negative" } */
- c += x >> a; /* { dg-bogus "right shift count >= width of type" } */
- c += x >> b; /* { dg-bogus "right shift count is negative" } */
+ c += x << a; /* { dg-bogus "10:left shift count >= width of type" } */
+ c += x << b; /* { dg-bogus "10:left shift count is negative" } */
+ c += x >> a; /* { dg-bogus "10:right shift count >= width of type" } */
+ c += x >> b; /* { dg-bogus "10:right shift count is negative" } */
return c;
}
unsigned char
fn1 (unsigned char a)
{
- return a >> ~6; /* { dg-warning "right shift count is negative" } */
+ return a >> ~6; /* { dg-warning "12:right shift count is negative" } */
}
unsigned short
fn2 (unsigned short a)
{
- return a >> ~6; /* { dg-warning "right shift count is negative" } */
+ return a >> ~6; /* { dg-warning "12:right shift count is negative" } */
}
unsigned int
fn3 (unsigned int a)
{
- return a >> ~6; /* { dg-warning "right shift count is negative" } */
+ return a >> ~6; /* { dg-warning "12:right shift count is negative" } */
}
unsigned char
fn4 (unsigned char a)
{
- return a >> 0xff03; /* { dg-warning "right shift count >= width of type" } */
+ return a >> 0xff03; /* { dg-warning "12:right shift count >= width of type" } */
}
unsigned short
fn5 (unsigned short a)
{
- return a >> 0xff03; /* { dg-warning "right shift count >= width of type" } */
+ return a >> 0xff03; /* { dg-warning "12:right shift count >= width of type" } */
}
unsigned int
fn6 (unsigned int a)
{
- return a >> 0xff03; /* { dg-warning "right shift count >= width of type" } */
+ return a >> 0xff03; /* { dg-warning "12:right shift count >= width of type" } */
}
constexpr bool b0 = p0; // { dg-warning "address of .A::i." }
constexpr bool b1 = p0 == 0; // { dg-warning "address of .A::i." }
constexpr bool b2 = p0 != 0; // { dg-warning "address of .A::i." }
-constexpr bool b3 = p0 < 0; // { dg-warning "ordered comparison" }
-constexpr bool b4 = p0 <= 0; // { dg-warning "ordered comparison" }
-constexpr bool b5 = p0 > 0; // { dg-warning "ordered comparison" }
-constexpr bool b6 = p0 >= 0; // { dg-warning "ordered comparison" }
+constexpr bool b3 = p0 < 0; // { dg-warning "25:ordered comparison" }
+constexpr bool b4 = p0 <= 0; // { dg-warning "25:ordered comparison" }
+constexpr bool b5 = p0 > 0; // { dg-warning "25:ordered comparison" }
+constexpr bool b6 = p0 >= 0; // { dg-warning "25:ordered comparison" }
constexpr bool b7 = !p0; // { dg-warning "address of .A::i." }
constexpr bool b8 = 0 == p0; // { dg-warning "address of .A::i." }
constexpr bool b9 = 0 != p0; // { dg-warning "address of .A::i." }
-constexpr bool b10 = 0 < p0; // { dg-warning "ordered comparison" }
-constexpr bool b11 = 0 <= p0; // { dg-warning "ordered comparison" }
-constexpr bool b12 = 0 > p0; // { dg-warning "ordered comparison" }
-constexpr bool b13 = 0 >= p0; // { dg-warning "ordered comparison" }
+constexpr bool b10 = 0 < p0; // { dg-warning "24:ordered comparison" }
+constexpr bool b11 = 0 <= p0; // { dg-warning "24:ordered comparison" }
+constexpr bool b12 = 0 > p0; // { dg-warning "24:ordered comparison" }
+constexpr bool b13 = 0 >= p0; // { dg-warning "24:ordered comparison" }
}
{
int r = 0;
- r += p == '\0'; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += p == L'\0'; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += p == u'\0'; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += p == U'\0'; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += p != '\0'; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += p != L'\0'; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += p != u'\0'; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += p != U'\0'; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += p == '\0'; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += p == L'\0'; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += p == u'\0'; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += p == U'\0'; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += p != '\0'; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += p != L'\0'; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += p != u'\0'; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += p != U'\0'; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += '\0' == p; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += L'\0' == p; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += u'\0' == p; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += U'\0' == p; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += '\0' != p; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += L'\0' != p; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += u'\0' != p; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += U'\0' != p; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += '\0' == p; // { dg-error "13:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += L'\0' == p; // { dg-error "14:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += u'\0' == p; // { dg-error "14:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += U'\0' == p; // { dg-error "14:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += '\0' != p; // { dg-error "13:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += L'\0' != p; // { dg-error "14:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += u'\0' != p; // { dg-error "14:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += U'\0' != p; // { dg-error "14:ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += q == '\0'; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += q == L'\0'; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += q == u'\0'; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += q == U'\0'; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += q != '\0'; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += q != L'\0'; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += q != u'\0'; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += q != U'\0'; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += q == '\0'; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += q == L'\0'; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += q == u'\0'; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += q == U'\0'; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += q != '\0'; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += q != L'\0'; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += q != u'\0'; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += q != U'\0'; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += '\0' == q; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += L'\0' == q; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += u'\0' == q; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += U'\0' == q; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += '\0' != q; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += L'\0' != q; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += u'\0' != q; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += U'\0' != q; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += '\0' == q; // { dg-error "13:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += L'\0' == q; // { dg-error "14:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += u'\0' == q; // { dg-error "14:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += U'\0' == q; // { dg-error "14:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += '\0' != q; // { dg-error "13:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += L'\0' != q; // { dg-error "14:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += u'\0' != q; // { dg-error "14:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += U'\0' != q; // { dg-error "14:ISO C\\+\\+ forbids comparison between pointer and integer" }
return r;
}
{
int r = 0;
- r += p == (char) 0; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += p != (char) 0; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += p == (char) 0; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += p != (char) 0; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += (char) 0 == p; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
- r += (char) 0 != p; // { dg-error "ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += (char) 0 == p; // { dg-error "17:ISO C\\+\\+ forbids comparison between pointer and integer" }
+ r += (char) 0 != p; // { dg-error "17:ISO C\\+\\+ forbids comparison between pointer and integer" }
return r;
}
{
A ();
A (A &);
- A (A < T, T >); // { dg-error "invalid constructor" }
+ A (A < T, T >); // { dg-error "3:invalid constructor" }
};
void f ()
// PR c++/79626
template <class a, class> struct b
-{ b(); b(b &); b(b< a, a >); }; // { dg-error "invalid constructor" }
+{ b(); b(b &); b(b< a, a >); }; // { dg-error "16:invalid constructor" }
int c(b< int, int >(b< int, int >()); // { dg-error "" }
extern void* p;
-int f1() { return ( p < 0 ? 1 : 0 ); } // { dg-warning "ordered comparison" }
-int f2() { return ( p <= 0 ? 1 : 0 ); } // { dg-warning "ordered comparison" }
-int f3() { return ( p > 0 ? 1 : 0 ); } // { dg-warning "ordered comparison" }
-int f4() { return ( p >= 0 ? 1 : 0 ); } // { dg-warning "ordered comparison" }
+int f1() { return ( p < 0 ? 1 : 0 ); } // { dg-warning "23:ordered comparison" }
+int f2() { return ( p <= 0 ? 1 : 0 ); } // { dg-warning "23:ordered comparison" }
+int f3() { return ( p > 0 ? 1 : 0 ); } // { dg-warning "23:ordered comparison" }
+int f4() { return ( p >= 0 ? 1 : 0 ); } // { dg-warning "23:ordered comparison" }
double a, b;
_Complex double c, d;
-int f(void) { return a == b; } /* { dg-warning "comparing floating-point" } */
-int g(void) { return c == d; } /* { dg-warning "comparing floating-point" } */
-int h(void) { return a != b; } /* { dg-warning "comparing floating-point" } */
-int i(void) { return c != d; } /* { dg-warning "comparing floating-point" } */
+int f(void) { return a == b; } /* { dg-warning "24:comparing floating-point" } */
+int g(void) { return c == d; } /* { dg-warning "24:comparing floating-point" } */
+int h(void) { return a != b; } /* { dg-warning "24:comparing floating-point" } */
+int i(void) { return c != d; } /* { dg-warning "24:comparing floating-point" } */
int test1(char *ptr)
{
- return ptr == "foo"; /* { dg-warning "comparison with string" } */
+ return ptr == "foo"; /* { dg-warning "14:comparison with string" } */
}
int test2()
int test1(char *ptr)
{
- return ptr == "foo"; /* { dg-warning "comparison with string" } */
+ return ptr == "foo"; /* { dg-warning "14:comparison with string" } */
}
int test2()
int foo (int i, void *p)
{
- if (i == p) // { dg-warning "ISO C.. forbids comparison between pointer and integer" }
+ if (i == p) // { dg-warning "9:ISO C.. forbids comparison between pointer and integer" }
return 0;
- else if (i != p) // { dg-warning "ISO C.. forbids comparison between pointer and integer" }
+ else if (i != p) // { dg-warning "14:ISO C.. forbids comparison between pointer and integer" }
return 1;
}
int bar (int i, void *p)
{
- if (i < p) // { dg-warning "ISO C.. forbids comparison between pointer and integer" }
+ if (i < p) // { dg-warning "9:ISO C.. forbids comparison between pointer and integer" }
return 0;
- else if (i >= p) // { dg-warning "ISO C.. forbids comparison between pointer and integer" }
+ else if (i >= p) // { dg-warning "14:ISO C.. forbids comparison between pointer and integer" }
return 1;
}
int baz (int i, void *p)
{
- if (i <= p) // { dg-warning "ISO C.. forbids comparison between pointer and integer" }
+ if (i <= p) // { dg-warning "9:ISO C.. forbids comparison between pointer and integer" }
return 0;
- else if (i > p) // { dg-warning "ISO C.. forbids comparison between pointer and integer" }
+ else if (i > p) // { dg-warning "14:ISO C.. forbids comparison between pointer and integer" }
return 1;
}
// { dg-do assemble }
struct A {
A();
- A(A); // { dg-error "" } copy ctor must take reference
+ A(A); // { dg-error "3:invalid constructor" } copy ctor must take reference
};
int main()
{