diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2004-12-08 08:47:59 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2004-12-08 08:47:59 +0000 |
commit | 0710ccffc3ddf8e4877fdab6cf712cd65f45d1cb (patch) | |
tree | 7de9c095103fb4a7809b6f28a30887d83788c35b | |
parent | e6aef9696474198372ccd66e8a5588b30ffbf93f (diff) | |
download | gcc-0710ccffc3ddf8e4877fdab6cf712cd65f45d1cb.zip gcc-0710ccffc3ddf8e4877fdab6cf712cd65f45d1cb.tar.gz gcc-0710ccffc3ddf8e4877fdab6cf712cd65f45d1cb.tar.bz2 |
re PR c++/18672 (Segfault with simple template code)
.: PR c++/18672
* gimplify.c (canonicalize_addr_expr): Cope with array of
incomplete type.
(gimplify_conversion): Remove redundant checks.
testsuite:
PR c++/18672
* g++.dg/opt/array1.C: New.
From-SVN: r91865
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/gimplify.c | 22 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/opt/array1.C | 20 |
4 files changed, 39 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1579cb3..c6b3059 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2004-12-08 Nathan Sidwell <nathan@codesourcery.com> + PR c++/18672 + * gimplify.c (canonicalize_addr_expr): Cope with array of + incomplete type. + (gimplify_conversion): Remove redundant checks. + * doc/trouble.texi (Non-bugs): Clarify empty loop removal. 2004-12-08 Uros Bizjak <uros@kss-loka.si> diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 41814a7..0b83d78 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1336,7 +1336,8 @@ canonicalize_addr_expr (tree *expr_p) return; /* The lower bound and element sizes must be constant. */ - if (TREE_CODE (TYPE_SIZE_UNIT (dctype)) != INTEGER_CST + if (!TYPE_SIZE_UNIT (dctype) + || TREE_CODE (TYPE_SIZE_UNIT (dctype)) != INTEGER_CST || !TYPE_DOMAIN (datype) || !TYPE_MIN_VALUE (TYPE_DOMAIN (datype)) || TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (datype))) != INTEGER_CST) return; @@ -1356,16 +1357,15 @@ canonicalize_addr_expr (tree *expr_p) static enum gimplify_status gimplify_conversion (tree *expr_p) { - /* If we still have a conversion at the toplevel, then strip - away all but the outermost conversion. */ - if (TREE_CODE (*expr_p) == NOP_EXPR || TREE_CODE (*expr_p) == CONVERT_EXPR) - { - STRIP_SIGN_NOPS (TREE_OPERAND (*expr_p, 0)); - - /* And remove the outermost conversion if it's useless. */ - if (tree_ssa_useless_type_conversion (*expr_p)) - *expr_p = TREE_OPERAND (*expr_p, 0); - } + gcc_assert (TREE_CODE (*expr_p) == NOP_EXPR + || TREE_CODE (*expr_p) == CONVERT_EXPR); + + /* Then strip away all but the outermost conversion. */ + STRIP_SIGN_NOPS (TREE_OPERAND (*expr_p, 0)); + + /* And remove the outermost conversion if it's useless. */ + if (tree_ssa_useless_type_conversion (*expr_p)) + *expr_p = TREE_OPERAND (*expr_p, 0); /* If we still have a conversion at the toplevel, then canonicalize some constructs. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index eac55df..0527609 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2004-12-08 Nathan Sidwell <nathan@codesourcery.com> + PR c++/18672 + * g++.dg/opt/array1.C: New. + PR c++/18803 * g++.dg/template/operator5.C: New. diff --git a/gcc/testsuite/g++.dg/opt/array1.C b/gcc/testsuite/g++.dg/opt/array1.C new file mode 100644 index 0000000..c63ed22 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/array1.C @@ -0,0 +1,20 @@ +// Copyright (C) 2004 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Nov 2004 <nathan@codesourcery.com> + +// PR 18672:ICE gimplifying incomplete array type. +// Origin: Magnus Fromreide <gcc@magfr.user.lysator.liu.se> + +struct A; + +struct D { + static A ary[]; +}; +extern A ary[]; + +void Foo (A const *); + +void Bar () +{ + Foo (D::ary); + Foo (::ary); +} |