diff mbox series

c++, libcpp: Use make_signed_t<size_t> in the 1z diagnostics

Message ID 20210204085351.GK4020736@tucnak
State New
Headers show
Series c++, libcpp: Use make_signed_t<size_t> in the 1z diagnostics | expand

Commit Message

Jakub Jelinek Feb. 4, 2021, 8:53 a.m. UTC
Hi!

The following patch uses make_signed_t<size_t> instead of
make_signed<size_t>::type in the diagnostics, because the former is shorter.
It is true that one can't use make_signed<size_t>::type in C++11 code (which
is why I haven't changed it in the testcase which is c++11 effective
target), but the message talks about C++23 and make_signed_t is a C++14 and
later feature, so I think it is fine.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2021-02-04  Jakub Jelinek  <jakub@redhat.com>

	* expr.c (cpp_classify_number): Use make_signed_t<size_t> instead of
	make_signed<size_t>::type in the diagnostics.

	* g++.dg/warn/Wsize_t-literals.C: Expect make_signed_t<size_t> instead
	of make_signed<size_t>::type in the diagnostics.


	Jakub

Comments

Jason Merrill Feb. 4, 2021, 4:03 p.m. UTC | #1
On 2/4/21 3:53 AM, Jakub Jelinek wrote:
> Hi!
> 
> The following patch uses make_signed_t<size_t> instead of
> make_signed<size_t>::type in the diagnostics, because the former is shorter.
> It is true that one can't use make_signed<size_t>::type in C++11 code (which
> is why I haven't changed it in the testcase which is c++11 effective
> target), but the message talks about C++23 and make_signed_t is a C++14 and
> later feature, so I think it is fine.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

> 2021-02-04  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* expr.c (cpp_classify_number): Use make_signed_t<size_t> instead of
> 	make_signed<size_t>::type in the diagnostics.
> 
> 	* g++.dg/warn/Wsize_t-literals.C: Expect make_signed_t<size_t> instead
> 	of make_signed<size_t>::type in the diagnostics.
> 
> --- libcpp/expr.c.jj	2021-02-03 20:45:37.114671441 +0100
> +++ libcpp/expr.c	2021-02-03 20:46:22.142168043 +0100
> @@ -820,7 +820,7 @@ cpp_classify_number (cpp_reader *pfile,
>          {
>   	  const char *message = (result & CPP_N_UNSIGNED) == CPP_N_UNSIGNED
>   				? N_("use of C++23 %<size_t%> integer constant")
> -				: N_("use of C++23 %<make_signed<size_t>::type%> integer constant");
> +				: N_("use of C++23 %<make_signed_t<size_t>%> integer constant");
>   	  cpp_warning_with_line (pfile, CPP_W_SIZE_T_LITERALS,
>   				 virtual_location, 0, message);
>          }
> --- gcc/testsuite/g++.dg/warn/Wsize_t-literals.C.jj	2021-02-03 20:45:37.101671586 +0100
> +++ gcc/testsuite/g++.dg/warn/Wsize_t-literals.C	2021-02-03 20:48:03.166038618 +0100
> @@ -8,5 +8,5 @@ std::size_t S1 = 5678ZU; // { dg-warning
>   std::size_t s2 = 1234uz; // { dg-warning {use of C\+\+23 .size_t. integer constant} "" { target c++20_down } }
>   std::size_t S2 = 5678UZ; // { dg-warning {use of C\+\+23 .size_t. integer constant} "" { target c++20_down } }
>   
> -std::make_signed<std::size_t>::type pd1 = 1234z; // { dg-warning {use of C\+\+23 .make_signed<size_t>::type. integer constant} "" { target c++20_down } }
> -std::make_signed<std::size_t>::type PD1 = 5678Z; // { dg-warning {use of C\+\+23 .make_signed<size_t>::type. integer constant} "" { target c++20_down } }
> +std::make_signed<std::size_t>::type pd1 = 1234z; // { dg-warning {use of C\+\+23 .make_signed_t<size_t>. integer constant} "" { target c++20_down } }
> +std::make_signed<std::size_t>::type PD1 = 5678Z; // { dg-warning {use of C\+\+23 .make_signed_t<size_t>. integer constant} "" { target c++20_down } }
> 
> 	Jakub
>
diff mbox series

Patch

--- libcpp/expr.c.jj	2021-02-03 20:45:37.114671441 +0100
+++ libcpp/expr.c	2021-02-03 20:46:22.142168043 +0100
@@ -820,7 +820,7 @@  cpp_classify_number (cpp_reader *pfile,
        {
 	  const char *message = (result & CPP_N_UNSIGNED) == CPP_N_UNSIGNED
 				? N_("use of C++23 %<size_t%> integer constant")
-				: N_("use of C++23 %<make_signed<size_t>::type%> integer constant");
+				: N_("use of C++23 %<make_signed_t<size_t>%> integer constant");
 	  cpp_warning_with_line (pfile, CPP_W_SIZE_T_LITERALS,
 				 virtual_location, 0, message);
        }
--- gcc/testsuite/g++.dg/warn/Wsize_t-literals.C.jj	2021-02-03 20:45:37.101671586 +0100
+++ gcc/testsuite/g++.dg/warn/Wsize_t-literals.C	2021-02-03 20:48:03.166038618 +0100
@@ -8,5 +8,5 @@  std::size_t S1 = 5678ZU; // { dg-warning
 std::size_t s2 = 1234uz; // { dg-warning {use of C\+\+23 .size_t. integer constant} "" { target c++20_down } }
 std::size_t S2 = 5678UZ; // { dg-warning {use of C\+\+23 .size_t. integer constant} "" { target c++20_down } }
 
-std::make_signed<std::size_t>::type pd1 = 1234z; // { dg-warning {use of C\+\+23 .make_signed<size_t>::type. integer constant} "" { target c++20_down } }
-std::make_signed<std::size_t>::type PD1 = 5678Z; // { dg-warning {use of C\+\+23 .make_signed<size_t>::type. integer constant} "" { target c++20_down } }
+std::make_signed<std::size_t>::type pd1 = 1234z; // { dg-warning {use of C\+\+23 .make_signed_t<size_t>. integer constant} "" { target c++20_down } }
+std::make_signed<std::size_t>::type PD1 = 5678Z; // { dg-warning {use of C\+\+23 .make_signed_t<size_t>. integer constant} "" { target c++20_down } }