From 80f7a782fd5a8030805a56db68c85db3bd139e23 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 22 Apr 2013 16:35:58 -0400 Subject: [PATCH] re PR c++/48665 (type of const member function) PR c++/48665 * rtti.c (get_typeid): Diagnose qualified function type. * pt.c (tsubst) [POINTER_TYPE]: Likewise. From-SVN: r198160 --- gcc/cp/ChangeLog | 4 ++ gcc/cp/pt.c | 15 ++++++ gcc/cp/rtti.c | 10 ++++ gcc/testsuite/g++.dg/cpp0x/decltype40.C | 4 +- gcc/testsuite/g++.dg/rtti/fn-quals.C | 12 +++++ libstdc++-v3/ChangeLog | 8 +++ .../testsuite/20_util/is_assignable/value.cc | 10 ++-- .../20_util/is_constructible/value-2.cc | 50 +++++++++---------- .../20_util/reference_wrapper/result_type.cc | 6 +-- .../20_util/reference_wrapper/typedefs-2.cc | 30 +++++------ 10 files changed, 99 insertions(+), 50 deletions(-) create mode 100644 gcc/testsuite/g++.dg/rtti/fn-quals.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c91f3ec68d9b..cb27315c6b94 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2013-04-22 Jason Merrill + PR c++/48665 + * rtti.c (get_typeid): Diagnose qualified function type. + * pt.c (tsubst) [POINTER_TYPE]: Likewise. + * error.c (dump_aggr_type): Fix lambda detection. (dump_simple_decl): Pretty-print capture field. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 77329a45b065..6ce2770c1c60 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11521,6 +11521,21 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) return error_mark_node; } + else if (TREE_CODE (type) == FUNCTION_TYPE + && (type_memfn_quals (type) != TYPE_UNQUALIFIED + || type_memfn_rqual (type) != REF_QUAL_NONE)) + { + if (complain & tf_error) + { + if (code == POINTER_TYPE) + error ("forming pointer to qualified function type %qT", + type); + else + error ("forming reference to qualified function type %qT", + type); + } + return error_mark_node; + } else if (code == POINTER_TYPE) { r = build_pointer_type (type); diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index b3c6687a75d9..4e7316560ec9 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -477,6 +477,16 @@ get_typeid (tree type, tsubst_flags_t complain) referenced type. */ type = non_reference (type); + /* This is not one of the uses of a qualified function type in 8.3.5. */ + if (TREE_CODE (type) == FUNCTION_TYPE + && (type_memfn_quals (type) != TYPE_UNQUALIFIED + || type_memfn_rqual (type) != REF_QUAL_NONE)) + { + if (complain & tf_error) + error ("typeid of qualified function type %qT", type); + return error_mark_node; + } + /* The top-level cv-qualifiers of the lvalue expression or the type-id that is the operand of typeid are always ignored. */ type = TYPE_MAIN_VARIANT (type); diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype40.C b/gcc/testsuite/g++.dg/cpp0x/decltype40.C index 7933c95b31f2..55258f4d88d6 100644 --- a/gcc/testsuite/g++.dg/cpp0x/decltype40.C +++ b/gcc/testsuite/g++.dg/cpp0x/decltype40.C @@ -68,7 +68,7 @@ static_assert(sizeof(g(0)) == 2, "Ouch"); static_assert(sizeof(g(0)) == 2, "Ouch"); static_assert(sizeof(f(0)) == 2, "Ouch"); static_assert(sizeof(f(0)) == 2, "Ouch"); -static_assert(sizeof(f(0)) == 2, "Ouch"); +//static_assert(sizeof(f(0)) == 2, "Ouch"); static_assert(sizeof(f(0)) == 2, "Ouch"); static_assert(sizeof(f(0)) == 2, "Ouch"); static_assert(sizeof(f(0)) == 2, "Ouch"); @@ -90,7 +90,7 @@ static_assert(sizeof(g2(0)) == 2, "Ouch"); static_assert(sizeof(g2(0)) == 2, "Ouch"); static_assert(sizeof(f2(0)) == 2, "Ouch"); static_assert(sizeof(f2(0)) == 2, "Ouch"); -static_assert(sizeof(f2(0)) == 2, "Ouch"); +//static_assert(sizeof(f2(0)) == 2, "Ouch"); static_assert(sizeof(f2(0)) == 2, "Ouch"); static_assert(sizeof(f2(0)) == 2, "Ouch"); static_assert(sizeof(f2(0)) == 2, "Ouch"); diff --git a/gcc/testsuite/g++.dg/rtti/fn-quals.C b/gcc/testsuite/g++.dg/rtti/fn-quals.C new file mode 100644 index 000000000000..75d24f8a9f68 --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/fn-quals.C @@ -0,0 +1,12 @@ +// PR c++/48665 + +#include +extern "C" void abort(); + +template void f() { + if (typeid(A)==typeid(B)) abort(); // { dg-error "qualified function" } + if (typeid(A*)==typeid(B*)) abort(); // { dg-error "qualified function" } +} +int main() { + f(); +} diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a320fa7f527b..b44f584bfc26 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2013-04-22 Jason Merrill + + * testsuite/20_util/is_assignable/value.cc: Comment out tests involving + function-cv-quals. + * testsuite/20_util/is_constructible/value-2.cc: Likewise. + * testsuite/20_util/reference_wrapper/result_type.cc: Likewise. + * testsuite/20_util/reference_wrapper/typedefs-2.cc: Likewise. + 2013-04-22 François Dumont * include/bits/hashtable_policy.h: Add C++11 allocator support. diff --git a/libstdc++-v3/testsuite/20_util/is_assignable/value.cc b/libstdc++-v3/testsuite/20_util/is_assignable/value.cc index eade406593db..8d45671fd1dd 100644 --- a/libstdc++-v3/testsuite/20_util/is_assignable/value.cc +++ b/libstdc++-v3/testsuite/20_util/is_assignable/value.cc @@ -277,8 +277,8 @@ static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); -static_assert(!std::is_assignable::value, "Error"); +// static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); static_assert(std::is_assignable::value, "Error"); static_assert(std::is_assignable::value, "Error"); -static_assert(std::is_assignable::value, "Error"); +//static_assert(std::is_assignable::value, "Error"); static_assert(std::is_assignable::value, "Error"); static_assert(std::is_assignable::value, "Error"); static_assert(std::is_assignable::value, "Error"); @@ -636,8 +636,8 @@ static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); -static_assert(!std::is_assignable::value, "Error"); +// static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); diff --git a/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc b/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc index ba6ffab77191..f3119111b0cb 100644 --- a/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc +++ b/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc @@ -72,8 +72,8 @@ static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, - "Error"); +// static_assert(!std::is_constructible::value, +// "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); @@ -461,20 +461,20 @@ static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, - "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, +// "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); @@ -488,8 +488,8 @@ static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); @@ -651,13 +651,13 @@ static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible, int, int>::value, "Error"); static_assert(!std::is_constructible, int, int>::value, diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc index 24cd6b911213..e849a5dc3b43 100644 --- a/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc @@ -27,9 +27,9 @@ using namespace std; struct T; reference_wrapper::result_type i01; -reference_wrapper::result_type i02; -reference_wrapper::result_type i03; -reference_wrapper::result_type i04; +// reference_wrapper::result_type i02; +// reference_wrapper::result_type i03; +// reference_wrapper::result_type i04; reference_wrapper::result_type i05; reference_wrapper::result_type i06; diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc index 89dcd3bd70c7..e0f7231ed929 100644 --- a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc @@ -25,13 +25,13 @@ using namespace std; reference_wrapper::argument_type i01; -reference_wrapper::argument_type i02; -reference_wrapper::argument_type i03; -reference_wrapper::argument_type i04; +// reference_wrapper::argument_type i02; +// reference_wrapper::argument_type i03; +// reference_wrapper::argument_type i04; reference_wrapper::result_type i05; -reference_wrapper::result_type i06; -reference_wrapper::result_type i07; -reference_wrapper::result_type i08; +// reference_wrapper::result_type i06; +// reference_wrapper::result_type i07; +// reference_wrapper::result_type i08; reference_wrapper::argument_type i09; reference_wrapper::argument_type i10; @@ -43,17 +43,17 @@ reference_wrapper::result_type i15; reference_wrapper::result_type i16; reference_wrapper::first_argument_type i17; -reference_wrapper::first_argument_type i18; -reference_wrapper::first_argument_type i19; -reference_wrapper::first_argument_type i20; +// reference_wrapper::first_argument_type i18; +// reference_wrapper::first_argument_type i19; +// reference_wrapper::first_argument_type i20; reference_wrapper::second_argument_type i21; -reference_wrapper::second_argument_type i22; -reference_wrapper::second_argument_type i23; -reference_wrapper::second_argument_type i24; +// reference_wrapper::second_argument_type i22; +// reference_wrapper::second_argument_type i23; +// reference_wrapper::second_argument_type i24; reference_wrapper::result_type i25; -reference_wrapper::result_type i26; -reference_wrapper::result_type i27; -reference_wrapper::result_type i28; +// reference_wrapper::result_type i26; +// reference_wrapper::result_type i27; +// reference_wrapper::result_type i28; reference_wrapper::first_argument_type i29; reference_wrapper::first_argument_type i30;