Index: gcc/ChangeLog

2006-02-24  Geoffrey Keating  <geoffk@apple.com>

	* doc/tm.texi (Run-time Target): Document C_COMMON_OVERRIDE_OPTIONS.
	* doc/invoke.texi (C++ Dialect Options): Document 
	-fno-use-cxa-get-exception-ptr.
	* configure.ac: Define DEFAULT_USE_CXA_ATEXIT to 2 not 1.
	* configure: Regenerate.
	* c.opt (fuse-cxa-get-exception-ptr): New.
	* c-opts.c (c_common_handle_option): Handle
	OPT_fuse_cxa_get_exception_ptr.
	* c-common.c (flag_use_cxa_atexit): Update documentation.
	(flag_use_cxa_get_exception_ptr): New.
	* c-common.h (flag_use_cxa_get_exception_ptr): New.
	* config/rs6000/darwin.h (SUBTARGET_OVERRIDE_OPTIONS): Improve
	documentation.
	(C_COMMON_OVERRIDE_OPTIONS): New.

Index: gcc/testsuite/ChangeLog
2006-02-24  Geoffrey Keating  <geoffk@apple.com>

	* g++.dg/eh/uncaught1.C: Add dg-options for ppc-darwin.
	* g++.dg/eh/uncaught2.C: New.
	* g++.dg/eh/uncaught3.C: New.

Index: gcc/cp/ChangeLog
2006-02-24  Geoffrey Keating  <geoffk@apple.com>

	* except.c (expand_start_catch_block): Handle
	flag_use_cxa_get_exception_ptr.

From-SVN: r111427
This commit is contained in:
Geoffrey Keating 2006-02-24 21:43:01 +00:00 committed by Geoffrey Keating
parent 676cb929fc
commit c7b5e39561
16 changed files with 257 additions and 7 deletions

View file

@ -1,3 +1,20 @@
2006-02-24 Geoffrey Keating <geoffk@apple.com>
* doc/tm.texi (Run-time Target): Document C_COMMON_OVERRIDE_OPTIONS.
* doc/invoke.texi (C++ Dialect Options): Document
-fno-use-cxa-get-exception-ptr.
* configure.ac: Define DEFAULT_USE_CXA_ATEXIT to 2 not 1.
* configure: Regenerate.
* c.opt (fuse-cxa-get-exception-ptr): New.
* c-opts.c (c_common_handle_option): Handle
OPT_fuse_cxa_get_exception_ptr.
* c-common.c (flag_use_cxa_atexit): Update documentation.
(flag_use_cxa_get_exception_ptr): New.
* c-common.h (flag_use_cxa_get_exception_ptr): New.
* config/rs6000/darwin.h (SUBTARGET_OVERRIDE_OPTIONS): Improve
documentation.
(C_COMMON_OVERRIDE_OPTIONS): New.
2006-02-24 Roger Sayle <roger@eyesopen.com>
PR middle-end/24952

View file

@ -424,10 +424,16 @@ int flag_weak = 1;
int flag_working_directory = -1;
/* Nonzero to use __cxa_atexit, rather than atexit, to register
destructors for local statics and global objects. */
destructors for local statics and global objects. '2' means it has been
set nonzero as a default, not by a command-line flag. */
int flag_use_cxa_atexit = DEFAULT_USE_CXA_ATEXIT;
/* Nonzero to use __cxa_get_exception_ptr in C++ exception-handling
code. '2' means it has not been set explicitly on the command line. */
int flag_use_cxa_get_exception_ptr = 2;
/* Nonzero means make the default pedwarns warnings instead of errors.
The value of this flag is ignored if -pedantic is specified. */

View file

@ -549,6 +549,11 @@ extern int flag_working_directory;
extern int flag_use_cxa_atexit;
/* Nonzero to use __cxa_get_exception_ptr in the C++ exception-handling
logic. */
extern int flag_use_cxa_get_exception_ptr;
/* Nonzero means make the default pedwarns warnings instead of errors.
The value of this flag is ignored if -pedantic is specified. */

View file

@ -786,6 +786,10 @@ c_common_handle_option (size_t scode, const char *arg, int value)
flag_use_cxa_atexit = value;
break;
case OPT_fuse_cxa_get_exception_ptr:
flag_use_cxa_get_exception_ptr = value;
break;
case OPT_fvisibility_inlines_hidden:
visibility_options.inlines_hidden = value;
break;
@ -978,6 +982,12 @@ c_common_post_options (const char **pfilename)
register_include_chains (parse_in, sysroot, iprefix, imultilib,
std_inc, std_cxx_inc && c_dialect_cxx (), verbose);
#ifdef C_COMMON_OVERRIDE_OPTIONS
/* Some machines may reject certain combinations of C
language-specific options. */
C_COMMON_OVERRIDE_OPTIONS;
#endif
flag_inline_trees = 1;
/* Use tree inlining. */

View file

@ -713,6 +713,10 @@ fuse-cxa-atexit
C++ ObjC++
Use __cxa_atexit to register destructors
fuse-cxa-get-exception-ptr
C++ ObjC++
Use __cxa_get_exception_ptr in exception handling
fvisibility-inlines-hidden
C++ ObjC++
Marks all inlined methods as having hidden visibility

View file

@ -59,11 +59,10 @@
while (0)
/* The Darwin ABI always includes AltiVec, can't be (validly) turned
off. */
#define SUBTARGET_OVERRIDE_OPTIONS \
do { \
/* The Darwin ABI always includes AltiVec, can't be (validly) turned \
off. */ \
rs6000_altivec_abi = 1; \
TARGET_ALTIVEC_VRSAVE = 1; \
if (DEFAULT_ABI == ABI_DARWIN) \
@ -87,6 +86,21 @@ do { \
} \
} while(0)
#define C_COMMON_OVERRIDE_OPTIONS do { \
/* On powerpc, __cxa_get_exception_ptr is available starting in the \
10.5 libstdc++.dylib. */ \
if ((! darwin_macosx_version_min \
|| strverscmp (darwin_macosx_version_min, "10.5") < 0) \
&& flag_use_cxa_get_exception_ptr == 2) \
flag_use_cxa_get_exception_ptr = 0; \
/* On powerpc, __cxa_atexit is available starting in the 10.4 \
libSystem.dylib. */ \
if ((! darwin_macosx_version_min \
|| strverscmp (darwin_macosx_version_min, "10.4") < 0) \
&& flag_use_cxa_atexit == 2) \
flag_use_cxa_atexit = 0; \
} while (0)
/* Darwin has 128-bit long double support in libc in 10.4 and later.
Default to 128-bit long doubles even on earlier platforms for ABI
consistency; arithmetic will work even if libc and libm support is

2
gcc/configure vendored
View file

@ -12346,7 +12346,7 @@ fi
if test x$use_cxa_atexit = xyes; then
cat >>confdefs.h <<\_ACEOF
#define DEFAULT_USE_CXA_ATEXIT 1
#define DEFAULT_USE_CXA_ATEXIT 2
_ACEOF
fi

View file

@ -1392,7 +1392,7 @@ if test x$enable___cxa_atexit = xyes || \
use_cxa_atexit=yes
fi
if test x$use_cxa_atexit = xyes; then
AC_DEFINE(DEFAULT_USE_CXA_ATEXIT, 1,
AC_DEFINE(DEFAULT_USE_CXA_ATEXIT, 2,
[Define if you want to use __cxa_atexit, rather than atexit, to
register C++ destructors for local statics and global objects.
This is essential for fully standards-compliant handling of

View file

@ -1,3 +1,8 @@
2006-02-24 Geoffrey Keating <geoffk@apple.com>
* except.c (expand_start_catch_block): Handle
flag_use_cxa_get_exception_ptr.
2006-02-22 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/26291

View file

@ -446,7 +446,8 @@ expand_start_catch_block (tree decl)
/* If the C++ object needs constructing, we need to do that before
calling __cxa_begin_catch, so that std::uncaught_exception gets
the right value during the copy constructor. */
else if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl)))
else if (flag_use_cxa_get_exception_ptr
&& TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl)))
{
exp = do_get_exception_ptr ();
initialize_handler_parm (decl, exp);

View file

@ -1581,6 +1581,12 @@ This option is required for fully standards-compliant handling of static
destructors, but will only work if your C library supports
@code{__cxa_atexit}.
@item -fno-use-cxa-get-exception-ptr
@opindex fno-use-cxa-get-exception-ptr
Don't use the @code{__cxa_get_exception_ptr} runtime routine. This
will cause @code{std::uncaught_exception} to be incorrect, but is necessary
if the runtime routine is not available.
@item -fvisibility-inlines-hidden
@opindex fvisibility-inlines-hidden
Causes all inlined methods to be marked with

View file

@ -778,6 +778,13 @@ Don't use this macro to turn on various extra optimizations for
@option{-O}. That is what @code{OPTIMIZATION_OPTIONS} is for.
@end defmac
@defmac C_COMMON_OVERRIDE_OPTIONS
This is similar to @code{OVERRIDE_OPTIONS} but is only used in the C
language frontends (C, Objective-C, C++, Objective-C++) and so can be
used to alter option flag variables which only exist in those
frontends.
@end defmac
@defmac OPTIMIZATION_OPTIONS (@var{level}, @var{size})
Some machines may desire to change what optimizations are performed for
various optimization levels. This macro, if defined, is executed once

View file

@ -1,3 +1,9 @@
2006-02-24 Geoffrey Keating <geoffk@apple.com>
* g++.dg/eh/uncaught1.C: Add dg-options for ppc-darwin.
* g++.dg/eh/uncaught2.C: New.
* g++.dg/eh/uncaught3.C: New.
2006-02-24 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/26423

View file

@ -1,5 +1,6 @@
// PR libstdc++/10606
// { dg-do run }
// { dg-options "-fuse-cxa-get-exception-ptr" { target powerpc*-*-darwin* } }
#include <exception>
#include <cstdlib>

View file

@ -0,0 +1,84 @@
// { dg-do compile }
// { dg-final { scan-assembler-not "__cxa_get_exception" } }
// { dg-options "-fno-use-cxa-get-exception-ptr" }
#include <exception>
#include <cstdlib>
struct Check {
int obj1, obj2;
bool state;
};
static Check const data[] = {
{ 0, 0, false }, // construct [0]
{ 1, 0, true }, // [1] = [0]
{ 0, 0, true }, // destruct [0]
{ 2, 1, true }, // [2] = [1]
{ 2, 2, true }, // destruct [2]
{ 3, 1, true }, // [3] = [1]
{ 3, 3, false }, // destruct [3]
{ 1, 1, false }, // destruct [1]
{ 9, 9, false } // end-of-data
};
static int pos = 0;
static void test(int obj1, int obj2, bool state)
{
if (obj1 != data[pos].obj1) abort ();
if (obj2 != data[pos].obj2) abort ();
if (state != data[pos].state) abort ();
pos++;
}
struct S {
int id;
S ();
S (const S &);
~S ();
};
static int next_id = 0;
S::S()
: id (next_id++)
{
test (id, id, std::uncaught_exception ());
}
S::S(const S &x)
: id (next_id++)
{
test (id, x.id, std::uncaught_exception ());
}
S::~S()
{
test (id, id, std::uncaught_exception ());
}
extern void foo (S *);
int main()
{
try
{
try
{
S s0;
throw s0; // s1 is the exception object
}
catch (S s2)
{
throw;
}
}
catch (S s3)
{
}
return 0;
}

View file

@ -0,0 +1,84 @@
// { dg-do compile { target powerpc*-*-darwin* } }
// { dg-final { scan-assembler-not "__cxa_get_exception" } }
// { dg-options "-mmacosx-version-min=10.4" }
#include <exception>
#include <cstdlib>
struct Check {
int obj1, obj2;
bool state;
};
static Check const data[] = {
{ 0, 0, false }, // construct [0]
{ 1, 0, true }, // [1] = [0]
{ 0, 0, true }, // destruct [0]
{ 2, 1, true }, // [2] = [1]
{ 2, 2, true }, // destruct [2]
{ 3, 1, true }, // [3] = [1]
{ 3, 3, false }, // destruct [3]
{ 1, 1, false }, // destruct [1]
{ 9, 9, false } // end-of-data
};
static int pos = 0;
static void test(int obj1, int obj2, bool state)
{
if (obj1 != data[pos].obj1) abort ();
if (obj2 != data[pos].obj2) abort ();
if (state != data[pos].state) abort ();
pos++;
}
struct S {
int id;
S ();
S (const S &);
~S ();
};
static int next_id = 0;
S::S()
: id (next_id++)
{
test (id, id, std::uncaught_exception ());
}
S::S(const S &x)
: id (next_id++)
{
test (id, x.id, std::uncaught_exception ());
}
S::~S()
{
test (id, id, std::uncaught_exception ());
}
extern void foo (S *);
int main()
{
try
{
try
{
S s0;
throw s0; // s1 is the exception object
}
catch (S s2)
{
throw;
}
}
catch (S s3)
{
}
return 0;
}