From: Nathan Sidwell <nathan@acm.org>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [PR C++/83287] Mark lookup for keeping
Date: Tue, 05 Dec 2017 17:27:00 -0000 [thread overview]
Message-ID: <f7601ad8-682c-cb45-1342-78eda66b2d1b@acm.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 390 bytes --]
This fixes 83287, a case where we failed to mark a lookup occuring
inside a template definition as being kept for instantiation. It turns
out that CAST_EXPR's single argument is a TREE_LIST, so we need to check
it for OVERLOADS. CAST_EXPR behaves this way because it's modelling a
function call. AFAICT it is the only node of this form.
applying to trunk.
nathan
--
Nathan Sidwell
[-- Attachment #2: 83287.diff --]
[-- Type: text/x-patch, Size: 965 bytes --]
Index: cp/tree.c
===================================================================
--- cp/tree.c (revision 255420)
+++ cp/tree.c (working copy)
@@ -3230,6 +3230,13 @@ build_min (enum tree_code code, tree tt,
}
va_end (p);
+
+ if (code == CAST_EXPR)
+ /* The single operand is a TREE_LIST, which we have to check. */
+ for (tree v = TREE_OPERAND (t, 0); v; v = TREE_CHAIN (v))
+ if (TREE_CODE (TREE_VALUE (v)) == OVERLOAD)
+ lookup_keep (TREE_VALUE (v), true);
+
return t;
}
Index: testsuite/g++.dg/lookup/pr83287.C
===================================================================
--- testsuite/g++.dg/lookup/pr83287.C (revision 0)
+++ testsuite/g++.dg/lookup/pr83287.C (working copy)
@@ -0,0 +1,19 @@
+// PR c++/83287 failed to keep lookup until instantiation time
+
+void foo ();
+
+namespace {
+ void foo (int);
+}
+
+template <class T>
+void bar ()
+{
+ T (*p)() = (T (*)(void)) foo;
+}
+
+void
+baz ()
+{
+ bar<void> ();
+}
reply other threads:[~2017-12-05 17:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f7601ad8-682c-cb45-1342-78eda66b2d1b@acm.org \
--to=nathan@acm.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).