PR c++/85060 - wrong-code with call to base member in template.
authorJason Merrill <jason@redhat.com>
Thu, 29 Mar 2018 19:38:29 +0000 (15:38 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 29 Mar 2018 19:38:29 +0000 (15:38 -0400)
* search.c (any_dependent_bases_p): Check uses_template_parms
rather than processing_template_decl.

From-SVN: r258962

gcc/cp/ChangeLog
gcc/cp/search.c
gcc/testsuite/g++.dg/template/dependent-base3.C [new file with mode: 0644]

index 3441058..454866e 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-27  Jason Merrill  <jason@redhat.com>
+
+       PR c++/85060 - wrong-code with call to base member in template.
+       * search.c (any_dependent_bases_p): Check uses_template_parms
+       rather than processing_template_decl.
+
 2018-03-29  David Malcolm  <dmalcolm@redhat.com>
 
        PR c++/85110
index 6bf8b0e..bfeaf2c 100644 (file)
@@ -2619,7 +2619,7 @@ original_binfo (tree binfo, tree here)
 bool
 any_dependent_bases_p (tree type)
 {
-  if (!type || !CLASS_TYPE_P (type) || !processing_template_decl)
+  if (!type || !CLASS_TYPE_P (type) || !uses_template_parms (type))
     return false;
 
   /* If we haven't set TYPE_BINFO yet, we don't know anything about the bases.
diff --git a/gcc/testsuite/g++.dg/template/dependent-base3.C b/gcc/testsuite/g++.dg/template/dependent-base3.C
new file mode 100644 (file)
index 0000000..e38b968
--- /dev/null
@@ -0,0 +1,26 @@
+// PR c++/85060
+// { dg-do compile { target c++14 } }
+
+struct CA {
+  constexpr int foo() const { return 42; }
+};
+
+template <class T>
+struct CB : CA { };
+
+template <class T>
+struct CC : CB<T> {
+  constexpr int bar() const {
+    const int m = CA::foo();
+    return m;
+  }
+
+  constexpr int baz() const {
+    const T m = CA::foo();
+    return m;
+  }
+};
+
+constexpr CC<double> c;
+
+static_assert( c.bar() == 42, "" );