Commit 8cb6a775 by Paolo Carlini Committed by Paolo Carlini

decl.c (grok_ctor_properties): Use DECL_SOURCE_LOCATION.

/cp
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.

/testsuite
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.

From-SVN: r276763
parent cc386cf2
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> 2019-10-08 Martin Sebor <msebor@redhat.com>
PR c++/92001 PR c++/92001
......
...@@ -13738,7 +13738,8 @@ grok_ctor_properties (const_tree ctype, const_tree decl) ...@@ -13738,7 +13738,8 @@ grok_ctor_properties (const_tree ctype, const_tree decl)
or implicitly defined), there's no need to worry about their or implicitly defined), there's no need to worry about their
existence. Theoretically, they should never even be existence. Theoretically, they should never even be
instantiated, but that's hard to forestall. */ 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); ctype, ctype);
return false; return false;
} }
......
...@@ -4475,7 +4475,8 @@ cp_build_binary_op (const op_location_t &location, ...@@ -4475,7 +4475,8 @@ cp_build_binary_op (const op_location_t &location,
if (t != error_mark_node) if (t != error_mark_node)
{ {
if (complain & tf_error) 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)); TREE_TYPE (t));
op0 = t; op0 = t;
} }
...@@ -4486,7 +4487,8 @@ cp_build_binary_op (const op_location_t &location, ...@@ -4486,7 +4487,8 @@ cp_build_binary_op (const op_location_t &location,
if (t != error_mark_node) if (t != error_mark_node)
{ {
if (complain & tf_error) 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)); TREE_TYPE (t));
op1 = t; op1 = t;
} }
...@@ -4809,16 +4811,16 @@ cp_build_binary_op (const op_location_t &location, ...@@ -4809,16 +4811,16 @@ cp_build_binary_op (const op_location_t &location,
{ {
if ((complain & tf_warning) if ((complain & tf_warning)
&& c_inhibit_evaluation_warnings == 0) && c_inhibit_evaluation_warnings == 0)
warning (OPT_Wshift_count_negative, warning_at (location, OPT_Wshift_count_negative,
"right shift count is negative"); "right shift count is negative");
} }
else else
{ {
if (compare_tree_int (const_op1, TYPE_PRECISION (type0)) >= 0 if (compare_tree_int (const_op1, TYPE_PRECISION (type0)) >= 0
&& (complain & tf_warning) && (complain & tf_warning)
&& c_inhibit_evaluation_warnings == 0) && c_inhibit_evaluation_warnings == 0)
warning (OPT_Wshift_count_overflow, warning_at (location, OPT_Wshift_count_overflow,
"right shift count >= width of type"); "right shift count >= width of type");
} }
} }
/* Avoid converting op1 to result_type later. */ /* Avoid converting op1 to result_type later. */
...@@ -4856,24 +4858,24 @@ cp_build_binary_op (const op_location_t &location, ...@@ -4856,24 +4858,24 @@ cp_build_binary_op (const op_location_t &location,
&& tree_int_cst_sgn (const_op0) < 0 && tree_int_cst_sgn (const_op0) < 0
&& (complain & tf_warning) && (complain & tf_warning)
&& c_inhibit_evaluation_warnings == 0) && c_inhibit_evaluation_warnings == 0)
warning (OPT_Wshift_negative_value, warning_at (location, OPT_Wshift_negative_value,
"left shift of negative value"); "left shift of negative value");
if (TREE_CODE (const_op1) == INTEGER_CST) if (TREE_CODE (const_op1) == INTEGER_CST)
{ {
if (tree_int_cst_lt (const_op1, integer_zero_node)) if (tree_int_cst_lt (const_op1, integer_zero_node))
{ {
if ((complain & tf_warning) if ((complain & tf_warning)
&& c_inhibit_evaluation_warnings == 0) && c_inhibit_evaluation_warnings == 0)
warning (OPT_Wshift_count_negative, warning_at (location, OPT_Wshift_count_negative,
"left shift count is negative"); "left shift count is negative");
} }
else if (compare_tree_int (const_op1, else if (compare_tree_int (const_op1,
TYPE_PRECISION (type0)) >= 0) TYPE_PRECISION (type0)) >= 0)
{ {
if ((complain & tf_warning) if ((complain & tf_warning)
&& c_inhibit_evaluation_warnings == 0) && c_inhibit_evaluation_warnings == 0)
warning (OPT_Wshift_count_overflow, warning_at (location, OPT_Wshift_count_overflow,
"left shift count >= width of type"); "left shift count >= width of type");
} }
else if (TREE_CODE (const_op0) == INTEGER_CST else if (TREE_CODE (const_op0) == INTEGER_CST
&& (complain & tf_warning)) && (complain & tf_warning))
...@@ -4920,8 +4922,9 @@ cp_build_binary_op (const op_location_t &location, ...@@ -4920,8 +4922,9 @@ cp_build_binary_op (const op_location_t &location,
if ((complain & tf_warning) if ((complain & tf_warning)
&& c_inhibit_evaluation_warnings == 0 && c_inhibit_evaluation_warnings == 0
&& (FLOAT_TYPE_P (type0) || FLOAT_TYPE_P (type1))) && (FLOAT_TYPE_P (type0) || FLOAT_TYPE_P (type1)))
warning (OPT_Wfloat_equal, warning_at (location, OPT_Wfloat_equal,
"comparing floating-point with %<==%> or %<!=%> is unsafe"); "comparing floating-point with %<==%> "
"or %<!=%> is unsafe");
if (complain & tf_warning) if (complain & tf_warning)
{ {
tree stripped_orig_op0 = tree_strip_any_location_wrapper (orig_op0); tree stripped_orig_op0 = tree_strip_any_location_wrapper (orig_op0);
...@@ -4930,8 +4933,9 @@ cp_build_binary_op (const op_location_t &location, ...@@ -4930,8 +4933,9 @@ cp_build_binary_op (const op_location_t &location,
&& !integer_zerop (cp_fully_fold (op1))) && !integer_zerop (cp_fully_fold (op1)))
|| (TREE_CODE (stripped_orig_op1) == STRING_CST || (TREE_CODE (stripped_orig_op1) == STRING_CST
&& !integer_zerop (cp_fully_fold (op0)))) && !integer_zerop (cp_fully_fold (op0))))
warning (OPT_Waddress, "comparison with string literal results " warning_at (location, OPT_Waddress,
"in unspecified behavior"); "comparison with string literal results in "
"unspecified behavior");
} }
build_type = boolean_type_node; build_type = boolean_type_node;
...@@ -4955,11 +4959,11 @@ cp_build_binary_op (const op_location_t &location, ...@@ -4955,11 +4959,11 @@ cp_build_binary_op (const op_location_t &location,
if (char_type_p (TREE_TYPE (orig_op1))) if (char_type_p (TREE_TYPE (orig_op1)))
{ {
auto_diagnostic_group d; auto_diagnostic_group d;
if (warning (OPT_Wpointer_compare, if (warning_at (location, OPT_Wpointer_compare,
"comparison between pointer and zero character " "comparison between pointer and zero character "
"constant")) "constant"))
inform (input_location, inform (location,
"did you mean to dereference the pointer?"); "did you mean to dereference the pointer?");
} }
warn_for_null_address (location, op0, complain); warn_for_null_address (location, op0, complain);
} }
...@@ -4978,10 +4982,10 @@ cp_build_binary_op (const op_location_t &location, ...@@ -4978,10 +4982,10 @@ cp_build_binary_op (const op_location_t &location,
if (char_type_p (TREE_TYPE (orig_op0))) if (char_type_p (TREE_TYPE (orig_op0)))
{ {
auto_diagnostic_group d; auto_diagnostic_group d;
if (warning (OPT_Wpointer_compare, if (warning_at (location, OPT_Wpointer_compare,
"comparison between pointer and zero character " "comparison between pointer and zero character "
"constant")) "constant"))
inform (input_location, inform (location,
"did you mean to dereference the pointer?"); "did you mean to dereference the pointer?");
} }
warn_for_null_address (location, op1, complain); warn_for_null_address (location, op1, complain);
...@@ -4996,8 +5000,9 @@ cp_build_binary_op (const op_location_t &location, ...@@ -4996,8 +5000,9 @@ cp_build_binary_op (const op_location_t &location,
else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE) else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
{ {
result_type = type0; result_type = type0;
if (complain & tf_error) 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 else
return error_mark_node; return error_mark_node;
} }
...@@ -5005,7 +5010,8 @@ cp_build_binary_op (const op_location_t &location, ...@@ -5005,7 +5010,8 @@ cp_build_binary_op (const op_location_t &location,
{ {
result_type = type1; result_type = type1;
if (complain & tf_error) 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 else
return error_mark_node; return error_mark_node;
} }
...@@ -5191,8 +5197,9 @@ cp_build_binary_op (const op_location_t &location, ...@@ -5191,8 +5197,9 @@ cp_build_binary_op (const op_location_t &location,
|| TREE_CODE (orig_op1) == STRING_CST) || TREE_CODE (orig_op1) == STRING_CST)
{ {
if (complain & tf_warning) if (complain & tf_warning)
warning (OPT_Waddress, "comparison with string literal results " warning_at (location, OPT_Waddress,
"in unspecified behavior"); "comparison with string literal results "
"in unspecified behavior");
} }
if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE) if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE)
...@@ -5267,15 +5274,15 @@ cp_build_binary_op (const op_location_t &location, ...@@ -5267,15 +5274,15 @@ cp_build_binary_op (const op_location_t &location,
{ {
result_type = type0; result_type = type0;
if (extra_warnings && (complain & tf_warning)) if (extra_warnings && (complain & tf_warning))
warning (OPT_Wextra, warning_at (location, OPT_Wextra,
"ordered comparison of pointer with integer zero"); "ordered comparison of pointer with integer zero");
} }
else if (code1 == POINTER_TYPE && null_ptr_cst_p (orig_op0)) else if (code1 == POINTER_TYPE && null_ptr_cst_p (orig_op0))
{ {
result_type = type1; result_type = type1;
if (extra_warnings && (complain & tf_warning)) if (extra_warnings && (complain & tf_warning))
warning (OPT_Wextra, warning_at (location, OPT_Wextra,
"ordered comparison of pointer with integer zero"); "ordered comparison of pointer with integer zero");
} }
else if (null_ptr_cst_p (orig_op0) && null_ptr_cst_p (orig_op1)) else if (null_ptr_cst_p (orig_op0) && null_ptr_cst_p (orig_op1))
/* One of the operands must be of nullptr_t type. */ /* One of the operands must be of nullptr_t type. */
...@@ -5284,16 +5291,18 @@ cp_build_binary_op (const op_location_t &location, ...@@ -5284,16 +5291,18 @@ cp_build_binary_op (const op_location_t &location,
{ {
result_type = type0; result_type = type0;
if (complain & tf_error) if (complain & tf_error)
permerror (input_location, "ISO C++ forbids comparison between pointer and integer"); permerror (location, "ISO C++ forbids comparison between "
else "pointer and integer");
else
return error_mark_node; return error_mark_node;
} }
else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE) else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE)
{ {
result_type = type1; result_type = type1;
if (complain & tf_error) if (complain & tf_error)
permerror (input_location, "ISO C++ forbids comparison between pointer and integer"); permerror (location, "ISO C++ forbids comparison between "
else "pointer and integer");
else
return error_mark_node; 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> 2019-10-09 Richard Biener <rguenther@suse.de>
* gcc.dg/vect/vect-outer-call-1.c: New testcase. * gcc.dg/vect/vect-outer-call-1.c: New testcase.
......
...@@ -8,8 +8,8 @@ int ...@@ -8,8 +8,8 @@ int
foo () foo ()
{ {
return "foo1" != (void *) 0 /* { dg-bogus "comparison with string literal results in unspecified behavior" } */ 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" } */ && "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" } */ && "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 } } */ && "foo4" != (const char *) ((void *) (&e - &e)) /* { dg-warning "15:comparison with string literal results in unspecified behavior" "" { target c } } */
&& "foo5" != "foo6"; /* { dg-warning "comparison with string literal results in unspecified behavior" } */ && "foo5" != "foo6"; /* { dg-warning "15:comparison with string literal results in unspecified behavior" } */
} }
...@@ -8,25 +8,25 @@ f1 (int *p, int **q) ...@@ -8,25 +8,25 @@ f1 (int *p, int **q)
{ {
int r = 0; int r = 0;
r += p == '\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 "comparison between pointer and zero character" } */ r += p == L'\0'; /* { dg-warning "10:comparison between pointer and zero character" } */
r += p != '\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 "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 += '\0' == p; /* { dg-warning "13:comparison between pointer and zero character" } */
r += L'\0' == p; /* { dg-warning "comparison between pointer and zero character" } */ r += L'\0' == p; /* { dg-warning "14:comparison between pointer and zero character" } */
r += '\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 "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 == '\0'; /* { dg-warning "10:comparison between pointer and zero character" } */
r += q == L'\0'; /* { dg-warning "comparison between pointer and zero character" } */ r += q == L'\0'; /* { dg-warning "10:comparison between pointer and zero character" } */
r += q != '\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 "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 += '\0' == q; /* { dg-warning "13:comparison between pointer and zero character" } */
r += L'\0' == q; /* { dg-warning "comparison between pointer and zero character" } */ r += L'\0' == q; /* { dg-warning "14:comparison between pointer and zero character" } */
r += '\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 "comparison between pointer and zero character" } */ r += L'\0' != q; /* { dg-warning "14:comparison between pointer and zero character" } */
return r; return r;
} }
...@@ -55,11 +55,11 @@ f3 (int *p) ...@@ -55,11 +55,11 @@ f3 (int *p)
{ {
int r = 0; int r = 0;
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 "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 "17: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" } */
return r; return r;
} }
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
void foo() void foo()
{ {
unsigned i1 = 1U << -1; /* { dg-warning "left shift count is negative" } */ unsigned i1 = 1U << -1; /* { dg-warning "20:left shift count is negative" } */
unsigned i2 = 1U >> -1; /* { dg-warning "right shift count is negative" } */ unsigned i2 = 1U >> -1; /* { dg-warning "20:right shift count is negative" } */
} }
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
void foo() void foo()
{ {
unsigned i1 = 1U << (sizeof(unsigned) * __CHAR_BIT__); /* { dg-warning "left 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 "right shift count >= width of type" } */ unsigned i2 = 1U >> (sizeof(unsigned) * __CHAR_BIT__); /* { dg-warning "20:right shift count >= width of type" } */
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
enum E { enum E {
A = 0 << 1, A = 0 << 1,
B = 1 << 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 } */ /* { dg-error "left operand of shift expression" "shift" { target c++ } .-1 } */
D = 0 >> 1, D = 0 >> 1,
E = 1 >> 1, E = 1 >> 1,
...@@ -23,10 +23,10 @@ left (int x) ...@@ -23,10 +23,10 @@ left (int x)
int r = 0; int r = 0;
r += z << x; r += z << x;
r += o << 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 += 0 << x;
r += 1 << 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; r += -1U << x;
return r; return r;
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
enum E { enum E {
A = 0 << 1, A = 0 << 1,
B = 1 << 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 "not an integer constant" "no constant" { target c++ } .-1 } */
/* { dg-error "left operand of shift expression" "shift" { target c++ } .-2 } */ /* { dg-error "left operand of shift expression" "shift" { target c++ } .-2 } */
D = 0 >> 1, D = 0 >> 1,
...@@ -24,10 +24,10 @@ left (int x) ...@@ -24,10 +24,10 @@ left (int x)
int r = 0; int r = 0;
r += z << x; r += z << x;
r += o << 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 += 0 << x;
r += 1 << 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; r += -1U << x;
return r; return r;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
enum E { enum E {
A = 0 << 1, A = 0 << 1,
B = 1 << 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, D = 0 >> 1,
E = 1 >> 1, E = 1 >> 1,
F = -1 >> 1 F = -1 >> 1
...@@ -23,10 +23,10 @@ left (int x) ...@@ -23,10 +23,10 @@ left (int x)
int r = 0; int r = 0;
r += z << x; r += z << x;
r += o << 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 += 0 << x;
r += 1 << 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; r += -1U << x;
return r; return r;
} }
......
...@@ -8,13 +8,13 @@ foo (int x) ...@@ -8,13 +8,13 @@ foo (int x)
const int a = sizeof (int) * __CHAR_BIT__; const int a = sizeof (int) * __CHAR_BIT__;
const int b = -7; const int b = -7;
int c = 0; int c = 0;
c += x << a; /* { dg-warning "left shift count >= width of type" } */ c += x << a; /* { dg-warning "10:left shift count >= width of type" } */
c += x << b; /* { dg-warning "left shift count is negative" } */ c += x << b; /* { dg-warning "10:left shift count is negative" } */
c += x << (sizeof (int) * __CHAR_BIT__); /* { dg-warning "left shift count >= width of type" } */ c += x << (sizeof (int) * __CHAR_BIT__); /* { dg-warning "10:left shift count >= width of type" } */
c += x << -7; /* { dg-warning "left shift count is negative" } */ c += x << -7; /* { dg-warning "10:left shift count is negative" } */
c += x >> a; /* { dg-warning "right shift count >= width of type" } */ c += x >> a; /* { dg-warning "10:right shift count >= width of type" } */
c += x >> b; /* { dg-warning "right shift count is negative" } */ c += x >> b; /* { dg-warning "10:right shift count is negative" } */
c += x >> (sizeof (int) * __CHAR_BIT__); /* { dg-warning "right shift count >= width of type" } */ c += x >> (sizeof (int) * __CHAR_BIT__); /* { dg-warning "10:right shift count >= width of type" } */
c += x >> -7; /* { dg-warning "right shift count is negative" } */ c += x >> -7; /* { dg-warning "10:right shift count is negative" } */
return c; return c;
} }
...@@ -8,9 +8,9 @@ foo (int x) ...@@ -8,9 +8,9 @@ foo (int x)
const int a = sizeof (int) * __CHAR_BIT__; const int a = sizeof (int) * __CHAR_BIT__;
const int b = -7; const int b = -7;
int c = 0; int c = 0;
c += x << a; /* { dg-bogus "left shift count >= width of type" } */ c += x << a; /* { dg-bogus "10:left shift count >= width of type" } */
c += x << b; /* { dg-bogus "left shift count is negative" } */ c += x << b; /* { dg-bogus "10:left shift count is negative" } */
c += x >> a; /* { dg-bogus "right shift count >= width of type" } */ c += x >> a; /* { dg-bogus "10:right shift count >= width of type" } */
c += x >> b; /* { dg-bogus "right shift count is negative" } */ c += x >> b; /* { dg-bogus "10:right shift count is negative" } */
return c; return c;
} }
...@@ -4,35 +4,35 @@ ...@@ -4,35 +4,35 @@
unsigned char unsigned char
fn1 (unsigned char a) 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 unsigned short
fn2 (unsigned short a) 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 unsigned int
fn3 (unsigned int a) 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 unsigned char
fn4 (unsigned char a) 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 unsigned short
fn5 (unsigned short a) 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 unsigned int
fn6 (unsigned int a) 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" } */
} }
...@@ -19,18 +19,18 @@ constexpr int *p0 = &i; ...@@ -19,18 +19,18 @@ constexpr int *p0 = &i;
constexpr bool b0 = p0; // { dg-warning "address of .A::i." } constexpr bool b0 = p0; // { dg-warning "address of .A::i." }
constexpr bool b1 = p0 == 0; // { 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 b2 = p0 != 0; // { dg-warning "address of .A::i." }
constexpr bool b3 = p0 < 0; // { dg-warning "ordered comparison" } constexpr bool b3 = p0 < 0; // { dg-warning "25:ordered comparison" }
constexpr bool b4 = p0 <= 0; // { dg-warning "ordered comparison" } constexpr bool b4 = p0 <= 0; // { dg-warning "25:ordered comparison" }
constexpr bool b5 = p0 > 0; // { dg-warning "ordered comparison" } constexpr bool b5 = p0 > 0; // { dg-warning "25:ordered comparison" }
constexpr bool b6 = p0 >= 0; // { dg-warning "ordered comparison" } constexpr bool b6 = p0 >= 0; // { dg-warning "25:ordered comparison" }
constexpr bool b7 = !p0; // { dg-warning "address of .A::i." } constexpr bool b7 = !p0; // { dg-warning "address of .A::i." }
constexpr bool b8 = 0 == 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 b9 = 0 != p0; // { dg-warning "address of .A::i." }
constexpr bool b10 = 0 < p0; // { dg-warning "ordered comparison" } constexpr bool b10 = 0 < p0; // { dg-warning "24:ordered comparison" }
constexpr bool b11 = 0 <= p0; // { dg-warning "ordered comparison" } constexpr bool b11 = 0 <= p0; // { dg-warning "24:ordered comparison" }
constexpr bool b12 = 0 > p0; // { dg-warning "ordered comparison" } constexpr bool b12 = 0 > p0; // { dg-warning "24:ordered comparison" }
constexpr bool b13 = 0 >= p0; // { dg-warning "ordered comparison" } constexpr bool b13 = 0 >= p0; // { dg-warning "24:ordered comparison" }
} }
......
...@@ -6,41 +6,41 @@ f1 (int *p, int **q) ...@@ -6,41 +6,41 @@ f1 (int *p, int **q)
{ {
int r = 0; int r = 0;
r += p == '\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 "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 "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 "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 "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 "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 "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 "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 += '\0' == p; // { dg-error "13:ISO C\\+\\+ forbids comparison between pointer and integer" }
r += L'\0' == p; // { dg-error "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 "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 "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 "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 "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 "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 "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 == '\0'; // { dg-error "10:ISO C\\+\\+ forbids comparison between pointer and integer" }
r += q == L'\0'; // { dg-error "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 "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 "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 "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 "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 "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 "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 += '\0' == q; // { dg-error "13:ISO C\\+\\+ forbids comparison between pointer and integer" }
r += L'\0' == q; // { dg-error "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 "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 "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 "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 "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 "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 "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; return r;
} }
...@@ -68,11 +68,11 @@ f3 (int *p) ...@@ -68,11 +68,11 @@ f3 (int *p)
{ {
int r = 0; int r = 0;
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 "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 "17: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" }
return r; return r;
} }
...@@ -4,7 +4,7 @@ template < class T, class > struct A ...@@ -4,7 +4,7 @@ template < class T, class > struct A
{ {
A (); A ();
A (A &); A (A &);
A (A < T, T >); // { dg-error "invalid constructor" } A (A < T, T >); // { dg-error "3:invalid constructor" }
}; };
void f () void f ()
......
// PR c++/79626 // PR c++/79626
template <class a, class> struct b 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 "" } int c(b< int, int >(b< int, int >()); // { dg-error "" }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
extern void* p; extern void* p;
int f1() { 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 "ordered comparison" } int f2() { return ( p <= 0 ? 1 : 0 ); } // { dg-warning "23:ordered comparison" }
int f3() { return ( p > 0 ? 1 : 0 ); } // { dg-warning "ordered comparison" } int f3() { return ( p > 0 ? 1 : 0 ); } // { dg-warning "23:ordered comparison" }
int f4() { return ( p >= 0 ? 1 : 0 ); } // { dg-warning "ordered comparison" } int f4() { return ( p >= 0 ? 1 : 0 ); } // { dg-warning "23:ordered comparison" }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
double a, b; double a, b;
_Complex double c, d; _Complex double c, d;
int f(void) { return a == b; } /* { 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 "comparing floating-point" } */ int g(void) { return c == d; } /* { dg-warning "24:comparing floating-point" } */
int h(void) { return a != b; } /* { dg-warning "comparing floating-point" } */ int h(void) { return a != b; } /* { dg-warning "24:comparing floating-point" } */
int i(void) { return c != d; } /* { dg-warning "comparing floating-point" } */ int i(void) { return c != d; } /* { dg-warning "24:comparing floating-point" } */
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
int test1(char *ptr) int test1(char *ptr)
{ {
return ptr == "foo"; /* { dg-warning "comparison with string" } */ return ptr == "foo"; /* { dg-warning "14:comparison with string" } */
} }
int test2() int test2()
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
int test1(char *ptr) int test1(char *ptr)
{ {
return ptr == "foo"; /* { dg-warning "comparison with string" } */ return ptr == "foo"; /* { dg-warning "14:comparison with string" } */
} }
int test2() int test2()
......
...@@ -3,24 +3,24 @@ ...@@ -3,24 +3,24 @@
int foo (int i, void *p) 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; 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; return 1;
} }
int bar (int i, void *p) 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; 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; return 1;
} }
int baz (int i, void *p) 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; 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; return 1;
} }
// { dg-do assemble } // { dg-do assemble }
struct A { struct A {
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() int main()
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment