This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++/84812] ICE with local fn decl
- From: Nathan Sidwell <nathan at acm dot org>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 19 Mar 2018 10:04:47 -0400
- Subject: [C++/84812] ICE with local fn decl
This bug happens when the machinery to check for an implicit extern "C"
linkage on a local declaration, meets an ambiguous local lookup. I was
misled by a comment that implied TREE_LIST -> overload. That was true
way back, but now means ambiguous lookup.
I declined the opportunity to micro-optimize the test to 'TREE_CODE (x)
== ERROR_MARK || TTEE_CODE (X) == TREE_LIST'.
nathan
--
Nathan Sidwell
2018-03-19 Nathan Sidwell <nathan@acm.org>
PR c++/84812
* name-lookup.c (set_local_extern_decl_linkage): Defend against
ambiguous lookups.
PR c++/84812
* g++.dg/lookup/pr84812.C: New.
Index: cp/name-lookup.c
===================================================================
--- cp/name-lookup.c (revision 258642)
+++ cp/name-lookup.c (working copy)
@@ -2878,7 +2878,9 @@ set_local_extern_decl_linkage (tree decl
= find_namespace_value (current_namespace, DECL_NAME (decl));
loc_value = ns_value;
}
- if (loc_value == error_mark_node)
+ if (loc_value == error_mark_node
+ /* An ambiguous lookup. */
+ || (loc_value && TREE_CODE (loc_value) == TREE_LIST))
loc_value = NULL_TREE;
for (ovl_iterator iter (loc_value); iter; ++iter)
@@ -2926,7 +2928,8 @@ set_local_extern_decl_linkage (tree decl
if (ns_value == decl)
ns_value = find_namespace_value (current_namespace, DECL_NAME (decl));
- if (ns_value == error_mark_node)
+ if (ns_value == error_mark_node
+ || (ns_value && TREE_CODE (ns_value) == TREE_LIST))
ns_value = NULL_TREE;
for (ovl_iterator iter (ns_value); iter; ++iter)
Index: testsuite/g++.dg/lookup/pr84812.C
===================================================================
--- testsuite/g++.dg/lookup/pr84812.C (revision 0)
+++ testsuite/g++.dg/lookup/pr84812.C (working copy)
@@ -0,0 +1,18 @@
+// PR 84812. ICE determining implicit "C" linkage
+
+struct A { void foo(); };
+struct B { void foo(); };
+
+struct C : A, B
+{
+ void X ();
+};
+
+void C::X ()
+{
+ void foo (); // local decl of ::foo
+
+ foo ();
+}
+
+// { dg-final { scan-assembler "_Z3foov" } }