From: Jason Merrill Date: Thu, 18 Jan 2018 22:15:32 +0000 (-0500) Subject: Fix template/inherit4.C. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b4cda6a6b731193c77191feb4dd70ef1cc658f09;p=gcc.git Fix template/inherit4.C. 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9577c024256..d23bfc433a5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2018-01-18 Jason Merrill + + 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 * cp-tree.h: Fix comment typo (DECL_NON_TRIVIALLY_INITIALIZED_P diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3d7d45864c6..0296845a31b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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; diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 477e9aef105..920fc15468a 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -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) diff --git a/gcc/testsuite/g++.dg/torture/pr83619.C b/gcc/testsuite/g++.dg/torture/pr83619.C index a5ca5372f18..5afd3ce0790 100644 --- a/gcc/testsuite/g++.dg/torture/pr83619.C +++ b/gcc/testsuite/g++.dg/torture/pr83619.C @@ -22,7 +22,7 @@ public: static void c (e *g) { - g->c (); + g->c (); // { dg-message "incomplete" } } }; };