aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-03-29 15:38:29 -0400
committerJason Merrill <jason@gcc.gnu.org>2018-03-29 15:38:29 -0400
commite597f6822c64f3886bdfa7f6a371470cdb642903 (patch)
tree6c2828208a21a9c7f82472b1c7556197d90afd2d /gcc
parent28ed14605eba0b4978fa8158cc2bc3db75f16f5d (diff)
downloadgcc-e597f6822c64f3886bdfa7f6a371470cdb642903.zip
gcc-e597f6822c64f3886bdfa7f6a371470cdb642903.tar.gz
gcc-e597f6822c64f3886bdfa7f6a371470cdb642903.tar.bz2
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. From-SVN: r258962
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/search.c2
-rw-r--r--gcc/testsuite/g++.dg/template/dependent-base3.C26
3 files changed, 33 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3441058..454866e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 6bf8b0e..bfeaf2c 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -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
index 0000000..e38b968
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/dependent-base3.C
@@ -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, "" );