This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[LTO]: PATCH: Avoid being confused by TRANSLATION_UNIT_DECL
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: zadeck at naturalbridge dot com
- Date: Sun, 5 Aug 2007 17:30:29 -0700
- Subject: [LTO]: PATCH: Avoid being confused by TRANSLATION_UNIT_DECL
- Reply-to: mark at codesourcery dot com
Kenny --
The problem that you ran into with structure types was due to the
DWARF writer not handling TRANSLATION_UNIT_DECL. This patch fixes
that oversight.
However, trying to process this program in the LTO reader blows up in
build_decl for a local variable; it appears that you're creating a
VAR_DECL without giving it a type, and that makes the middle end
unhappy.
struct S {
int x;
int y;
};
int foo (void) {
struct S s;
return s.x;
}
Committed.
Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
2007-08-05 Mark Mitchell <mark@codesourcery.com>
* tree.h (FILE_SCOPE_P): New macro.
(DECL_FILE_SCOPE_P): Use it.
* dwarf2out.c (lto_type_ref): Use FILE_SCOPE_P to test whether
an entity is at file scope.
Index: gcc/tree.h
===================================================================
--- gcc/tree.h (revision 127226)
+++ gcc/tree.h (working copy)
@@ -2667,10 +2667,14 @@ struct tree_memory_partition_tag GTY(())
#define DECL_POINTER_ALIAS_SET_KNOWN_P(NODE) \
(DECL_POINTER_ALIAS_SET (NODE) != - 1)
+/* Nonzero for a scope (e.g., the value of either DECL_CONTEXT or
+ TYPE_CONTEXT) which is the file scope. */
+#define FILE_SCOPE_P(SCOPE) \
+ (!(SCOPE) || TREE_CODE (SCOPE) == TRANSLATION_UNIT_DECL)
+
/* Nonzero for a decl which is at file scope. */
-#define DECL_FILE_SCOPE_P(EXP) \
- (! DECL_CONTEXT (EXP) \
- || TREE_CODE (DECL_CONTEXT (EXP)) == TRANSLATION_UNIT_DECL)
+#define DECL_FILE_SCOPE_P(EXP) \
+ FILE_SCOPE_P (DECL_CONTEXT (EXP))
/* Nonzero for a decl that is decorated using attribute used.
This indicates compiler tools that this decl needs to be preserved. */
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c (revision 127226)
+++ gcc/dwarf2out.c (working copy)
@@ -14929,7 +14929,7 @@ lto_type_ref (tree type, lto_out_ref *re
gcc_assert (TYPE_P (type));
scope = TYPE_CONTEXT (type);
- if (scope)
+ if (!FILE_SCOPE_P (scope))
{
/* We do not yet support lexically scoped types. */
sorry ("nested types are not supported by LTO");