From bb0a32e80d75ed27f9714a0dc03d1faca50d94a6 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sat, 6 Aug 2011 00:34:37 -0400 Subject: [PATCH] re PR c++/49921 ([C++0x] Segfault during compilation, decltype and operator->*) PR c++/49921 * semantics.c (finish_decltype_type): Call invalid_nonstatic_memfn_p. From-SVN: r177498 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/semantics.c | 3 +++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/cpp0x/decltype31.C | 13 +++++++++++++ 4 files changed, 22 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/decltype31.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 964de150272..18bf49385ed 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-08-05 Jason Merrill + PR c++/49921 + * semantics.c (finish_decltype_type): Call invalid_nonstatic_memfn_p. + PR c++/49669 * init.c (perform_member_init): Handle invalid array initializer. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 2f02e696dba..3d836eb56c7 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4948,6 +4948,9 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, return error_mark_node; } + if (invalid_nonstatic_memfn_p (expr, complain)) + return error_mark_node; + /* To get the size of a static data member declared as an array of unknown bound, we need to instantiate it. */ if (TREE_CODE (expr) == VAR_DECL diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9ce5d9b75f8..cef7f415a19 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-08-05 Jason Merrill + PR c++/49921 + * g++.dg/cpp0x/decltype31.C: New. + PR c++/49669 * g++.dg/init/array28.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype31.C b/gcc/testsuite/g++.dg/cpp0x/decltype31.C new file mode 100644 index 00000000000..b9817eb9e13 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype31.C @@ -0,0 +1,13 @@ +// PR c++/49921 +// { dg-options -std=c++0x } + +struct Local +{ + void f(); +}; + +Local *l; +void (Local::*ptr)(); +decltype((l->*ptr)) i; // { dg-error "member function" } + +// { dg-prune-output "invalid type in declaration" } -- 2.30.2