diff options
author | Geoffrey Keating <geoffk@apple.com> | 2006-02-24 21:43:01 +0000 |
---|---|---|
committer | Geoffrey Keating <geoffk@gcc.gnu.org> | 2006-02-24 21:43:01 +0000 |
commit | c7b5e39561d3a7895496c2fb231450544f4a9306 (patch) | |
tree | 501f0f2b9d0c19c624f6a6ae51162e498fd2b1e1 /gcc | |
parent | 676cb929fcac50fbe3bd71de734a8f40b5b2ea10 (diff) | |
download | gcc-c7b5e39561d3a7895496c2fb231450544f4a9306.zip gcc-c7b5e39561d3a7895496c2fb231450544f4a9306.tar.gz gcc-c7b5e39561d3a7895496c2fb231450544f4a9306.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 17 | ||||
-rw-r--r-- | gcc/c-common.c | 8 | ||||
-rw-r--r-- | gcc/c-common.h | 5 | ||||
-rw-r--r-- | gcc/c-opts.c | 10 | ||||
-rw-r--r-- | gcc/c.opt | 4 | ||||
-rw-r--r-- | gcc/config/rs6000/darwin.h | 20 | ||||
-rwxr-xr-x | gcc/configure | 2 | ||||
-rw-r--r-- | gcc/configure.ac | 2 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/except.c | 3 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 6 | ||||
-rw-r--r-- | gcc/doc/tm.texi | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/eh/uncaught1.C | 1 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/eh/uncaught2.C | 84 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/eh/uncaught3.C | 84 |
16 files changed, 257 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0fef1ea..d541925 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/c-common.c b/gcc/c-common.c index 759a68c..4f8ab8e 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -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. */ diff --git a/gcc/c-common.h b/gcc/c-common.h index 6498255..ed93f97 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -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. */ diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 00a8631..c53238b 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -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. */ @@ -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 diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h index 46119c8..30a2fff 100644 --- a/gcc/config/rs6000/darwin.h +++ b/gcc/config/rs6000/darwin.h @@ -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 diff --git a/gcc/configure b/gcc/configure index b07c286..fe6f1bd 100755 --- a/gcc/configure +++ b/gcc/configure @@ -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 diff --git a/gcc/configure.ac b/gcc/configure.ac index 1b8feab..447f827 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -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 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c888a09..a1df2bb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 8d68486..87e9586 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -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); diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 029b43c..a81ab58 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -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 diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index dd57867..cebb71c 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c1d4744..1d4bef3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 diff --git a/gcc/testsuite/g++.dg/eh/uncaught1.C b/gcc/testsuite/g++.dg/eh/uncaught1.C index 2aa1068..afbf5af4 100644 --- a/gcc/testsuite/g++.dg/eh/uncaught1.C +++ b/gcc/testsuite/g++.dg/eh/uncaught1.C @@ -1,5 +1,6 @@ // PR libstdc++/10606 // { dg-do run } +// { dg-options "-fuse-cxa-get-exception-ptr" { target powerpc*-*-darwin* } } #include <exception> #include <cstdlib> diff --git a/gcc/testsuite/g++.dg/eh/uncaught2.C b/gcc/testsuite/g++.dg/eh/uncaught2.C new file mode 100644 index 0000000..a99b2d7 --- /dev/null +++ b/gcc/testsuite/g++.dg/eh/uncaught2.C @@ -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; +} diff --git a/gcc/testsuite/g++.dg/eh/uncaught3.C b/gcc/testsuite/g++.dg/eh/uncaught3.C new file mode 100644 index 0000000..4ce4a53 --- /dev/null +++ b/gcc/testsuite/g++.dg/eh/uncaught3.C @@ -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; +} |