This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Attempt to fix PR 13856
- From: "Zack Weinberg" <zack at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org, gcc-bugzilla at gcc dot gnu dot org
- Date: Thu, 05 Feb 2004 23:51:31 -0800
- Subject: Attempt to fix PR 13856
This is an attempt to fix PR 13856 (not handling .hidden correctly
when applied to a definition [in the libc source] of a built-in
function). It doesn't quite work yet. I am seeing a small number of
failures - ICEs in dwarf2out.c::add_abstract_origin_attribute and in
builtin.c::expand_builtin. I am repeating bootstrap overnight to see
if they are unrelated.
zw
===================================================================
Index: c-decl.c
--- c-decl.c 27 Jan 2004 02:35:17 -0000 1.470.4.3
+++ c-decl.c 6 Feb 2004 07:50:07 -0000
@@ -939,7 +939,8 @@ diagnose_mismatched_decls (tree newdecl,
unless OLDDECL is a builtin. OLDDECL will be discarded in any case. */
if (TREE_CODE (olddecl) != TREE_CODE (newdecl))
{
- if (TREE_CODE (olddecl) != FUNCTION_DECL || !DECL_BUILT_IN (olddecl))
+ if (TREE_CODE (olddecl) != FUNCTION_DECL
+ || !DECL_BUILT_IN (olddecl) || !C_DECL_INVISIBLE (olddecl))
{
error ("%J'%D' redeclared as different kind of symbol",
newdecl, newdecl);
@@ -956,7 +957,8 @@ diagnose_mismatched_decls (tree newdecl,
if (!comptypes (oldtype, newtype, COMPARE_STRICT))
{
- if (TREE_CODE (olddecl) == FUNCTION_DECL && DECL_BUILT_IN (olddecl))
+ if (TREE_CODE (olddecl) == FUNCTION_DECL
+ && DECL_BUILT_IN (olddecl) && C_DECL_INVISIBLE (olddecl))
{
/* Accept harmless mismatch in function types.
This is for the ffs and fprintf builtins. */
@@ -1034,6 +1036,7 @@ diagnose_mismatched_decls (tree newdecl,
can't validate the argument list) the built-in definition is
overridden, but optionally warn this was a bad choice of name. */
if (DECL_BUILT_IN (olddecl)
+ && C_DECL_INVISIBLE (olddecl)
&& (!TREE_PUBLIC (newdecl)
|| (DECL_INITIAL (newdecl)
&& !TYPE_ARG_TYPES (TREE_TYPE (newdecl)))))
@@ -1428,20 +1431,9 @@ merge_decls (tree newdecl, tree olddecl,
if (DECL_BUILT_IN (olddecl))
{
- /* Get rid of any built-in function if we have a function
- definition. */
- if (new_is_definition)
- {
- TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
- DECL_BUILT_IN_CLASS (olddecl) = NOT_BUILT_IN;
- }
- else
- {
- /* If redeclaring a builtin function, and not a definition,
- it stays built in. */
- DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl);
- DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl);
- }
+ /* If redeclaring a builtin function, it stays built in. */
+ DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl);
+ DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl);
}
/* Also preserve various other info from the definition. */
===================================================================
Index: testsuite/gcc.c-torture/execute/string-opt-15.c
--- testsuite/gcc.c-torture/execute/string-opt-15.c 21 Jan 2003 19:43:53 -0000 1.2
+++ testsuite/gcc.c-torture/execute/string-opt-15.c 6 Feb 2004 07:50:41 -0000
@@ -39,7 +39,7 @@ main ()
should abort. */
__attribute__ ((noinline))
static int
-memcmp (const char *p1, const char *p2, size_t len)
+memcmp (const void *p1, const void *p2, size_t len)
{
abort ();
}
===================================================================
Index: testsuite/gcc.dg/fwritable-strings-1.c
--- testsuite/gcc.dg/fwritable-strings-1.c 30 Jan 2004 14:23:24 -0000 1.1.2.1
+++ testsuite/gcc.dg/fwritable-strings-1.c 6 Feb 2004 07:50:41 -0000
@@ -3,6 +3,7 @@
/* { dg-do run } */
/* { dg-options "-fwritable-strings" } */
+/* { dg-error "-fwritable-strings is deprecated" "" { target *-*-* } 0 } */
extern void abort(void);
===================================================================
Index: testsuite/gcc.dg/visibility-8.c
--- testsuite/gcc.dg/visibility-8.c 1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/visibility-8.c 6 Feb 2004 07:50:41 -0000
@@ -0,0 +1,16 @@
+/* Test hidden visibility on built-in functions (for libc). */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+/* { dg-require-visibility "" } */
+/* { dg-final { scan-assembler "\\.hidden.*__GI_fputs_unlocked" } } */
+
+int fputs_unlocked (const char *restrict, int *restrict)
+ __asm__ ("__GI_fputs_unlocked")
+ __attribute__ ((visibility ("hidden")));
+
+int
+fputs_unlocked (str, fp)
+ const char *str;
+ int *fp;
+{
+}