]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Diagnose non-uglified names even in requires exprs
authorJakub Jelinek <jakub@redhat.com>
Wed, 29 Apr 2026 05:58:46 +0000 (07:58 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 29 Apr 2026 05:58:46 +0000 (07:58 +0200)
I was worried we don't handle lambda parameters/captures,
but apparently we do (so I have just added tests to verify that),
and noticed we don't handle params of requires expressions, so
added test coverage for that and handled those in the plugins.

2026-04-29  Jakub Jelinek  <jakub@redhat.com>

* g++.dg/plugin/uglification_plugin.cc (plugin_check_tree): Walk
REQUIRES_EXPR_PARMS of REQUIRES_EXPR.
(plugin_walk_decl): Walk TEMPLATE_PARMS_CONSTRAINTS using
plugin_check_tree.  Walk DECL_INITIAL of CONCEPT_DECL as well.
* g++.dg/plugin/uglification.C: Add tests for non-uglified names
in lambda parameters, lambda captures and requires expressions.

Reviewed-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/testsuite/g++.dg/plugin/uglification.C
gcc/testsuite/g++.dg/plugin/uglification_plugin.cc

index 6193a3ba23076bc11a105cac0a28e0184178a32a..8f42e6325dd4708c069f7f77b6540ca588a11ab4 100644 (file)
@@ -148,4 +148,16 @@ namespace std {
       return ao;
     }
   };
+  void sed (int __ap) {
+    auto __aq = [] (int ar) {};                // { dg-message "note: non-uglified name 'ar'" }
+    auto __as = [at = __ap] () {};     // { dg-message "note: non-uglified name 'at'" }
+  }
+  template <typename _Tp>
+  concept eiusmod = requires (_Tp au) {        // { dg-message "note: non-uglified name 'au'" }
+    au++;
+  };
+  template <typename ..._Tp>
+  requires ((requires (const _Tp av) { // { dg-message "note: non-uglified name 'av'" }
+    av++; }) && ...)
+  void tempor (_Tp ...aw) {}           // { dg-message "note: non-uglified name 'aw'" }
 }
index 87fdc6616d1ad19ed3358231895191f33ce90000..760dbf38ff4f6586fa5633d77769c0cd160e8893 100644 (file)
@@ -89,6 +89,9 @@ plugin_check_tree (tree *tp, int */*walk_subtrees*/, void */*data*/)
       plugin_check_decl (var);
   if (TREE_CODE (*tp) == DECL_EXPR)
     plugin_check_decl (DECL_EXPR_DECL (*tp));
+  if (TREE_CODE (*tp) == REQUIRES_EXPR)
+    for (tree parm = REQUIRES_EXPR_PARMS (*tp); parm; parm = DECL_CHAIN (parm))
+      plugin_check_decl (parm);
   return NULL_TREE;
 }
 
@@ -153,6 +156,10 @@ plugin_walk_decl (tree decl)
       tree parms = DECL_INNERMOST_TEMPLATE_PARMS (decl);
       for (tree node : tree_vec_range (parms))
        plugin_check_decl (TREE_VALUE (node));
+      if (tree constr
+         = TEMPLATE_PARMS_CONSTRAINTS (DECL_TEMPLATE_PARMS (decl)))
+        cp_walk_tree_without_duplicates (&constr, plugin_check_tree,
+                                        NULL);
     }
 
   if (DECL_FUNCTION_TEMPLATE_P (decl))
@@ -162,6 +169,10 @@ plugin_walk_decl (tree decl)
           && DECL_TEMPLATE_INFO (decl))
     plugin_check_fn (decl);
 
+  if (TREE_CODE (STRIP_TEMPLATE (decl)) == CONCEPT_DECL)
+    cp_walk_tree_without_duplicates (&DECL_INITIAL (STRIP_TEMPLATE (decl)),
+                                    plugin_check_tree, NULL);
+
   if (DECL_CLASS_TEMPLATE_P (decl))
     decl = DECL_TEMPLATE_RESULT (decl);
   if (TREE_CODE (decl) == TYPE_DECL