[C++/84812] ICE with local fn decl
authorNathan Sidwell <nathan@acm.org>
Mon, 19 Mar 2018 14:07:07 +0000 (14:07 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Mon, 19 Mar 2018 14:07:07 +0000 (14:07 +0000)
https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00872.html
PR c++/84812
* name-lookup.c (set_local_extern_decl_linkage): Defend against
ambiguous lookups.

PR c++/84812
* g++.dg/lookup/pr84812.C: New.

From-SVN: r258644

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/pr84812.C [new file with mode: 0644]

index 2a8da084445416a3f33254758a4afbb820fb1bf6..66226033e4132f3657ee6f02bf8054a1bb925570 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-19  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/84812
+       * name-lookup.c (set_local_extern_decl_linkage): Defend against
+       ambiguous lookups.
+
 2018-03-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/84910
index 80a92ab0ac4874109eaaf0c02b6ae386d669c776..cc8bb2f81c68e960dca11a81f1e15795f7fef171 100644 (file)
@@ -2878,7 +2878,9 @@ set_local_extern_decl_linkage (tree decl, bool shadowed)
            = 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, bool shadowed)
       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 868d8e8f7a63da0574dcb280c16d1edd1aaadd3f..337b4bd1f25229eda5519f8743d795b6c043fd83 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-19  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/84812
+       * g++.dg/lookup/pr84812.C: New.
+
 2018-03-19  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/84929
diff --git a/gcc/testsuite/g++.dg/lookup/pr84812.C b/gcc/testsuite/g++.dg/lookup/pr84812.C
new file mode 100644 (file)
index 0000000..9cff222
--- /dev/null
@@ -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" } }