From e597f6822c64f3886bdfa7f6a371470cdb642903 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 29 Mar 2018 15:38:29 -0400 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 6 +++++ gcc/cp/search.c | 2 +- .../g++.dg/template/dependent-base3.C | 26 +++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/dependent-base3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 344105844a6..454866e6e77 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-03-27 Jason Merrill + + 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 PR c++/85110 diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 6bf8b0e70dc..bfeaf2cc819 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 00000000000..e38b968e774 --- /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 +struct CB : CA { }; + +template +struct CC : CB { + constexpr int bar() const { + const int m = CA::foo(); + return m; + } + + constexpr int baz() const { + const T m = CA::foo(); + return m; + } +}; + +constexpr CC c; + +static_assert( c.bar() == 42, "" ); -- 2.30.2