]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Fix non-portable default argument of make_auto_1 [PR104197]
authorPatrick Palka <ppalka@redhat.com>
Mon, 24 Jan 2022 16:47:13 +0000 (11:47 -0500)
committerPatrick Palka <ppalka@redhat.com>
Mon, 24 Jan 2022 16:47:13 +0000 (11:47 -0500)
Avoid using the macro current_template_depth, which expands to an
expression that uses __FUNCTION__, within the signature of a function.

PR c++/104197

gcc/cp/ChangeLog:

* pt.cc (make_auto_1): Use -1 as a placeholder default argument
for level.

gcc/cp/pt.cc

index bba62a5800abb833de8b442feb12cad83e5f27d6..8f50b9c4d3c2e2e18b148f091d6a89cfb5c63e9c 100644 (file)
@@ -28477,9 +28477,10 @@ make_args_non_dependent (vec<tree, va_gc> *args)
    by default.  If set_canonical is true, we set TYPE_CANONICAL on it.  */
 
 static tree
-make_auto_1 (tree name, bool set_canonical,
-            int level = current_template_depth + 1)
+make_auto_1 (tree name, bool set_canonical, int level = -1)
 {
+  if (level == -1)
+    level = current_template_depth + 1;
   tree au = cxx_make_type (TEMPLATE_TYPE_PARM);
   TYPE_NAME (au) = build_decl (input_location, TYPE_DECL, name, au);
   TYPE_STUB_DECL (au) = TYPE_NAME (au);