The libstdc++ manual documents that _T can not be used, because it's a macro in system headers on some targets.
PR libstdc++/94901 * include/std/type_traits (__is_complete_or_unbounded): Replace BADNAME _T with _Tp. * testsuite/17_intro/badnames.cc: New test. Tested powerpc64le-linux and x86_64-linux, committed to master. This should be backported to gcc-10 too.
commit 070b4df8a06539b661c134d436ea4207099fdcf0 Author: Jonathan Wakely <jwak...@redhat.com> Date: Fri May 1 13:13:39 2020 +0100 libstdc++: Replace reserved identifier _T with _Tp (PR 94901) The libstdc++ manual documents that _T can not be used, because it's a macro in system headers on some targets. PR libstdc++/94901 * include/std/type_traits (__is_complete_or_unbounded): Replace BADNAME _T with _Tp. * testsuite/17_intro/badnames.cc: New test. diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 75a98e38c0a..bc9a45b3746 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -197,8 +197,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Helper functions that return false_type for incomplete classes, // incomplete unions and arrays of known bound from those. - template <typename _T, size_t = sizeof(_T)> - constexpr true_type __is_complete_or_unbounded(__type_identity<_T>) + template <typename _Tp, size_t = sizeof(_Tp)> + constexpr true_type __is_complete_or_unbounded(__type_identity<_Tp>) { return {}; } template <typename _TypeIdentity, diff --git a/libstdc++-v3/testsuite/17_intro/badnames.cc b/libstdc++-v3/testsuite/17_intro/badnames.cc new file mode 100644 index 00000000000..aabd01255e2 --- /dev/null +++ b/libstdc++-v3/testsuite/17_intro/badnames.cc @@ -0,0 +1,72 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do compile { target x86_64-*-linux* } } + +// Names taken from coding_style.bad_identifiers in the libstdc++ manual. +// We can't test this on all targets, because these names are used in +// non-GCC system headers. Test on x86_64-linux where we know these particular +// names aren't used. + +// For Solaris: +#define _B _B is a BADNAME +#define _C _C is a BADNAME +#define _L _L is a BADNAME +#define _N _N is a BADNAME +#define _P _P is a BADNAME +#define _S _S is a BADNAME +#define _U _U is a BADNAME +#define _X _X is a BADNAME +#define _E1 _E1 is a BADNAME +#define _E2 _E2 is a BADNAME +#define _E3 _E3 is a BADNAME +#define _E4 _E4 is a BADNAME +#define _E5 _E5 is a BADNAME +#define _E6 _E6 is a BADNAME +#define _E7 _E7 is a BADNAME +#define _E8 _E8 is a BADNAME +#define _E9 _E9 is a BADNAME + // .. +#define _E24 _E24 is a BADNAME + +// Irix adds: +#define _A _A is a BADNAME +#define _G _G is a BADNAME + +// MS adds: +#define _T _T is a BADNAME + +// BSD adds: +#define __used __used is a BADNAME +#define __unused __unused is a BADNAME + // __inline (glibc uses this so can't test here) + // _Complex (glibc uses this so can't test here) +#define __istype __istype is a BADNAME +#define __maskrune __maskrune is a BADNAME +#define __tolower __tolower is a BADNAME +#define __toupper __toupper is a BADNAME +#define __wchar_t __wchar_t is a BADNAME +#define __wint_t __wint_t is a BADNAME + // _res + // _res_ext + // __tg_* + +// VxWorks adds: +#define _C2 _C2 is a BADNAME + + +#include <bits/stdc++.h>