aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2009-03-29 14:11:58 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2009-03-29 14:11:58 +0000
commit3379ae7f3b65e899f9b7812e27a43625c6b497f7 (patch)
treefc54e8ca0216db0859777fe6558b4f473ca6ae59
parenta8da523f8a442f95c34dd3687771589579a08918 (diff)
downloadgcc-3379ae7f3b65e899f9b7812e27a43625c6b497f7.zip
gcc-3379ae7f3b65e899f9b7812e27a43625c6b497f7.tar.gz
gcc-3379ae7f3b65e899f9b7812e27a43625c6b497f7.tar.bz2
20090113-1.c: New testcase.
2009-03-29 Richard Guenther <rguenther@suse.de> * gcc.c-torture/execute/20090113-1.c: New testcase. * gcc.c-torture/execute/20090113-2.c: Likewise. * gcc.c-torture/execute/20090113-3.c: Likewise. * gcc.c-torture/execute/20090207-1.c: Likewise. * gcc.c-torture/compile/20090114-1.c: Likewise. * gcc.c-torture/compile/20090328-1.c: Likewise. * gcc.dg/noncompile/920507-1.c: Fix out-of-bounds array access. From-SVN: r145234
-rw-r--r--gcc/testsuite/ChangeLog10
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/20090114-1.c44
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/20090328-1.c17
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20090113-1.c61
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20090113-2.c160
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20090113-3.c138
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20090207-1.c16
-rw-r--r--gcc/testsuite/gcc.dg/noncompile/920507-1.c2
8 files changed, 447 insertions, 1 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 16415c6..2f60726 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2009-03-29 Richard Guenther <rguenther@suse.de>
+
+ * gcc.c-torture/execute/20090113-1.c: New testcase.
+ * gcc.c-torture/execute/20090113-2.c: Likewise.
+ * gcc.c-torture/execute/20090113-3.c: Likewise.
+ * gcc.c-torture/execute/20090207-1.c: Likewise.
+ * gcc.c-torture/compile/20090114-1.c: Likewise.
+ * gcc.c-torture/compile/20090328-1.c: Likewise.
+ * gcc.dg/noncompile/920507-1.c: Fix out-of-bounds array access.
+
2009-03-29 David Ayers <ayers@fsfe.org>
PR objc/27377
diff --git a/gcc/testsuite/gcc.c-torture/compile/20090114-1.c b/gcc/testsuite/gcc.c-torture/compile/20090114-1.c
new file mode 100644
index 0000000..692c96f
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/20090114-1.c
@@ -0,0 +1,44 @@
+typedef struct {
+ int MbInterlace;
+ int channel_type;
+} InputParameters;
+typedef struct {
+ int type;
+ int NumberofCodedPFrame;
+ int NumberofGOP;
+ int NumberofPPicture;
+ int FieldControl;
+ int Frame_Total_Number_MB;
+ int NumberofCodedMacroBlocks;
+ int BasicUnit;
+} ImageParameters;
+extern InputParameters *input;
+extern ImageParameters *img;
+long T;
+void rc_init_pict(int fieldpic)
+{
+ if(input->MbInterlace)
+ T = img->Frame_Total_Number_MB;
+ img->NumberofCodedMacroBlocks=0;
+ if(input->channel_type==1
+ && img->NumberofCodedPFrame==58)
+ T = 4;
+ if(fieldpic)
+ {
+ switch (img->type)
+ {
+ case 0:
+ if(img->NumberofCodedPFrame>0
+ && img->FieldControl==1)
+ T = 3;
+ if(img->NumberofPPicture==1)
+ T = 2;
+ }
+ if(img->type==0
+ && img->NumberofCodedPFrame>0)
+ T = 0;
+ }
+ if(img->type==0
+ && img->FieldControl==1)
+ T = 1;
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/20090328-1.c b/gcc/testsuite/gcc.c-torture/compile/20090328-1.c
new file mode 100644
index 0000000..10328ad
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/20090328-1.c
@@ -0,0 +1,17 @@
+union loc { unsigned reg; signed offset; };
+void __frame_state_for (volatile char *state_in, int x)
+{
+ /* We should move all the loads out of this loop. Right now, we only
+ move one. It takes two insertions because we insert a cast. */
+ union loc fs;
+ int reg;
+ for (;;) {
+ switch (x) {
+ case 0:
+ *state_in = fs.reg;
+ case 1:
+ *state_in = fs.offset;
+ }
+ }
+}
+
diff --git a/gcc/testsuite/gcc.c-torture/execute/20090113-1.c b/gcc/testsuite/gcc.c-torture/execute/20090113-1.c
new file mode 100644
index 0000000..9c5f01d
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20090113-1.c
@@ -0,0 +1,61 @@
+typedef struct descriptor_dimension
+{
+ int stride;
+ int lbound;
+ int ubound;
+} descriptor_dimension;
+typedef struct {
+ int *data;
+ int dtype;
+ descriptor_dimension dim[7];
+} gfc_array_i4;
+
+void
+msum_i4 (gfc_array_i4 * const retarray,
+ gfc_array_i4 * const array,
+ const int * const pdim)
+{
+ int count[7];
+ int extent[7];
+ int * dest;
+ const int * base;
+ int dim;
+ int n;
+ int len;
+
+ dim = (*pdim) - 1;
+ len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
+
+ for (n = 0; n < dim; n++)
+ {
+ extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;
+ count[n] = 0;
+ }
+
+ dest = retarray->data;
+ base = array->data;
+
+ do
+ {
+ int result = 0;
+
+ for (n = 0; n < len; n++, base++)
+ result += *base;
+ *dest = result;
+
+ count[0]++;
+ dest += 1;
+ }
+ while (count[0] != extent[0]);
+}
+
+int main()
+{
+ int rdata[3];
+ int adata[9];
+ gfc_array_i4 retarray = { rdata, 265, { { 1, 1, 3 } } };
+ gfc_array_i4 array = { adata, 266, { { 1, 1, 3 }, { 3, 1, 3 } } };
+ int dim = 2;
+ msum_i4 (&retarray, &array, &dim);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/20090113-2.c b/gcc/testsuite/gcc.c-torture/execute/20090113-2.c
new file mode 100644
index 0000000..9871a66
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20090113-2.c
@@ -0,0 +1,160 @@
+struct obstack {};
+struct bitmap_head_def;
+typedef struct bitmap_head_def *bitmap;
+typedef const struct bitmap_head_def *const_bitmap;
+typedef unsigned long BITMAP_WORD;
+typedef struct bitmap_obstack
+{
+ struct bitmap_element_def *elements;
+ struct bitmap_head_def *heads;
+ struct obstack obstack;
+} bitmap_obstack;
+typedef struct bitmap_element_def
+{
+ struct bitmap_element_def *next;
+ struct bitmap_element_def *prev;
+ unsigned int indx;
+ BITMAP_WORD bits[((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 1u))];
+} bitmap_element;
+
+struct bitmap_descriptor;
+
+typedef struct bitmap_head_def {
+ bitmap_element *first;
+ bitmap_element *current;
+ unsigned int indx;
+ bitmap_obstack *obstack;
+} bitmap_head;
+
+bitmap_element bitmap_zero_bits;
+
+typedef struct
+{
+ bitmap_element *elt1;
+ bitmap_element *elt2;
+ unsigned word_no;
+ BITMAP_WORD bits;
+} bitmap_iterator;
+
+static void __attribute__((noinline))
+bmp_iter_set_init (bitmap_iterator *bi, const_bitmap map,
+ unsigned start_bit, unsigned *bit_no)
+{
+ bi->elt1 = map->first;
+ bi->elt2 = ((void *)0);
+
+ while (1)
+ {
+ if (!bi->elt1)
+ {
+ bi->elt1 = &bitmap_zero_bits;
+ break;
+ }
+
+ if (bi->elt1->indx >= start_bit / (((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 1u)) * (8 * 8 * 1u)))
+ break;
+ bi->elt1 = bi->elt1->next;
+ }
+
+ if (bi->elt1->indx != start_bit / (((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 1u)) * (8 * 8 * 1u)))
+ start_bit = bi->elt1->indx * (((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 1u)) * (8 * 8 * 1u));
+
+ bi->word_no = start_bit / (8 * 8 * 1u) % ((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 1u));
+ bi->bits = bi->elt1->bits[bi->word_no];
+ bi->bits >>= start_bit % (8 * 8 * 1u);
+
+ start_bit += !bi->bits;
+
+ *bit_no = start_bit;
+}
+
+static void __attribute__((noinline))
+bmp_iter_next (bitmap_iterator *bi, unsigned *bit_no)
+{
+ bi->bits >>= 1;
+ *bit_no += 1;
+}
+
+static unsigned char __attribute__((noinline))
+bmp_iter_set_tail (bitmap_iterator *bi, unsigned *bit_no)
+{
+ while (!(bi->bits & 1))
+ {
+ bi->bits >>= 1;
+ *bit_no += 1;
+ }
+ return 1;
+}
+
+static __inline__ unsigned char
+bmp_iter_set (bitmap_iterator *bi, unsigned *bit_no)
+{
+ unsigned bno = *bit_no;
+ BITMAP_WORD bits = bi->bits;
+ bitmap_element *elt1;
+
+ if (bits)
+ {
+ while (!(bits & 1))
+ {
+ bits >>= 1;
+ bno += 1;
+ }
+ *bit_no = bno;
+ return 1;
+ }
+
+ *bit_no = ((bno + 64 - 1) / 64 * 64);
+ bi->word_no++;
+
+ elt1 = bi->elt1;
+ while (1)
+ {
+ while (bi->word_no != 2)
+ {
+ bi->bits = elt1->bits[bi->word_no];
+ if (bi->bits)
+ {
+ bi->elt1 = elt1;
+ return bmp_iter_set_tail (bi, bit_no);
+ }
+ *bit_no += 64;
+ bi->word_no++;
+ }
+
+ elt1 = elt1->next;
+ if (!elt1)
+ {
+ bi->elt1 = elt1;
+ return 0;
+ }
+ *bit_no = elt1->indx * (2 * 64);
+ bi->word_no = 0;
+ }
+}
+
+extern void abort (void);
+
+static void __attribute__((noinline)) catchme(int i)
+{
+ if (i != 0 && i != 64)
+ abort ();
+}
+static void __attribute__((noinline)) foobar (bitmap_head *chain)
+{
+ bitmap_iterator rsi;
+ unsigned int regno;
+ for (bmp_iter_set_init (&(rsi), (chain), (0), &(regno));
+ bmp_iter_set (&(rsi), &(regno));
+ bmp_iter_next (&(rsi), &(regno)))
+ catchme(regno);
+}
+
+int main()
+{
+ bitmap_element elem = { (void *)0, (void *)0, 0, { 1, 1 } };
+ bitmap_head live_throughout = { &elem, &elem, 0, (void *)0 };
+ foobar (&live_throughout);
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.c-torture/execute/20090113-3.c b/gcc/testsuite/gcc.c-torture/execute/20090113-3.c
new file mode 100644
index 0000000..f67bac2
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20090113-3.c
@@ -0,0 +1,138 @@
+struct obstack {};
+struct bitmap_head_def;
+typedef struct bitmap_head_def *bitmap;
+typedef const struct bitmap_head_def *const_bitmap;
+typedef unsigned long BITMAP_WORD;
+
+typedef struct bitmap_obstack
+{
+ struct bitmap_element_def *elements;
+ struct bitmap_head_def *heads;
+ struct obstack obstack;
+} bitmap_obstack;
+typedef struct bitmap_element_def
+{
+ struct bitmap_element_def *next;
+ struct bitmap_element_def *prev;
+ unsigned int indx;
+ BITMAP_WORD bits[(2)];
+} bitmap_element;
+
+struct bitmap_descriptor;
+
+typedef struct bitmap_head_def {
+ bitmap_element *first;
+ bitmap_element *current;
+ unsigned int indx;
+ bitmap_obstack *obstack;
+} bitmap_head;
+
+bitmap_element bitmap_zero_bits;
+
+typedef struct
+{
+ bitmap_element *elt1;
+ bitmap_element *elt2;
+ unsigned word_no;
+ BITMAP_WORD bits;
+} bitmap_iterator;
+
+static __attribute__((noinline)) void
+bmp_iter_set_init (bitmap_iterator *bi, const_bitmap map,
+ unsigned start_bit, unsigned *bit_no)
+{
+ bi->elt1 = map->first;
+ bi->elt2 = ((void *)0);
+
+ while (1)
+ {
+ if (!bi->elt1)
+ {
+ bi->elt1 = &bitmap_zero_bits;
+ break;
+ }
+
+ if (bi->elt1->indx >= start_bit / (128u))
+ break;
+ bi->elt1 = bi->elt1->next;
+ }
+
+ if (bi->elt1->indx != start_bit / (128u))
+ start_bit = bi->elt1->indx * (128u);
+
+ bi->word_no = start_bit / 64u % (2);
+ bi->bits = bi->elt1->bits[bi->word_no];
+ bi->bits >>= start_bit % 64u;
+
+ start_bit += !bi->bits;
+
+ *bit_no = start_bit;
+}
+
+static __inline__ __attribute__((always_inline)) void
+bmp_iter_next (bitmap_iterator *bi, unsigned *bit_no)
+{
+ bi->bits >>= 1;
+ *bit_no += 1;
+}
+
+static __inline__ __attribute__((always_inline)) unsigned char
+bmp_iter_set (bitmap_iterator *bi, unsigned *bit_no)
+{
+ if (bi->bits)
+ {
+ while (!(bi->bits & 1))
+ {
+ bi->bits >>= 1;
+ *bit_no += 1;
+ }
+ return 1;
+ }
+
+ *bit_no = ((*bit_no + 64u - 1) / 64u * 64u);
+ bi->word_no++;
+
+ while (1)
+ {
+ while (bi->word_no != (2))
+ {
+ bi->bits = bi->elt1->bits[bi->word_no];
+ if (bi->bits)
+ {
+ while (!(bi->bits & 1))
+ {
+ bi->bits >>= 1;
+ *bit_no += 1;
+ }
+ return 1;
+ }
+ *bit_no += 64u;
+ bi->word_no++;
+ }
+
+ bi->elt1 = bi->elt1->next;
+ if (!bi->elt1)
+ return 0;
+ *bit_no = bi->elt1->indx * (128u);
+ bi->word_no = 0;
+ }
+}
+
+static void __attribute__((noinline))
+foobar (bitmap_head *live_throughout)
+{
+ bitmap_iterator rsi;
+ unsigned int regno;
+ for (bmp_iter_set_init (&(rsi), (live_throughout), (0), &(regno));
+ bmp_iter_set (&(rsi), &(regno));
+ bmp_iter_next (&(rsi), &(regno)))
+ ;
+}
+int main()
+{
+ bitmap_element elem = { (void *)0, (void *)0, 0, { 1, 1 } };
+ bitmap_head live_throughout = { &elem, &elem, 0, (void *)0 };
+ foobar (&live_throughout);
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.c-torture/execute/20090207-1.c b/gcc/testsuite/gcc.c-torture/execute/20090207-1.c
new file mode 100644
index 0000000..51a6860
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20090207-1.c
@@ -0,0 +1,16 @@
+int foo(int i)
+{
+ int a[32];
+ a[1] = 3;
+ a[0] = 1;
+ a[i] = 2;
+ return a[0];
+}
+extern void abort (void);
+int main()
+{
+ if (foo (0) != 2
+ || foo (1) != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/noncompile/920507-1.c b/gcc/testsuite/gcc.dg/noncompile/920507-1.c
index c1a3523..7024a5b 100644
--- a/gcc/testsuite/gcc.dg/noncompile/920507-1.c
+++ b/gcc/testsuite/gcc.dg/noncompile/920507-1.c
@@ -3,5 +3,5 @@ x(void)
{
register int *a asm("unknown_register"); /* { dg-error "invalid register" } */
int *v[1] = {a};
- return v[1];
+ return v[0];
}