This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
------ module1 const int __attribute__((weak)) vaca = 0;
int
f(void)
{
return vaca;
}------ module2 #include <stdio.h>
main()
{
printf ("%d\n", f()); /* should print 2 */
return 0;
}
------* gcc/c-typeck.c (decl_constant_value): check DECL_WEAK. * gcc/tree-ssa-ccp.c (get_symbol_constant_value): Likewise.
Attachment:
const-weak.c
Description: application/source
Index: gcc/tree-ssa-ccp.c
===================================================================
--- gcc/tree-ssa-ccp.c (revision 134799)
+++ gcc/tree-ssa-ccp.c (working copy)
@@ -275,6 +275,7 @@
{
if (TREE_STATIC (sym)
&& TREE_READONLY (sym)
+ && !DECL_WEAK (sym)
&& !MTAG_P (sym))
{
tree val = DECL_INITIAL (sym);
Index: gcc/c-typeck.c
===================================================================
--- gcc/c-typeck.c (revision 134799)
+++ gcc/c-typeck.c (working copy)
@@ -1545,6 +1545,7 @@
&& !TREE_THIS_VOLATILE (decl)
&& TREE_READONLY (decl)
&& DECL_INITIAL (decl) != 0
+ && !DECL_WEAK (decl)
&& TREE_CODE (DECL_INITIAL (decl)) != ERROR_MARK
/* This is invalid if initial value is not constant.
If it has either a function call, a memory reference,
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |