From: Jason Merrill Date: Thu, 29 Mar 2018 19:38:29 +0000 (-0400) Subject: PR c++/85060 - wrong-code with call to base member in template. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e597f6822c64f3886bdfa7f6a371470cdb642903;p=gcc.git 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 --- 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, "" );