diff options
author | Jason Merrill <jason@redhat.com> | 2013-04-22 16:35:58 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2013-04-22 16:35:58 -0400 |
commit | 80f7a782fd5a8030805a56db68c85db3bd139e23 (patch) | |
tree | aa9b5669ab9a21f24f5d9a49ab89e7e53ab05db0 /gcc | |
parent | af580858ea4338535dfb2ae4a28cbda18d1b50d0 (diff) | |
download | gcc-80f7a782fd5a8030805a56db68c85db3bd139e23.zip gcc-80f7a782fd5a8030805a56db68c85db3bd139e23.tar.gz gcc-80f7a782fd5a8030805a56db68c85db3bd139e23.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/pt.c | 15 | ||||
-rw-r--r-- | gcc/cp/rtti.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/decltype40.C | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/rtti/fn-quals.C | 12 |
5 files changed, 43 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c91f3ec..cb27315 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2013-04-22 Jason Merrill <jason@redhat.com> + 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 77329a4..6ce2770 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 b3c6687..4e73165 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 7933c95..55258f4 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<void(&)()>(0)) == 2, "Ouch"); static_assert(sizeof(g<void(&&)()>(0)) == 2, "Ouch"); static_assert(sizeof(f<void, void>(0)) == 2, "Ouch"); static_assert(sizeof(f<void(), void()>(0)) == 2, "Ouch"); -static_assert(sizeof(f<void() const, void() const>(0)) == 2, "Ouch"); +//static_assert(sizeof(f<void() const, void() const>(0)) == 2, "Ouch"); static_assert(sizeof(f<int, void>(0)) == 2, "Ouch"); static_assert(sizeof(f<void, int>(0)) == 2, "Ouch"); static_assert(sizeof(f<C, void>(0)) == 2, "Ouch"); @@ -90,7 +90,7 @@ static_assert(sizeof(g2<void(&)()>(0)) == 2, "Ouch"); static_assert(sizeof(g2<void(&&)()>(0)) == 2, "Ouch"); static_assert(sizeof(f2<void, void>(0)) == 2, "Ouch"); static_assert(sizeof(f2<void(), void()>(0)) == 2, "Ouch"); -static_assert(sizeof(f2<void() const, void() const>(0)) == 2, "Ouch"); +//static_assert(sizeof(f2<void() const, void() const>(0)) == 2, "Ouch"); static_assert(sizeof(f2<int, void>(0)) == 2, "Ouch"); static_assert(sizeof(f2<void, int>(0)) == 2, "Ouch"); static_assert(sizeof(f2<C, void>(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 0000000..75d24f8 --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/fn-quals.C @@ -0,0 +1,12 @@ +// PR c++/48665 + +#include <typeinfo> +extern "C" void abort(); + +template<class A,class B> 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<void()const,void()>(); +} |