re PR c++/71826 (ICE on valid C++ code with ambiguous member lookup: tree check:...
authorJakub Jelinek <jakub@redhat.com>
Mon, 18 Jul 2016 18:42:24 +0000 (20:42 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 18 Jul 2016 18:42:24 +0000 (20:42 +0200)
PR c++/71826
* pt.c (tsubst_baselink): Only set BASELINK_OPTYPE for BASELINK_P.

* g++.dg/template/pr71826.C: New test.

From-SVN: r238441

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/pr71826.C [new file with mode: 0644]

index 3cd6b133869e8d5180e8236d2b57617ccd33ee55..899b2aeb656797f60fb35d0a405fd61820e73b77 100644 (file)
@@ -1,5 +1,8 @@
 2016-07-18  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/71826
+       * pt.c (tsubst_baselink): Only set BASELINK_OPTYPE for BASELINK_P.
+
        PR c++/71822
        * cp-gimplify.c (cp_gimplify_expr) <case VEC_INIT_EXPR>: Recursively
        fold *expr_p before genericizing it.
index 1fbf546aaf235675e273c07a9dcdadf0c52d9d2e..916fd7b47c491673a2b61f82cd2ec9b85b48008c 100644 (file)
@@ -13767,7 +13767,8 @@ tsubst_baselink (tree baselink, tree object_type,
                  BASELINK_FUNCTIONS (baselink),
                  template_args);
     /* Update the conversion operator type.  */
-    BASELINK_OPTYPE (baselink) = optype;
+    if (BASELINK_P (baselink))
+      BASELINK_OPTYPE (baselink) = optype;
 
     if (!object_type)
       object_type = current_class_type;
index 2f6471a6c6b04012dc4fefabbbaef49affb548c6..060fcebbf017a09c0df46ed639006a11617602bd 100644 (file)
@@ -1,5 +1,8 @@
 2016-07-18  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/71826
+       * g++.dg/template/pr71826.C: New test.
+
        PR c++/71822
        * g++.dg/template/defarg21.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/template/pr71826.C b/gcc/testsuite/g++.dg/template/pr71826.C
new file mode 100644 (file)
index 0000000..753fd7e
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/71826
+// { dg-do compile }
+
+template <class> struct A { int i; };  // { dg-message "note" }
+struct B { void i () {} };             // { dg-message "note" }
+template <class T> struct C : A <T>, B
+{ 
+  void f () { i (); }                  // { dg-error "is ambiguous" }
+};
+
+int
+main ()
+{ 
+  C <int> c;
+  c.f ();
+  return 0;
+}