re PR c++/80979 (ice in lookup_mark, at cp/tree.c:2298)
authorNathan Sidwell <nathan@acm.org>
Tue, 6 Jun 2017 15:06:56 +0000 (15:06 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 6 Jun 2017 15:06:56 +0000 (15:06 +0000)
PR c++/80979
* name-lookup.c (adl_class_only): Don't add visible friends.

From-SVN: r248922

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

index f9bd9548eb84b0a3bb4be6bce0b4764ae124ad25..8200756ba4dd42a9cf416f3f53e0472af889ce6d 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-06  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/80979
+       * name-lookup.c (adl_class_only): Don't add visible friends.
+
 2017-06-05  Volker Reichelt  <v.reichelt@netcologne.de>
 
        * parser.c (cp_parser_base_specifier): Fix typos in error messages.
index 041d51c8494d5376eadeac1bce5f20f005bc9d48..169a1c99edaba0ab4da672599660513e57e5af81 100644 (file)
@@ -801,6 +801,12 @@ name_lookup::adl_class_only (tree type)
          if (CP_DECL_CONTEXT (fn) != context)
            continue;
 
+         /* Only interested in anticipated friends.  (Non-anticipated
+            ones will have been inserted during the namespace
+            adl.)  */
+         if (!DECL_ANTICIPATED (fn))
+           continue;
+
          /* Template specializations are never found by name lookup.
             (Templates themselves can be found, but not template
             specializations.)  */
diff --git a/gcc/testsuite/g++.dg/lookup/pr80979.C b/gcc/testsuite/g++.dg/lookup/pr80979.C
new file mode 100644 (file)
index 0000000..eb22f71
--- /dev/null
@@ -0,0 +1,26 @@
+// pr C++/80979 ICE with late discovery of using directives during ADL
+// of a friend declaration.
+
+namespace Tiny {
+  class Handsome {};
+  void Dahl (Handsome &, Handsome &);
+
+  namespace Jack {
+    class Vladof {
+      friend void Dahl (Vladof &, Vladof &);
+    };
+    void Dahl (Vladof &, Vladof &);
+  }
+
+  struct BDonk {};
+
+  namespace Tina {
+    void Dahl (BDonk &, Jack::Vladof &);
+  }
+  using Tina::Dahl;
+}
+
+void BoomBoom (Tiny::BDonk &vault, Tiny::Jack::Vladof &hunter)
+{
+  Dahl (vault, hunter);
+}