* c++: Fix nullptr deref [pr97460[
@ 2020-10-16 17:24 Nathan Sidwell
0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-10-16 17:24 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 412 bytes --]
My changes to friend handling meant that there are now cases where a
friend doesn't get a lang-specific object. So we need to check there
is one before looking inside it.
PR c++/97460
gcc/cp/
* pt.c (push_template_decl): Check DECL_LANG_SPECIFIC in friend
case.
gcc/testsuite/
* g++.dg/template/pr97460.C: New.
pushing to trunk
nathan
--
Nathan Sidwell
[-- Attachment #2: 97460.diff --]
[-- Type: text/x-patch, Size: 1026 bytes --]
diff --git c/gcc/cp/pt.c w/gcc/cp/pt.c
index 2a9a8fafaca..dc664ec3798 100644
--- c/gcc/cp/pt.c
+++ w/gcc/cp/pt.c
@@ -5877,7 +5877,8 @@ push_template_decl (tree decl, bool is_friend)
|| TREE_CODE (ctx) == FUNCTION_DECL
|| (CLASS_TYPE_P (ctx) && TYPE_BEING_DEFINED (ctx))
|| (TREE_CODE (decl) == TYPE_DECL && LAMBDA_TYPE_P (TREE_TYPE (decl)))
- || (is_friend && !DECL_TEMPLATE_INFO (decl)))
+ || (is_friend && !(DECL_LANG_SPECIFIC (decl)
+ && DECL_TEMPLATE_INFO (decl))))
{
if (DECL_LANG_SPECIFIC (decl)
&& DECL_TEMPLATE_INFO (decl)
diff --git c/gcc/testsuite/g++.dg/template/pr97460.C w/gcc/testsuite/g++.dg/template/pr97460.C
new file mode 100644
index 00000000000..6dea4898997
--- /dev/null
+++ w/gcc/testsuite/g++.dg/template/pr97460.C
@@ -0,0 +1,9 @@
+// PR 97460
+// ICE, null dereference
+
+class io_context {
+ template <int> class basic_executor_type;
+};
+template <int> class io_context::basic_executor_type {
+ template <int> friend class basic_executor_type;
+};
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-10-16 17:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-16 17:24 c++: Fix nullptr deref [pr97460[ Nathan Sidwell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).