* [PR C++/83287] Mark lookup for keeping
@ 2017-12-05 17:27 Nathan Sidwell
0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2017-12-05 17:27 UTC (permalink / raw)
To: GCC Patches
[-- 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> ();
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-12-05 17:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-05 17:27 [PR C++/83287] Mark lookup for keeping 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).