This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa] Fix a testcase like 20040411-1.c


I had forgot that structs could contain VLA (a stupid extension to even C99).
The easy fix is to remove the check for ARRAY_TYPE just in case there is another
type which I missed.


OK? Bootstrapped on powerpc-apple-darwin with no regressions.

Thanks,
Andrew Pinski


Testcase: int sub1 (int i, int j) { typedef struct { int c[i+2]; }c; int x[10], y[10];

  if (j == 2)
    {
      memcpy (x, y, 10 * sizeof (int));
      return sizeof (c);
    }
  else
    return sizeof (c) * 3;
}

int
main ()
{
  typedef struct
  {
   int  c[22];
  }c;
  if (sub1 (20, 3) != sizeof (c)*3)
    abort ();

  return 0;
}


ChangeLog:


	* c-simplify.c (gimplify_decl_stmt) [TYPE_DECL]:
	Do not check the type.

Patch:

Index: c-simplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/c-simplify.c,v
retrieving revision 1.1.4.97
diff -u -p -r1.1.4.97 c-simplify.c
--- c-simplify.c 15 Apr 2004 19:55:13 -0000 1.1.4.97
+++ c-simplify.c 23 Apr 2004 00:50:21 -0000
@@ -852,7 +852,7 @@ gimplify_decl_stmt (tree *stmt_p)
if (TREE_CODE (decl) == TYPE_DECL)
{
tree type = TREE_TYPE (decl);
- if (TREE_CODE (type) == ARRAY_TYPE
+ if (TYPE_SIZE_UNIT (type)
&& !TREE_CONSTANT (TYPE_SIZE_UNIT (type)))
{
/* This is a variable-sized array type. Simplify its size. */



Attachment: temp.diff.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]