diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c91f3ec68d9..cb27315c6b9 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 77329a45b06..6ce2770c1c6 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 b3c6687a75d..4e7316560ec 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 7933c95b31f..55258f4d88d 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 00000000000..75d24f8a9f6 --- /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 a320fa7f527..b44f584bfc2 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 eade406593d..8d45671fd1d 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 ba6ffab7719..f3119111b0c 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 24cd6b91121..e849a5dc3b4 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 89dcd3bd70c..e0f7231ed92 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;