From c93586fa83db51294b3c51afb48f4257889813c6 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Tue, 19 Jun 2001 13:32:57 +0000 Subject: [PATCH] except.c (initialize_handler_parm): Expect __cxa_begin_catch to return pointers to data members by reference rather... * except.c (initialize_handler_parm): Expect __cxa_begin_catch to return pointers to data members by reference rather than by value. From-SVN: r43456 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/except.c | 6 +++--- gcc/testsuite/g++.old-deja/g++.eh/ptrmem1.C | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.eh/ptrmem1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 99643259c51..ea5de138d54 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2001-06-19 Richard Sandiford + + * except.c (initialize_handler_parm): Expect __cxa_begin_catch to + return pointers to data members by reference rather than by value. + 2001-06-18 Jason Merrill Implement the Named Return Value optimization. diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 458590a8f57..46ffd6e5b76 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -348,7 +348,7 @@ initialize_handler_parm (decl, exp) adjusted by value from __cxa_begin_catch. Others are returned by reference. */ init_type = TREE_TYPE (decl); - if (TREE_CODE (init_type) != POINTER_TYPE + if (! TYPE_PTR_P (init_type) && TREE_CODE (init_type) != REFERENCE_TYPE) init_type = build_reference_type (init_type); @@ -357,8 +357,8 @@ initialize_handler_parm (decl, exp) /* Since pointers are passed by value, initialize a reference to pointer catch parm with the address of the temporary. */ - if (TREE_CODE (init_type) == REFERENCE_TYPE - && TREE_CODE (TREE_TYPE (init_type)) == POINTER_TYPE) + if (TREE_CODE (init_type) == REFERENCE_TYPE + && TYPE_PTR_P (TREE_TYPE (init_type))) exp = build_unary_op (ADDR_EXPR, exp, 1); exp = ocp_convert (init_type, exp, CONV_IMPLICIT|CONV_FORCE_TEMP, 0); diff --git a/gcc/testsuite/g++.old-deja/g++.eh/ptrmem1.C b/gcc/testsuite/g++.old-deja/g++.eh/ptrmem1.C new file mode 100644 index 00000000000..ba70612033b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/ptrmem1.C @@ -0,0 +1,15 @@ +extern "C" void exit (int); +extern "C" void abort (void); +struct A { int i; }; +int main () +{ + try { throw &A::i; } + catch (int A::*p) + { + if (p == &A::i) + exit (0); + else + abort (); + } + abort (); +} -- 2.30.2