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-Tag: upstream/12.2.0~32608 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e597f6822c64f3886bdfa7f6a371470cdb642903;p=platform%2Fupstream%2Fgcc.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 3441058..454866e 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 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 +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, "" );