On 1/20/26 6:02 AM, Marek Polacek wrote:
On Sat, Jan 17, 2026 at 04:31:09PM +0800, Jason Merrill wrote:
On 1/17/26 8:47 AM, Marek Polacek wrote:
I suppose this could/should wait till GCC 17.

Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

-- >8 --
During Reflection review it came up that is_std_substitution
handles NAMESPACE_DECLs accidentally: it wants either a class or a
class template, but is looking at the type of any decl.

Are there testcases affected by this?

I added code to check if we now return false for something that we
used to return true for, and found nothing.  I ran dg.exp and old-deja.exp.

Let's include such a checking_assert in the return false path.

gcc/cp/ChangeLog:

        * mangle.cc (is_std_substitution): Instead of any _DECL, only
        accept TYPE_DECL and DECL_CLASS_TEMPLATE_P.  Use NULL_TREE
        instead of NULL.
---
   gcc/cp/mangle.cc | 8 ++++----
   1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc
index 06bd396c03e..4887b7900de 100644
--- a/gcc/cp/mangle.cc
+++ b/gcc/cp/mangle.cc
@@ -478,7 +478,7 @@ add_substitution (tree node)
   }
   /* Helper function for find_substitution.  Returns nonzero if NODE,
-   which may be a decl or a CLASS_TYPE, is a template-id with template
+   which may be a class or a class template, is a template-id with template
      name of substitution_index[INDEX] in the ::std namespace, with
      global module attachment.  */
@@ -486,10 +486,10 @@ static bool
   is_std_substitution (const tree node,
                     const substitution_identifier_index_t index)
   {
-  tree type = NULL;
-  tree decl = NULL;
+  tree type = NULL_TREE;
+  tree decl = NULL_TREE;
-  if (DECL_P (node))
+  if (TREE_CODE (node) == TYPE_DECL || DECL_CLASS_TEMPLATE_P (node))
       {
         type = TREE_TYPE (node);
         decl = node;

base-commit: e6532f870a741f15082122eaa1120c72569fe6cf


Marek


Reply via email to