This commit is contained in:
Jakub Jelinek 2007-10-02 22:21:55 +00:00
parent f7b32afe54
commit 720e849aa6
3 changed files with 158 additions and 1 deletions

View File

@ -0,0 +1,102 @@
2007-10-02 Jakub Jelinek <jakub@redhat.com>
* decl.c (duplicate_decls): When redeclaring a builtin function,
keep the merged decl builtin whenever types match, even if new
decl defines a function.
* gcc.dg/builtins-65.c: New test.
* g++.dg/ext/builtin10.C: New test.
--- gcc/cp/decl.c.jj 2007-10-01 22:11:09.000000000 +0200
+++ gcc/cp/decl.c 2007-10-02 11:39:46.000000000 +0200
@@ -1988,23 +1988,21 @@ duplicate_decls (tree newdecl, tree oldd
DECL_ARGUMENTS (olddecl) = DECL_ARGUMENTS (newdecl);
DECL_RESULT (olddecl) = DECL_RESULT (newdecl);
}
+ /* If redeclaring a builtin function, it stays built in. */
+ if (types_match && DECL_BUILT_IN (olddecl))
+ {
+ DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl);
+ DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl);
+ /* If we're keeping the built-in definition, keep the rtl,
+ regardless of declaration matches. */
+ COPY_DECL_RTL (olddecl, newdecl);
+ }
if (new_defines_function)
/* If defining a function declared with other language
linkage, use the previously declared language linkage. */
SET_DECL_LANGUAGE (newdecl, DECL_LANGUAGE (olddecl));
else if (types_match)
{
- /* If redeclaring a builtin function, and not a definition,
- it stays built in. */
- if (DECL_BUILT_IN (olddecl))
- {
- DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl);
- DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl);
- /* If we're keeping the built-in definition, keep the rtl,
- regardless of declaration matches. */
- COPY_DECL_RTL (olddecl, newdecl);
- }
-
DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
/* Don't clear out the arguments if we're redefining a function. */
if (DECL_ARGUMENTS (olddecl))
--- gcc/testsuite/gcc.dg/builtins-65.c.jj 2007-10-02 11:23:51.000000000 +0200
+++ gcc/testsuite/gcc.dg/builtins-65.c 2007-10-02 11:24:12.000000000 +0200
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+typedef __SIZE_TYPE__ size_t;
+extern void __chk_fail (void);
+extern int snprintf (char *, size_t, const char *, ...);
+extern inline __attribute__((gnu_inline, always_inline)) int snprintf (char *a, size_t b, const char *fmt, ...)
+{
+ if (__builtin_object_size (a, 0) != -1UL && __builtin_object_size (a, 0) < b)
+ __chk_fail ();
+ return __builtin_snprintf (a, b, fmt, __builtin_va_arg_pack ());
+}
+extern int snprintf (char *, size_t, const char *, ...) __asm ("mysnprintf");
+
+char buf[10];
+
+int
+main (void)
+{
+ snprintf (buf, 10, "%d%d\n", 10, 10);
+ return 0;
+}
+
+/* { dg-final { scan-assembler "mysnprintf" } } */
+/* { dg-final { scan-assembler-not "__chk_fail" } } */
--- gcc/testsuite/g++.dg/ext/builtin10.C.jj 2007-10-02 11:19:45.000000000 +0200
+++ gcc/testsuite/g++.dg/ext/builtin10.C 2007-10-02 11:23:26.000000000 +0200
@@ -0,0 +1,27 @@
+// { dg-do compile }
+// { dg-options "-O2" }
+
+typedef __SIZE_TYPE__ size_t;
+extern "C" {
+extern void __chk_fail (void);
+extern int snprintf (char *, size_t, const char *, ...);
+extern inline __attribute__((gnu_inline, always_inline)) int snprintf (char *a, size_t b, const char *fmt, ...)
+{
+ if (__builtin_object_size (a, 0) != -1UL && __builtin_object_size (a, 0) < b)
+ __chk_fail ();
+ return __builtin_snprintf (a, b, fmt, __builtin_va_arg_pack ());
+}
+extern int snprintf (char *, size_t, const char *, ...) __asm ("mysnprintf");
+}
+
+char buf[10];
+
+int
+main (void)
+{
+ snprintf (buf, 10, "%d%d\n", 10, 10);
+ return 0;
+}
+
+// { dg-final { scan-assembler "mysnprintf" } }
+// { dg-final { scan-assembler-not "__chk_fail" } }

View File

@ -0,0 +1,47 @@
2007-09-06 Jason Merrill <jason@redhat.com>
* decl2.c (get_guard): Copy visibility from the guarded variable.
--- gcc/cp/decl2.c (revision 128225)
+++ gcc/cp/decl2.c (revision 128226)
@@ -2215,6 +2215,8 @@ get_guard (tree decl)
DECL_ONE_ONLY (guard) = DECL_ONE_ONLY (decl);
if (TREE_PUBLIC (decl))
DECL_WEAK (guard) = DECL_WEAK (decl);
+ DECL_VISIBILITY (guard) = DECL_VISIBILITY (decl);
+ DECL_VISIBILITY_SPECIFIED (guard) = DECL_VISIBILITY_SPECIFIED (decl);
DECL_ARTIFICIAL (guard) = 1;
DECL_IGNORED_P (guard) = 1;
--- gcc/testsuite/g++.dg/ext/visibility/guard1.C (revision 0)
+++ gcc/testsuite/g++.dg/ext/visibility/guard1.C (revision 128226)
@@ -0,0 +1,29 @@
+// { dg-options "-fvisibility=hidden" }
+// { dg-require-visibility "" }
+// { dg-final { scan-not-hidden "_ZGVZN5otherclEvE4s_cd" } }
+
+extern "C" int printf (const char *, ...);
+
+#define DLLEXPORT __attribute__ ((visibility("default")))
+
+struct class_data
+{
+ int apple;
+ class_data() { printf("non trivial ctor\n"); }
+};
+
+struct DLLEXPORT other
+{
+ class_data* operator ()()
+ {
+ static class_data s_cd;
+ return &s_cd;
+ }
+};
+
+int main()
+{
+ other aFoo;
+ aFoo();
+ return 0;
+}

View File

@ -1,6 +1,6 @@
%define DATE 20070925 %define DATE 20070925
%define gcc_version 4.1.2 %define gcc_version 4.1.2
%define gcc_release 30 %define gcc_release 31
%define _unpackaged_files_terminate_build 0 %define _unpackaged_files_terminate_build 0
%define multilib_64_archs sparc64 ppc64 s390x x86_64 %define multilib_64_archs sparc64 ppc64 s390x x86_64
%define include_gappletviewer 1 %define include_gappletviewer 1
@ -147,6 +147,8 @@ Patch30: gcc41-pr20880.patch
Patch31: gcc41-pr32694.patch Patch31: gcc41-pr32694.patch
Patch32: gcc41-virtual-inline-backtrace.patch Patch32: gcc41-virtual-inline-backtrace.patch
Patch33: gcc41-c++-gnu-inline-redecl.patch Patch33: gcc41-c++-gnu-inline-redecl.patch
Patch34: gcc41-c++-builtin-redecl.patch
Patch35: gcc41-c++-guard-visibility.patch
# On ARM EABI systems, we do want -gnueabi to be part of the # On ARM EABI systems, we do want -gnueabi to be part of the
# target triple. # target triple.
@ -463,6 +465,8 @@ which are required to run programs compiled with the GNAT.
%patch31 -p0 -b .pr32694~ %patch31 -p0 -b .pr32694~
%patch32 -p0 -b .virtual-inline-backtrace~ %patch32 -p0 -b .virtual-inline-backtrace~
%patch33 -p0 -b .c++-gnu-inline-redecl~ %patch33 -p0 -b .c++-gnu-inline-redecl~
%patch34 -p0 -b .c++-builtin-redecl~
%patch35 -p0 -b .c++-guard-visibility~
sed -i -e 's/4\.1\.3/4.1.2/' gcc/BASE-VER gcc/version.c sed -i -e 's/4\.1\.3/4.1.2/' gcc/BASE-VER gcc/version.c
sed -i -e 's/" (Red Hat[^)]*)"/" (Red Hat %{version}-%{gcc_release})"/' gcc/version.c sed -i -e 's/" (Red Hat[^)]*)"/" (Red Hat %{version}-%{gcc_release})"/' gcc/version.c
@ -1617,6 +1621,10 @@ fi
%doc rpm.doc/changelogs/libmudflap/ChangeLog* %doc rpm.doc/changelogs/libmudflap/ChangeLog*
%changelog %changelog
* Wed Oct 3 2007 Jakub Jelinek <jakub@redhat.com> 4.1.2-31
- fix visibility of C++ guard variables (Jason Merrill)
- don't drop DECL_BUILT_IN_CLASS when defining a builtin function
* Mon Oct 1 2007 Jakub Jelinek <jakub@redhat.com> 4.1.2-30 * Mon Oct 1 2007 Jakub Jelinek <jakub@redhat.com> 4.1.2-30
- fix ICE on C++ gnu_inline function followed by prototype of the same - fix ICE on C++ gnu_inline function followed by prototype of the same
fn (Alexandre Oliva) fn (Alexandre Oliva)