diff options
author | jamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-03-11 22:27:26 +0000 |
---|---|---|
committer | jamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-03-11 22:27:26 +0000 |
commit | 6816d0c461d2fa52bffa30e4a7901091d134ac3c (patch) | |
tree | a99001a237dfd1caa78f3f3dd0c869a43f4fe759 | |
parent | ca4b7618c8baba16ad5ad0b44ca4a1d452ddfeea (diff) | |
download | gcc-6816d0c461d2fa52bffa30e4a7901091d134ac3c.tar.gz |
2010-03-11 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/43257
* tree.c (assign_assembler_name_if_neeeded): New function.
(free_lang_data_in_cgraph): Assembler name assignment moved to the
above new function.
* tree.h (assign_assembler_name_if_neeeded): Declare.
* cgraphunit.c (cgraph_analyze_function): Create an assembler name for
the function if needed.
* testsuite/g++.dg/torture/pr43257.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157393 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cgraphunit.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/torture/pr43257.C | 30 | ||||
-rw-r--r-- | gcc/tree.c | 48 | ||||
-rw-r--r-- | gcc/tree.h | 2 |
6 files changed, 77 insertions, 20 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ab8f589cd82..dff9016c564 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2010-03-11 Martin Jambor <mjambor@suse.cz> + + PR tree-optimization/43257 + * tree.c (assign_assembler_name_if_neeeded): New function. + (free_lang_data_in_cgraph): Assembler name assignment moved to the + above new function. + * tree.h (assign_assembler_name_if_neeeded): Declare. + * cgraphunit.c (cgraph_analyze_function): Create an assembler name for + the function if needed. + 2010-03-11 Chris Demetriou <cgd@google.com> * Makefile.in (stmp-int-hdrs): Make include/unwind.h, diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 399912bfbd5..f4580adbd75 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -836,6 +836,8 @@ cgraph_analyze_function (struct cgraph_node *node) current_function_decl = decl; push_cfun (DECL_STRUCT_FUNCTION (decl)); + assign_assembler_name_if_neeeded (node->decl); + /* Make sure to gimplify bodies only once. During analyzing a function we lower it, which will require gimplified nested functions, so we can end up here with an already gimplified diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 152db476016..279f499a238 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-03-11 Martin Jambor <mjambor@suse.cz> + + PR tree-optimization/43257 + * g++.dg/torture/pr43257.C: New test. + 2010-03-11 Tobias Burnus <burnus@net-b.de> PR fortran/43228 diff --git a/gcc/testsuite/g++.dg/torture/pr43257.C b/gcc/testsuite/g++.dg/torture/pr43257.C new file mode 100644 index 00000000000..a3e75574adb --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr43257.C @@ -0,0 +1,30 @@ +/* { dg-do assemble } */ + +class A {}; +class B {}; + +static void *func (int n) +{ + void *p; + if (p == 0) throw ::A (); +} + +static void *func (int n, B const &) +{ + try { + return func (n); + } + catch (::A const &) { + } + return func (n); +} + +void *f1 (int n) +{ + return func (n, B()); +} + +void *f2 (int n) +{ + return func (n, B()); +} diff --git a/gcc/tree.c b/gcc/tree.c index c51cca7d6f7..86fe2bb3b62 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -4831,6 +4831,33 @@ find_decls_types_in_var (struct varpool_node *v, struct free_lang_data_d *fld) find_decls_types (v->decl, fld); } +/* If T needs an assembler name, have one created for it. */ + +void +assign_assembler_name_if_neeeded (tree t) +{ + if (need_assembler_name_p (t)) + { + /* When setting DECL_ASSEMBLER_NAME, the C++ mangler may emit + diagnostics that use input_location to show locus + information. The problem here is that, at this point, + input_location is generally anchored to the end of the file + (since the parser is long gone), so we don't have a good + position to pin it to. + + To alleviate this problem, this uses the location of T's + declaration. Examples of this are + testsuite/g++.dg/template/cond2.C and + testsuite/g++.dg/template/pr35240.C. */ + location_t saved_location = input_location; + input_location = DECL_SOURCE_LOCATION (t); + + decl_assembler_name (t); + + input_location = saved_location; + } +} + /* Free language specific information for every operand and expression in every node of the call graph. This process operates in three stages: @@ -4880,26 +4907,7 @@ free_lang_data_in_cgraph (void) now because free_lang_data_in_decl will invalidate data needed for mangling. This breaks mangling on interdependent decls. */ for (i = 0; VEC_iterate (tree, fld.decls, i, t); i++) - if (need_assembler_name_p (t)) - { - /* When setting DECL_ASSEMBLER_NAME, the C++ mangler may emit - diagnostics that use input_location to show locus - information. The problem here is that, at this point, - input_location is generally anchored to the end of the file - (since the parser is long gone), so we don't have a good - position to pin it to. - - To alleviate this problem, this uses the location of T's - declaration. Examples of this are - testsuite/g++.dg/template/cond2.C and - testsuite/g++.dg/template/pr35240.C. */ - location_t saved_location = input_location; - input_location = DECL_SOURCE_LOCATION (t); - - decl_assembler_name (t); - - input_location = saved_location; - } + assign_assembler_name_if_neeeded (t); /* Traverse every decl found freeing its language data. */ for (i = 0; VEC_iterate (tree, fld.decls, i, t); i++) diff --git a/gcc/tree.h b/gcc/tree.h index f9fa00ff983..7e51ea624ae 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4720,6 +4720,8 @@ extern tree build_low_bits_mask (tree, unsigned); extern tree tree_strip_nop_conversions (tree); extern tree tree_strip_sign_nop_conversions (tree); extern tree lhd_gcc_personality (void); +extern void assign_assembler_name_if_neeeded (tree); + /* In cgraph.c */ extern void change_decl_assembler_name (tree, tree); |