target/6569: sparc-sun-solaris2.7 C testsuite regression in compile/20011119-2.c
Franz Sirl
Franz.Sirl-kernel@lauterbach.com
Mon May 6 13:22:00 GMT 2002
On Monday 06 May 2002 08:03, davem@gcc.gnu.org wrote:
> Synopsis: sparc-sun-solaris2.7 C testsuite regression in
> compile/20011119-2.c
>
> Responsible-Changed-From-To: unassigned->sirl
> Responsible-Changed-By: davem
> Responsible-Changed-When: Sun May 5 23:03:04 2002
> Responsible-Changed-Why:
> On request by Mark.
>
> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&
>pr=6569
Can you try the attached patch? It seems to work for me, but the bootstrap
hasn't completed yet. While I was at it, I improved the placing of the
warning messages. I'm still a bit confused, cause it sometimes seems olddecl
and newdecl appeared to be swapped compared to their sourcefile ordering.
Franz.
* varasm.c (declare_weak_1): New, splitout from declare_weak.
(declare_weak): Use declare_weak_1.
(merge_weak): Likewise. Always use NEWDECL for warning message.
-------------- next part --------------
Index: gcc/varasm.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.250.2.9
diff -u -p -r1.250.2.9 varasm.c
--- gcc/varasm.c 1 May 2002 18:03:34 -0000 1.250.2.9
+++ gcc/varasm.c 6 May 2002 18:46:56 -0000
@@ -166,6 +166,7 @@ static unsigned HOST_WIDE_INT array_size
static unsigned min_align PARAMS ((unsigned, unsigned));
static void output_constructor PARAMS ((tree, HOST_WIDE_INT,
unsigned int));
+static void declare_weak_1 PARAMS ((tree, int));
static void globalize_decl PARAMS ((tree));
static int in_named_entry_eq PARAMS ((const PTR, const PTR));
static hashval_t in_named_entry_hash PARAMS ((const PTR));
@@ -5010,16 +5011,18 @@ merge_weak (newdecl, olddecl)
|| ! TREE_STATIC (decl))
&& TREE_USED (decl)
&& TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
- warning_with_decl (decl, "weak declaration of `%s' after first use results in unspecified behavior");
+ warning_with_decl (newdecl, "weak declaration of `%s' after first use results in unspecified behavior");
- declare_weak (decl);
+ declare_weak_1 (decl, DECL_WEAK (newdecl));
}
-/* Declare DECL to be a weak symbol. */
+/* Declare DECL to be a weak symbol, put it on the WEAK_DECLS list
+ if NEW is set. */
-void
-declare_weak (decl)
+static void
+declare_weak_1 (decl, new)
tree decl;
+ int new;
{
if (! TREE_PUBLIC (decl))
error_with_decl (decl, "weak declaration of `%s' must be public");
@@ -5027,7 +5030,7 @@ declare_weak (decl)
error_with_decl (decl, "weak declaration of `%s' must precede definition");
else if (SUPPORTS_WEAK)
{
- if (! DECL_WEAK (decl))
+ if (new && ! DECL_WEAK (decl))
weak_decls = tree_cons (NULL, decl, weak_decls);
}
else
@@ -5040,6 +5043,15 @@ declare_weak (decl)
&& XEXP (DECL_RTL (decl), 0)
&& GET_CODE (XEXP (DECL_RTL (decl), 0)) == SYMBOL_REF)
SYMBOL_REF_WEAK (XEXP (DECL_RTL (decl), 0)) = 1;
+}
+
+/* Declare DECL to be a weak symbol. */
+
+void
+declare_weak (decl)
+ tree decl;
+{
+ declare_weak_1 (decl, 1);
}
/* Emit any pending weak declarations. */
Index: gcc/testsuite/gcc.dg/weak-3.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/testsuite/gcc.dg/weak-3.c,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 weak-3.c
--- gcc/testsuite/gcc.dg/weak-3.c 28 Apr 2002 18:43:58 -0000 1.1.2.1
+++ gcc/testsuite/gcc.dg/weak-3.c 6 May 2002 18:46:56 -0000
@@ -34,12 +34,12 @@ void * foo1b (void)
}
-extern void * ffoo1c (void); /* { dg-warning "weak declaration" "weak declaration" } */
+extern void * ffoo1c (void);
void * foo1c (void)
{
return (void *)ffoo1c;
}
-extern void * ffoo1c (void) __attribute__((weak));
+extern void * ffoo1c (void) __attribute__((weak)); /* { dg-warning "weak declaration" "weak declaration" } */
int ffoo1d (void);
@@ -56,7 +56,7 @@ void * foo1e (void)
}
-extern void * ffoo1f (void); /* { dg-warning "weak declaration" "weak declaration" } */
+extern void * ffoo1f (void);
extern void * ffoox1f (void);
void * foo1f (void)
{
@@ -64,7 +64,7 @@ void * foo1f (void)
ffoo1f ();
return 0;
}
-extern void * ffoo1f (void) __attribute__((weak, alias ("ffoox1f")));
+extern void * ffoo1f (void) __attribute__((weak, alias ("ffoox1f"))); /* { dg-warning "weak declaration" "weak declaration" } */
extern void * ffoo1g (void);
Index: gcc/testsuite/gcc.dg/weak-5.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/testsuite/gcc.dg/weak-5.c,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 weak-5.c
--- gcc/testsuite/gcc.dg/weak-5.c 28 Apr 2002 18:43:58 -0000 1.1.2.1
+++ gcc/testsuite/gcc.dg/weak-5.c 6 May 2002 18:46:56 -0000
@@ -39,12 +39,12 @@ void * foo1b (void)
}
-extern int vfoo1c; /* { dg-warning "weak declaration" "weak declaration" } */
+extern int vfoo1c;
void * foo1c (void)
{
return (void *)&vfoo1c;
}
-extern int vfoo1c __attribute__((weak));
+extern int vfoo1c __attribute__((weak)); /* { dg-warning "weak declaration" "weak declaration" } */
extern int vfoo1d __attribute__((weak));
More information about the Gcc-bugs
mailing list