> Am 31.10.2026 um 07:58 schrieb Stefan Schulze Frielinghaus 
> <[email protected]>:
> 
> From: Stefan Schulze Frielinghaus <[email protected]>
> 
> Since there is no front end available at link time, lto1 prints types by
> means of the generic tree pretty printer.  So far NULLPTR_TYPE was not
> handled which means we fell back to do_niy().  For example, printing
> 
>  note: type '<<< Unknown tree: nullptr_type >>>' should match type 'int'
> 
> instead of mentioning nullptr_t.  Fixed by handling NULLPTR_TYPE
> similarly as other _TYPE cases.
> 
> There is still some inconsistency left because the C++ FE prints the
> type sometimes with a suffix like `'T' {aka 'std::nullptr_t'}` when `T`
> is a typedef.  Therefore, messages between an LTO and non-LTO build may
> still differ a bit.

Ok

Thanks,
Richard 

> gcc/ChangeLog:
> 
>    * tree-pretty-print.cc (dump_generic_node): Handle NULLPTR_TYPE.
> 
> gcc/testsuite/ChangeLog:
> 
>    * gcc.dg/lto/nullptr-1_0.c: New test.
>    * gcc.dg/lto/nullptr-1_1.c: New test.
>    * g++.dg/lto/nullptr-1_0.C: New test.
>    * g++.dg/lto/nullptr-1_1.C: New test.
>    * g++.dg/lto/nullptr-2_0.C: New test.
>    * g++.dg/lto/nullptr-2_1.C: New test.
> ---
> Bootstrapped and regtested on s390x.  Ok for mainline?
> 
> gcc/testsuite/g++.dg/lto/nullptr-1_0.C | 14 ++++++++++++++
> gcc/testsuite/g++.dg/lto/nullptr-1_1.C |  7 +++++++
> gcc/testsuite/g++.dg/lto/nullptr-2_0.C | 16 ++++++++++++++++
> gcc/testsuite/g++.dg/lto/nullptr-2_1.C |  7 +++++++
> gcc/testsuite/gcc.dg/lto/nullptr-1_0.c | 16 ++++++++++++++++
> gcc/testsuite/gcc.dg/lto/nullptr-1_1.c |  7 +++++++
> gcc/tree-pretty-print.cc               |  3 +++
> 7 files changed, 70 insertions(+)
> create mode 100644 gcc/testsuite/g++.dg/lto/nullptr-1_0.C
> create mode 100644 gcc/testsuite/g++.dg/lto/nullptr-1_1.C
> create mode 100644 gcc/testsuite/g++.dg/lto/nullptr-2_0.C
> create mode 100644 gcc/testsuite/g++.dg/lto/nullptr-2_1.C
> create mode 100644 gcc/testsuite/gcc.dg/lto/nullptr-1_0.c
> create mode 100644 gcc/testsuite/gcc.dg/lto/nullptr-1_1.c
> 
> diff --git a/gcc/testsuite/g++.dg/lto/nullptr-1_0.C 
> b/gcc/testsuite/g++.dg/lto/nullptr-1_0.C
> new file mode 100644
> index 00000000000..b59417861e0
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/lto/nullptr-1_0.C
> @@ -0,0 +1,14 @@
> +// { dg-lto-do link }
> +// { dg-require-effective-target c++11 }
> +
> +// Check that the type decltype(nullptr) is pretty printed when LTO is 
> involved
> +
> +decltype (nullptr) x; // { dg-lto-message "type 'decltype\\(nullptr\\)' 
> should match type 'int'" }
> +
> +int get (void);
> +
> +int
> +main ()
> +{
> +  return get ();
> +}
> diff --git a/gcc/testsuite/g++.dg/lto/nullptr-1_1.C 
> b/gcc/testsuite/g++.dg/lto/nullptr-1_1.C
> new file mode 100644
> index 00000000000..c97765db58a
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/lto/nullptr-1_1.C
> @@ -0,0 +1,7 @@
> +extern int x; // { dg-lto-warning "type of 'x' does not match original 
> declaration" }
> +
> +int
> +get (void)
> +{
> +  return x;
> +}
> diff --git a/gcc/testsuite/g++.dg/lto/nullptr-2_0.C 
> b/gcc/testsuite/g++.dg/lto/nullptr-2_0.C
> new file mode 100644
> index 00000000000..7420ba24341
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/lto/nullptr-2_0.C
> @@ -0,0 +1,16 @@
> +// { dg-lto-do link }
> +// { dg-require-effective-target c++11 }
> +
> +// Check that the type std::nullptr_t is pretty printed when LTO is involved
> +
> +#include <cstddef>
> +
> +std::nullptr_t x; // { dg-lto-message "type 'nullptr_t' should match type 
> 'int'" }
> +
> +int get (void);
> +
> +int
> +main ()
> +{
> +  return get ();
> +}
> diff --git a/gcc/testsuite/g++.dg/lto/nullptr-2_1.C 
> b/gcc/testsuite/g++.dg/lto/nullptr-2_1.C
> new file mode 100644
> index 00000000000..c97765db58a
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/lto/nullptr-2_1.C
> @@ -0,0 +1,7 @@
> +extern int x; // { dg-lto-warning "type of 'x' does not match original 
> declaration" }
> +
> +int
> +get (void)
> +{
> +  return x;
> +}
> diff --git a/gcc/testsuite/gcc.dg/lto/nullptr-1_0.c 
> b/gcc/testsuite/gcc.dg/lto/nullptr-1_0.c
> new file mode 100644
> index 00000000000..f8b626ea994
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/lto/nullptr-1_0.c
> @@ -0,0 +1,16 @@
> +/* { dg-lto-do link } */
> +/* { dg-lto-additional-options "-std=c23" } */
> +
> +/* Check that the type nullptr_t is pretty printed when LTO is involved.  */
> +
> +#include <stddef.h>
> +
> +nullptr_t x; /* { dg-lto-message "type 'nullptr_t' should match type 'int'" 
> } */
> +
> +extern int get (void);
> +
> +int
> +main (void)
> +{
> +  return get ();
> +}
> diff --git a/gcc/testsuite/gcc.dg/lto/nullptr-1_1.c 
> b/gcc/testsuite/gcc.dg/lto/nullptr-1_1.c
> new file mode 100644
> index 00000000000..f8fa508f717
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/lto/nullptr-1_1.c
> @@ -0,0 +1,7 @@
> +extern int x; /* { dg-lto-warning "type of 'x' does not match original 
> declaration" } */
> +
> +int
> +get (void)
> +{
> +  return x;
> +}
> diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc
> index 34fc7080783..9655870cfc8 100644
> --- a/gcc/tree-pretty-print.cc
> +++ b/gcc/tree-pretty-print.cc
> @@ -2347,6 +2347,7 @@ dump_generic_node (pretty_printer *pp, tree node, int 
> spc, dump_flags_t flags,
>     case BOOLEAN_TYPE:
>     case BITINT_TYPE:
>     case OPAQUE_TYPE:
> +    case NULLPTR_TYPE:
>       {
>    unsigned int quals = TYPE_QUALS (node);
>    enum tree_code_class tclass;
> @@ -2483,6 +2484,8 @@ dump_generic_node (pretty_printer *pp, tree node, int 
> spc, dump_flags_t flags,
>          }
>        else if (TREE_CODE (node) == VOID_TYPE)
>          pp_string (pp, "void");
> +        else if (TREE_CODE (node) == NULLPTR_TYPE)
> +          pp_string (pp, "nullptr_t");
>        else
>               pp_string (pp, "<unnamed type>");
>      }
> --
> 2.55.0
> 

Reply via email to