aboutsummaryrefslogtreecommitdiff
path: root/gcc/lto
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2015-12-11 00:57:15 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2015-12-10 23:57:15 +0000
commit958a627f8831aad2d1d87c1a95b622722f375e73 (patch)
tree81333eac2542fe1d73ebec68b922ed18cd399b73 /gcc/lto
parent0c91a1fb3c6bf27bd513d6a160bdce14a7070a60 (diff)
downloadgcc-958a627f8831aad2d1d87c1a95b622722f375e73.zip
gcc-958a627f8831aad2d1d87c1a95b622722f375e73.tar.gz
gcc-958a627f8831aad2d1d87c1a95b622722f375e73.tar.bz2
re PR lto/61886 (LTO breaks fread with _FORTIFY_SOURCE=2)
PR ipa/61886 * lto-symtab.c (lto_symtab_merge_p): Avoid merging across different values of error and warning attributes. * gcc.dg/lto/pr61886_0.c: New testcase From-SVN: r231548
Diffstat (limited to 'gcc/lto')
-rw-r--r--gcc/lto/ChangeLog6
-rw-r--r--gcc/lto/lto-symtab.c52
2 files changed, 52 insertions, 6 deletions
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog
index 4fe2ebe..f0d90fc 100644
--- a/gcc/lto/ChangeLog
+++ b/gcc/lto/ChangeLog
@@ -1,3 +1,9 @@
+2015-12-11 Jan Hubicka <hubicka@ucw.cz>
+
+ PR ipa/61886
+ * lto-symtab.c (lto_symtab_merge_p): Avoid merging across different
+ values of error and warning attributes.
+
2015-12-08 Jan Hubicka <hubicka@ucw.cz>
PR lto/68811
diff --git a/gcc/lto/lto-symtab.c b/gcc/lto/lto-symtab.c
index d4868c4..35c690a 100644
--- a/gcc/lto/lto-symtab.c
+++ b/gcc/lto/lto-symtab.c
@@ -511,19 +511,59 @@ static bool
lto_symtab_merge_p (tree prevailing, tree decl)
{
if (TREE_CODE (prevailing) != TREE_CODE (decl))
- return false;
+ {
+ if (symtab->dump_file)
+ fprintf (symtab->dump_file, "Not merging decls; "
+ "TREE_CODE mismatch\n");
+ return false;
+ }
if (TREE_CODE (prevailing) == FUNCTION_DECL)
{
if (DECL_BUILT_IN (prevailing) != DECL_BUILT_IN (decl))
- return false;
+ {
+ if (symtab->dump_file)
+ fprintf (symtab->dump_file, "Not merging decls; "
+ "DECL_BUILT_IN mismatch\n");
+ return false;
+ }
if (DECL_BUILT_IN (prevailing)
&& (DECL_BUILT_IN_CLASS (prevailing) != DECL_BUILT_IN_CLASS (decl)
|| DECL_FUNCTION_CODE (prevailing) != DECL_FUNCTION_CODE (decl)))
- return false;
+ {
+ if (symtab->dump_file)
+ fprintf (symtab->dump_file, "Not merging decls; "
+ "DECL_BUILT_IN_CLASS or CODE mismatch\n");
+ return false;
+ }
+ }
+ if (DECL_ATTRIBUTES (prevailing) != DECL_ATTRIBUTES (decl))
+ {
+ tree prev_attr = lookup_attribute ("error", DECL_ATTRIBUTES (prevailing));
+ tree attr = lookup_attribute ("error", DECL_ATTRIBUTES (decl));
+ if ((prev_attr == NULL) != (attr == NULL)
+ || (prev_attr
+ && TREE_VALUE (TREE_VALUE (prev_attr))
+ != TREE_VALUE (TREE_VALUE (attr))))
+ {
+ if (symtab->dump_file)
+ fprintf (symtab->dump_file, "Not merging decls; "
+ "error attribute mismatch\n");
+ return false;
+ }
+
+ prev_attr = lookup_attribute ("warning", DECL_ATTRIBUTES (prevailing));
+ attr = lookup_attribute ("warning", DECL_ATTRIBUTES (decl));
+ if ((prev_attr == NULL) != (attr == NULL)
+ || (prev_attr
+ && TREE_VALUE (TREE_VALUE (prev_attr))
+ != TREE_VALUE (TREE_VALUE (attr))))
+ {
+ if (symtab->dump_file)
+ fprintf (symtab->dump_file, "Not merging decls; "
+ "warning attribute mismatch\n");
+ return false;
+ }
}
- /* There are several other cases where merging can not be done, but until
- aliasing code is fixed to support aliases it we can not really return
- false on non-readonly var, yet. */
return true;
}