From 0948e3921d0e0e19928f59f22e241b9648233e3b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 18 Feb 2005 00:56:54 +0100 Subject: [PATCH] re PR c++/20023 (internal compiler error: Segmentation fault) PR c++/20023 PR tree-optimization/20009 * convert.c (convert_to_integer): Revert 2005-02-16 change. * gcc.c-torture/compile/20050217-1.c: New test. * g++.dg/opt/switch3.C: New test. From-SVN: r95208 --- gcc/ChangeLog | 4 ++++ gcc/convert.c | 3 +-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/opt/switch3.C | 16 ++++++++++++++++ gcc/testsuite/gcc.c-torture/compile/20050217-1.c | 14 ++++++++++++++ 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/opt/switch3.C create mode 100644 gcc/testsuite/gcc.c-torture/compile/20050217-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 610d47ac393..77930b280fa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2005-02-18 Jakub Jelinek + PR c++/20023 + PR tree-optimization/20009 + * convert.c (convert_to_integer): Revert 2005-02-16 change. + PR tree-optimization/18947 * cgraphunit.c (cgraph_finalize_function): When redefining an extern inline, remove all nodes that are inlined into the extern inline diff --git a/gcc/convert.c b/gcc/convert.c index c48b242b655..f900ace21e4 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -387,8 +387,7 @@ convert_to_integer (tree type, tree expr) expr = integer_zero_node; else expr = fold (build1 (CONVERT_EXPR, - lang_hooks.types.type_for_size - (POINTER_SIZE, TYPE_UNSIGNED (type)), + lang_hooks.types.type_for_size (POINTER_SIZE, 0), expr)); return convert_to_integer (type, expr); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ccfd4ef6929..668d6e471c3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2005-02-18 Jakub Jelinek + PR c++/20023 + PR tree-optimization/20009 + * gcc.c-torture/compile/20050217-1.c: New test. + * g++.dg/opt/switch3.C: New test. + PR tree-optimization/18947 * gcc.c-torture/compile/20050215-1.c: New test. * gcc.c-torture/compile/20050215-2.c: New test. diff --git a/gcc/testsuite/g++.dg/opt/switch3.C b/gcc/testsuite/g++.dg/opt/switch3.C new file mode 100644 index 00000000000..643cac3235b --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/switch3.C @@ -0,0 +1,16 @@ +// PR c++/20023 +// { dg-do compile } +// { dg-options "-O2" } + +void f (void); +typedef __SIZE_TYPE__ size_t; +void g (void *a) +{ + size_t b = (size_t) a; + switch (b) + { + case 1: + f (); + break; + } +} diff --git a/gcc/testsuite/gcc.c-torture/compile/20050217-1.c b/gcc/testsuite/gcc.c-torture/compile/20050217-1.c new file mode 100644 index 00000000000..f4b928d1e04 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20050217-1.c @@ -0,0 +1,14 @@ +/* PR c++/20023 */ + +void f (void); +typedef __SIZE_TYPE__ size_t; +void g (void *a) +{ + size_t b = (size_t) a; + switch (b) + { + case 1: + f (); + break; + } +}