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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@111427
138bc75d-0d04-0410-961f-
82ee72b054a4
+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
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. */
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. */
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;
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. */
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
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) \
} \
} 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
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
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
+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
/* 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);
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
@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
+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
// PR libstdc++/10606
// { dg-do run }
+// { dg-options "-fuse-cxa-get-exception-ptr" { target powerpc*-*-darwin* } }
#include <exception>
#include <cstdlib>
--- /dev/null
+// { 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;
+}
--- /dev/null
+// { 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;
+}