From aee7846e9060634b4aa75155423a5dffcc616db8 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Sun, 1 May 2005 20:30:40 +0000 Subject: [PATCH] c-cppbuiltin.c (c_cpp_builtins): Do not define __GXX_WEAK__ to 1 if !flag_weak. * c-cppbuiltin.c (c_cpp_builtins): Do not define __GXX_WEAK__ to 1 if !flag_weak. * doc/cpp.texi (__DEPRECATED): Document. (__EXCEPTIONS): Likewise. (__GXX_WEAK__): Likewise. * g++.dg/cpp/weak.C: New test. From-SVN: r99080 --- gcc/ChangeLog | 6 ++++++ gcc/c-cppbuiltin.c | 2 +- gcc/doc/cpp.texi | 20 ++++++++++++++++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/cpp/weak.C | 5 +++++ 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp/weak.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6ba6bb8b5e6..4f48773d438 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2005-05-01 Mark Mitchell + * c-cppbuiltin.c (c_cpp_builtins): Do not define __GXX_WEAK__ to 1 + if !flag_weak. + * doc/cpp.texi (__DEPRECATED): Document. + (__EXCEPTIONS): Likewise. + (__GXX_WEAK__): Likewise. + * function.c (INVOKE__main): Do not define. (expand_main_function): Check HAS_INIT_SECTION when determining whether or not to call __main. diff --git a/gcc/c-cppbuiltin.c b/gcc/c-cppbuiltin.c index 06904dbb5e5..bb656f46b05 100644 --- a/gcc/c-cppbuiltin.c +++ b/gcc/c-cppbuiltin.c @@ -328,7 +328,7 @@ c_cpp_builtins (cpp_reader *pfile) if (c_dialect_cxx ()) { - if (SUPPORTS_ONE_ONLY) + if (flag_weak && SUPPORTS_ONE_ONLY) cpp_define (pfile, "__GXX_WEAK__=1"); else cpp_define (pfile, "__GXX_WEAK__=0"); diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi index 02cb4b8d200..71bd4ee2677 100644 --- a/gcc/doc/cpp.texi +++ b/gcc/doc/cpp.texi @@ -2081,11 +2081,31 @@ respectively. They exist to make the standard header given numerical limits work correctly. You should not use these macros directly; instead, include the appropriate headers. +@item __DEPRECATED +This macro is defined, with value 1, when compiling a C++ source file +with warnings about deprecated constructs enabled. These warnings are +enabled by default, but can be disabled with @option{-Wno-deprecated}. + +@item __EXCEPTIONS +This macro is defined, with value 1, when compiling a C++ source file +with exceptions enabled. If @option{-fno-exceptions} was used when +compiling the file, then this macro will not be defined. + @item __USING_SJLJ_EXCEPTIONS__ This macro is defined, with value 1, if the compiler uses the old mechanism based on @code{setjmp} and @code{longjmp} for exception handling. +@item __GXX_WEAK__ +This macro is defined when compiling a C++ source file. It has the +value 1 if the compiler will use weak symbols, COMDAT sections, or +other similar techniques to collapse symbols with ``vague linkage'' +that are defined in multiple translation units. If the compiler will +not collapse such symbols, this macro is defined with value 0. In +general, user code should not need to make use of this macro; the +purpose of this macro is to ease implementation of the C++ runtime +library provided with G++. + @item __NEXT_RUNTIME__ This macro is defined, with value 1, if (and only if) the NeXT runtime (as in @option{-fnext-runtime}) is in use for Objective-C@. If the GNU diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f1c04ecedd5..33dca447a1e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2005-05-01 Mark Mitchell + + * g++.dg/cpp/weak.C: New test. + 2005-05-01 Zdenek Dvorak * gcc.dg/tree-ssa/loop-8.c: New test. diff --git a/gcc/testsuite/g++.dg/cpp/weak.C b/gcc/testsuite/g++.dg/cpp/weak.C new file mode 100644 index 00000000000..6c51e1985aa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/weak.C @@ -0,0 +1,5 @@ +// { dg-options "-fno-weak" } + +#if __GXX_WEAK__ +#error "__GXX_WEAK__ defined when -fno-weak in use" +#endif -- 2.30.2