From f92c74268a1f3e9ff6921097e8da418879769e2b Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Mon, 15 Jun 2015 19:26:27 +0000 Subject: [PATCH] re PR c++/51048 (Class template inheritance doesn't work well with function-local types) /cp 2015-06-15 Paolo Carlini PR c++/51048 * decl2.c (no_linkage_error): Do not issue a permerror if the DECL using a local type is pure virtual. /testsuite 2015-06-15 Paolo Carlini PR c++/51048 * g++.dg/cpp0x/local-type1.C: New. From-SVN: r224492 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl2.c | 8 ++++++-- gcc/testsuite/ChangeLog | 7 ++++++- gcc/testsuite/g++.dg/cpp0x/local-type1.C | 19 +++++++++++++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/local-type1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e1ca26ebeed..cf311c73178 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-06-15 Paolo Carlini + + PR c++/51048 + * decl2.c (no_linkage_error): Do not issue a permerror if the DECL + using a local type is pure virtual. + 2015-06-13 Patrick Palka * call.c: Remove comment documenting the long-deleted diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 9df3139e9e3..ce7ab52c28b 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -4221,8 +4221,12 @@ no_linkage_error (tree decl) TYPE_NAME (t)); } else if (cxx_dialect >= cxx11) - permerror (DECL_SOURCE_LOCATION (decl), "%q#D, declared using local type " - "%qT, is used but never defined", decl, t); + { + if (TREE_CODE (decl) == VAR_DECL || !DECL_PURE_VIRTUAL_P (decl)) + permerror (DECL_SOURCE_LOCATION (decl), + "%q#D, declared using local type " + "%qT, is used but never defined", decl, t); + } else if (TREE_CODE (decl) == VAR_DECL) warning_at (DECL_SOURCE_LOCATION (decl), 0, "type %qT with no linkage " "used to declare variable %q#D with linkage", t, decl); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0d574821068..68356fc31e3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-06-15 Paolo Carlini + + PR c++/51048 + * g++.dg/cpp0x/local-type1.C: New. + 2015-06-15 Andre Vehreschild PR fortran/44672 @@ -11,7 +16,7 @@ 2015-06-13 Patrick Palka PR c++/65168 - g++.dg/warn/Walways-true-3.C: New test. + * g++.dg/warn/Walways-true-3.C: New test. 2015-06-13 Tom de Vries diff --git a/gcc/testsuite/g++.dg/cpp0x/local-type1.C b/gcc/testsuite/g++.dg/cpp0x/local-type1.C new file mode 100644 index 00000000000..73bfd167385 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/local-type1.C @@ -0,0 +1,19 @@ +// PR c++/51048 +// { dg-do compile { target c++11 } } + +template +struct A { + virtual void DoPush(X const& x) = 0; + void Push(X const& x) { DoPush(x); } +}; + +template +struct B : A { + using A::Push; + virtual void DoPush(X const&) { } +}; + +int main() { + enum S { }; + B().Push(S()); +} -- 2.30.2