Fix template/inherit4.C.
authorJason Merrill <jason@redhat.com>
Thu, 18 Jan 2018 22:15:32 +0000 (17:15 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 18 Jan 2018 22:15:32 +0000 (17:15 -0500)
PR c++/83714
* search.c (any_dependent_bases_p): Handle null TREE_BINFO.
* pt.c (instantiation_dependent_scope_ref_p): True if
any_dependent_bases_p.

From-SVN: r256866

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/cp/search.c
gcc/testsuite/g++.dg/torture/pr83619.C

index 9577c02425689dccf7ef53fa1b7872e8c48c1c46..d23bfc433a5c5810526f364464ea088ae2cbb81d 100644 (file)
@@ -1,3 +1,10 @@
+2018-01-18  Jason Merrill  <jason@redhat.com>
+
+       PR c++/83714
+       * search.c (any_dependent_bases_p): Handle null TREE_BINFO.
+       * pt.c (instantiation_dependent_scope_ref_p): True if
+       any_dependent_bases_p.
+
 2018-01-18  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * cp-tree.h: Fix comment typo (DECL_NON_TRIVIALLY_INITIALIZED_P
index 3d7d45864c62253c2689e2e1df597f05609caa69..0296845a31bf092e5c1534431a70558cde430674 100644 (file)
@@ -23952,6 +23952,9 @@ instantiation_dependent_scope_ref_p (tree t)
 {
   if (DECL_P (TREE_OPERAND (t, 1))
       && CLASS_TYPE_P (TREE_OPERAND (t, 0))
+      /* A dependent base could make a member inaccessible in the current
+        class.  */
+      && !any_dependent_bases_p ()
       && accessible_in_template_p (TREE_OPERAND (t, 0),
                                   TREE_OPERAND (t, 1)))
     return false;
index 477e9aef105588bd52de39601d9692b8bad586c1..920fc15468a8b4578cf08e77cafe551759a46624 100644 (file)
@@ -2612,6 +2612,13 @@ any_dependent_bases_p (tree type)
   if (!type || !CLASS_TYPE_P (type) || !processing_template_decl)
     return false;
 
+  /* If we haven't set TYPE_BINFO yet, we don't know anything about the bases.
+     Return false because in this situation we aren't actually looking up names
+     in the scope of the class, so it doesn't matter whether it has dependent
+     bases.  */
+  if (!TYPE_BINFO (type))
+    return false;
+
   unsigned i;
   tree base_binfo;
   FOR_EACH_VEC_SAFE_ELT (BINFO_BASE_BINFOS (TYPE_BINFO (type)), i, base_binfo)
index a5ca5372f18befafa7ffe486a9497e3e5409b764..5afd3ce0790dd632eeb6e63469bad6837c64d06f 100644 (file)
@@ -22,7 +22,7 @@ public:
     static void
     c (e *g)
     {
-      g->c ();
+      g->c ();                 // { dg-message "incomplete" }
     }
   };
 };