From bdb567c7f63269189b95cb72b24368bcc7667514 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Wed, 12 Sep 2007 07:54:17 +0000 Subject: [PATCH] re PR middle-end/33382 (internal compiler error: in get_constraint_for_component_ref, at tree-ssa-structalias.c:2454) 2007-09-12 Richard Guenther PR middle-end/33382 * tree-ssa-structalias.c (get_constraint_for_component_ref): Note that accesses to a whole flexible array member may not lead to a subvariable. * gcc.c-torture/compile/pr33382.c: New testcase. * gcc.c-torture/execute/pr33382.c: Likewise. From-SVN: r128417 --- gcc/ChangeLog | 7 ++ gcc/testsuite/ChangeLog | 6 ++ gcc/testsuite/gcc.c-torture/compile/pr33382.c | 95 +++++++++++++++++++ gcc/testsuite/gcc.c-torture/execute/pr33382.c | 21 ++++ gcc/tree-ssa-structalias.c | 3 +- 5 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr33382.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr33382.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d1a90998f3c7..f5a6956ed635 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2007-09-12 Richard Guenther + + PR middle-end/33382 + * tree-ssa-structalias.c (get_constraint_for_component_ref): + Note that accesses to a whole flexible array member may not lead + to a subvariable. + 2007-09-10 Bob Wilson * config/xtensa/xtensa.c (xtensa_output_literal): Mask out high bits diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2643d8407f84..8a8ed97c10d2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2007-09-12 Richard Guenther + + PR middle-end/33382 + * gcc.c-torture/compile/pr33382.c: New testcase. + * gcc.c-torture/execute/pr33382.c: Likewise. + 2007-09-06 Paolo Carlini PR c++/32674 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr33382.c b/gcc/testsuite/gcc.c-torture/compile/pr33382.c new file mode 100644 index 000000000000..d83f74e42ccc --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr33382.c @@ -0,0 +1,95 @@ +typedef unsigned int size_t; +typedef struct { + int disable; + char *searchconfig[]; +} config_t; +typedef struct { + void *lng; +} arglist_t; +config_t config = { + .searchconfig = { + ((void *) 0)} +}; + +arglist_t arglist[] = { + { + &config.searchconfig[0]} +}; +const int arglistsize = ((int) (sizeof(arglist) / sizeof(arglist_t))); +void show_configuration(char *arg) +{ + int i; + + if (!__extension__( { + size_t + __s1_len, + __s2_len; (__builtin_constant_p(arglist[i].lng) + && (__s1_len = (!((size_t) + (const void *) + 1) + || __s2_len >= 4)) + ? : (__builtin_constant_p(arglist[i].lng) + && ((size_t) + (const void *) + 4) + ? (__builtin_constant_p(arg) + && ((size_t) (const void *) 1) ? + : (__extension__( { + __const * __s2 = + (__const *) + (arg); + register + __result = + (((__const + *) (arglist + [i]. + lng))[0] + - __s2[0]); + if (__s1_len == + 0) { + if (__s1_len == + 0) { + __result = + (((__const + unsigned char + *) (__const + char + *) + (arglist[i]. + lng))[3] - + __s2[3]);} + } + __result;} + ))): + (__builtin_constant_p(arg) + ? + (__builtin_constant_p + (arglist[i].lng) + ? : (__extension__( { + char + __result + = + ((__const + unsigned *) + (arg))[0]; + if + (__s2_len + > 0 + && __result == + 0) { + if (__s2_len > + 1 + && __result + == 0) { + } + } + __result;} + ))): + + + + __builtin_strcmp(arglist[i].lng, + arg))));} + )) + return; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr33382.c b/gcc/testsuite/gcc.c-torture/execute/pr33382.c new file mode 100644 index 000000000000..ee539643ae67 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr33382.c @@ -0,0 +1,21 @@ +struct Foo { + int i; + int j[]; +}; + +struct Foo x = { 1, { 2, 0, 2, 3 } }; + +int foo(void) +{ + x.j[0] = 1; + return x.j[1]; +} + +extern void abort(void); + +int main() +{ + if (foo() != 0) + abort(); + return 0; +} diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index b18f6a31326d..d21e0a78bfd9 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -2451,7 +2451,8 @@ get_constraint_for_component_ref (tree t, VEC(ce_s, heap) **results) accessing *only* padding. */ /* Still the user could access one past the end of an array embedded in a struct resulting in accessing *only* padding. */ - gcc_assert (curr || ref_contains_array_ref (orig_t)); + gcc_assert (curr || TREE_CODE (TREE_TYPE (orig_t)) == ARRAY_TYPE + || ref_contains_array_ref (orig_t)); } else if (bitmaxsize == 0) { -- 2.47.2