aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.cc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2023-08-11 21:13:23 -0400
committerPatrick Palka <ppalka@redhat.com>2023-08-11 21:13:23 -0400
commitf50f603cbfd05653555e9856360c83108bbd1d8a (patch)
tree99f332955c64ae70746baa6c6782dcc9a4e7898a /gcc/cp/decl.cc
parent066c260ad09dde95f43e503f7242b011d17a10f6 (diff)
downloadgcc-f50f603cbfd05653555e9856360c83108bbd1d8a.zip
gcc-f50f603cbfd05653555e9856360c83108bbd1d8a.tar.gz
gcc-f50f603cbfd05653555e9856360c83108bbd1d8a.tar.bz2
c++: bogus warning w/ deduction guide in anon ns [PR106604]
Here we're unintentionally issuing a "declared static but never defined" warning from wrapup_namespace_globals for a deduction guide declared in an anonymous namespace. This patch fixes this by giving deduction guides a dummy DECL_INITIAL, which suppresses the warning and also allows us to simplify redeclaration checking for them. Co-authored-by: Jason Merrill <jason@redhat.com> PR c++/106604 gcc/cp/ChangeLog: * decl.cc (redeclaration_error_message): Remove special handling for deduction guides. (grokfndecl): Give deduction guides a dummy DECL_INITIAL. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/class-deduction74.C: Expect "defined" instead of "declared" in the repeated deduction guide diagnostics. * g++.dg/cpp1z/class-deduction116.C: New test.
Diffstat (limited to 'gcc/cp/decl.cc')
-rw-r--r--gcc/cp/decl.cc14
1 files changed, 6 insertions, 8 deletions
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index e21e015..126c581 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -3297,10 +3297,6 @@ redeclaration_error_message (tree newdecl, tree olddecl)
}
}
- if (deduction_guide_p (olddecl)
- && deduction_guide_p (newdecl))
- return G_("deduction guide %q+D redeclared");
-
/* [class.compare.default]: A definition of a comparison operator as
defaulted that appears in a class shall be the first declaration of
that function. */
@@ -3355,10 +3351,6 @@ redeclaration_error_message (tree newdecl, tree olddecl)
}
}
- if (deduction_guide_p (olddecl)
- && deduction_guide_p (newdecl))
- return G_("deduction guide %q+D redeclared");
-
/* Core issue #226 (C++11):
If a friend function template declaration specifies a
@@ -10352,6 +10344,12 @@ grokfndecl (tree ctype,
DECL_CXX_DESTRUCTOR_P (decl) = 1;
DECL_NAME (decl) = dtor_identifier;
break;
+ case sfk_deduction_guide:
+ /* Give deduction guides a definition even though they don't really
+ have one: the restriction that you can't repeat a deduction guide
+ makes them more like a definition anyway. */
+ DECL_INITIAL (decl) = void_node;
+ break;
default:
break;
}