c++: consistently diagnose bare CTAD placeholder in fn return type
authorPatrick Palka <ppalka@redhat.com>
Thu, 20 Jan 2022 14:22:27 +0000 (09:22 -0500)
committerPatrick Palka <ppalka@redhat.com>
Thu, 20 Jan 2022 14:22:27 +0000 (09:22 -0500)
Relax slightly the existing check for diagnosing a bare CTAD placeholder
as the return type of a function declarator to also handle the abstract
declarator case.

gcc/cp/ChangeLog:

* decl.cc (grokdeclarator): Diagnose a CTAD placeholder as
function return type even when !funcdecl_p.

gcc/testsuite/ChangeLog:

* g++.dg/other/pr88187.C: Adjust expected C++17 diagnostic.

gcc/cp/decl.cc
gcc/testsuite/g++.dg/other/pr88187.C

index 2dade75..1cbe9a3 100644 (file)
@@ -12647,11 +12647,11 @@ grokdeclarator (const cp_declarator *declarator,
                if (!tmpl)
                  if (tree late_auto = type_uses_auto (late_return_type))
                    tmpl = CLASS_PLACEHOLDER_TEMPLATE (late_auto);
-               if (tmpl && funcdecl_p)
+               if (tmpl)
                  {
-                   if (!dguide_name_p (unqualified_id))
+                   if (!funcdecl_p || !dguide_name_p (unqualified_id))
                      {
-                       error_at (declarator->id_loc, "deduced class "
+                       error_at (typespec_loc, "deduced class "
                                  "type %qD in function return type",
                                  DECL_NAME (tmpl));
                        inform (DECL_SOURCE_LOCATION (tmpl),
index 13466d3..7812e3f 100644 (file)
@@ -4,4 +4,4 @@
 template <int> struct A;
 void f (A ()); // { dg-error "6:variable or field 'f' declared void" "" { target c++14_down } }
                // { dg-error "missing template arguments before '\\(' token" "" { target c++14_down } .-1 }
-               // { dg-error "placeholder .A. not permitted in this context" "" { target c++17 } .-2 }
+               // { dg-error "deduced class type 'A' in function return type" "" { target c++17 } .-2 }