aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2008-09-04 12:30:26 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2008-09-04 10:30:26 +0000
commit4db15d75ec50a9eb20ebd8fa95a1fda5c7a635e3 (patch)
tree81758f4a1a9d589ec8f3ccfa19b59c3b8a8e29e5 /gcc/tree.c
parent28e6bb130e41cc18e1d07330a154862a4927af65 (diff)
downloadgcc-4db15d75ec50a9eb20ebd8fa95a1fda5c7a635e3.zip
gcc-4db15d75ec50a9eb20ebd8fa95a1fda5c7a635e3.tar.gz
gcc-4db15d75ec50a9eb20ebd8fa95a1fda5c7a635e3.tar.bz2
re PR tree-optimization/37345 (Segfault in decl_function_context (TYPE_MAIN_VARIANT))
PR tree-optimization/37345 PR tree-optimization/37358 PR tree-optimization/37357 * tree.c (build_function_type_skip_args): Build distinct type copy; set TYPE_CONTEXT. (build_function_decl_skip_args): Set type of new decl not orig decl; clear DECL_VINDEX for methods turned into functions. From-SVN: r139980
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 95680ba..71267bd 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5925,7 +5925,12 @@ build_function_type_skip_args (tree orig_type, bitmap args_to_skip)
TYPE_ARG_TYPES (new_type) = new_reversed;
}
else
- new_type = build_function_type (TREE_TYPE (orig_type), new_reversed);
+ {
+ new_type
+ = build_distinct_type_copy (build_function_type (TREE_TYPE (orig_type),
+ new_reversed));
+ TYPE_CONTEXT (new_type) = TYPE_CONTEXT (orig_type);
+ }
/* This is a new type, not a copy of an old type. Need to reassociate
variants. We can handle everything except the main variant lazily. */
@@ -5959,7 +5964,12 @@ build_function_decl_skip_args (tree orig_decl, bitmap args_to_skip)
new_type = TREE_TYPE (orig_decl);
if (prototype_p (new_type))
new_type = build_function_type_skip_args (new_type, args_to_skip);
- TREE_TYPE (orig_decl) = new_type;
+ TREE_TYPE (new_decl) = new_type;
+
+ /* For declarations setting DECL_VINDEX (i.e. methods)
+ we expect first argument to be THIS pointer. */
+ if (bitmap_bit_p (args_to_skip, 0))
+ DECL_VINDEX (new_decl) = NULL_TREE;
return new_decl;
}