C++ PATCH for c++/71143, 71209 (bogus error with dependent base)

Jason Merrill jason@redhat.com
Fri Jun 17 16:35:00 GMT 2016


Now that we have stopped treating *this as a dependent scope, we need
to avoid giving errors for not finding things when we have dependent
bases.

Tested x86_64-pc-linux-gnu, applying to trunk.
-------------- next part --------------
commit d553bc7ff104a8d973c3f48c005457038422db26
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Jun 17 12:16:00 2016 -0400

    	PR c++/71209 - wrong error with dependent base
    
    	* typeck.c (finish_class_member_access_expr): Avoid "not a base"
    	warning when there are dependent bases.

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 2ccd2da..3704b88 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -2797,6 +2797,8 @@ finish_class_member_access_expr (cp_expr object, tree name, bool template_p,
 	    return error_mark_node;
 	  if (!access_path)
 	    {
+	      if (any_dependent_bases_p (object_type))
+		goto dependent;
 	      if (complain & tf_error)
 		error ("%qT is not a base of %qT", scope, object_type);
 	      return error_mark_node;
diff --git a/gcc/testsuite/g++.dg/template/dependent-base1.C b/gcc/testsuite/g++.dg/template/dependent-base1.C
new file mode 100644
index 0000000..392305b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/dependent-base1.C
@@ -0,0 +1,10 @@
+// PR c++/71209
+
+struct A {
+  int table_clear;
+};
+
+template <typename T>
+struct B : T {
+  B() { this->A::table_clear; }
+};


More information about the Gcc-patches mailing list