From c19ee3f5471b312f3ae6e70453551150a3c293b4 Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 15 Dec 2014 20:19:51 +0000 Subject: [PATCH] PR c++/64297 * typeck.c (apply_memfn_quals): Correct wrong TYPE_CANONICAL. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@218763 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/typeck.c | 6 ++++++ gcc/testsuite/g++.dg/cpp0x/ref-qual16.C | 12 ++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/ref-qual16.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c14020dafd6..afb24839c42 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2014-12-15 Jason Merrill + PR c++/64297 + * typeck.c (apply_memfn_quals): Correct wrong TYPE_CANONICAL. + N3778: Sized Deallocation * call.c (non_placement_deallocation_fn_p): A global sized operator delete is not a usual deallocation function until C++14. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 7b39816bdb1..9368b49b012 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -8945,6 +8945,12 @@ apply_memfn_quals (tree type, cp_cv_quals memfn_quals, cp_ref_qualifier rqual) /* This should really have a different TYPE_MAIN_VARIANT, but that gets complex. */ tree result = build_qualified_type (type, memfn_quals); + if (tree canon = TYPE_CANONICAL (result)) + if (canon != result) + /* check_qualified_type doesn't check the ref-qualifier, so make sure + TYPE_CANONICAL is correct. */ + TYPE_CANONICAL (result) + = build_ref_qualified_type (canon, type_memfn_rqual (result)); result = build_exception_variant (result, TYPE_RAISES_EXCEPTIONS (type)); return build_ref_qualified_type (result, rqual); } diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual16.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual16.C new file mode 100644 index 00000000000..1d7650bb61b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual16.C @@ -0,0 +1,12 @@ +// PR c++/64297 +// { dg-do compile { target c++11 } } + +struct A { + typedef int X; + template X m_fn1() const; +}; +template struct is_function {}; +is_function i; +struct D { + template > D(Y); +} b(&A::m_fn1<0>); -- 2.11.4.GIT