From edeea36425037a03cb28ff88309f75a630972138 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 20 Dec 2007 16:09:54 +0000 Subject: svn merge -r130787:131101 svn+ssh://gcc.gnu.org/svn/gcc/trunk/ git-svn-id: https://gcc.gnu.org/svn/gcc/branches/redhat/gcc-4_3-branch@131103 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/gcc.c-torture/compile/20071214-1.c | 15 ++ gcc/testsuite/gcc.c-torture/compile/pr34091.c | 175 +++++++++++++++++++++++ gcc/testsuite/gcc.c-torture/execute/20071216-1.c | 38 +++++ gcc/testsuite/gcc.c-torture/execute/20071219-1.c | 71 +++++++++ gcc/testsuite/gcc.c-torture/execute/pr34415.c | 34 +++++ gcc/testsuite/gcc.c-torture/execute/pr34456.c | 30 ++++ 6 files changed, 363 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/20071214-1.c create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr34091.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/20071216-1.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/20071219-1.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr34415.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr34456.c (limited to 'gcc/testsuite/gcc.c-torture') diff --git a/gcc/testsuite/gcc.c-torture/compile/20071214-1.c b/gcc/testsuite/gcc.c-torture/compile/20071214-1.c new file mode 100644 index 00000000000..f30af930630 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20071214-1.c @@ -0,0 +1,15 @@ +typedef __builtin_va_list va_list; +void gftp_config_parse_args (int numargs, char **first, ...) +{ + char **dest = first; + va_list argp; + __builtin_va_start (argp, first); + while (numargs-- > 0) + { + *dest = __builtin_malloc (1); + dest = __builtin_va_arg(argp, char **); + *dest = ((void *)0); + } + __builtin_va_end(argp); +} + diff --git a/gcc/testsuite/gcc.c-torture/compile/pr34091.c b/gcc/testsuite/gcc.c-torture/compile/pr34091.c new file mode 100644 index 00000000000..0b8549132e6 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr34091.c @@ -0,0 +1,175 @@ +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef int GLint; +typedef unsigned short GLushort; +typedef unsigned int GLuint; +typedef float GLfloat; +typedef GLushort GLchan; +struct gl_texture_image; +typedef struct __GLcontextRec GLcontext; +typedef void (*FetchTexelFuncC) (const struct gl_texture_image * texImage, + GLint col, GLint row, GLint img, + GLchan * texelOut); +struct gl_texture_format +{ +}; +struct gl_texture_image +{ + GLenum _BaseFormat; + GLboolean _IsPowerOfTwo; + FetchTexelFuncC FetchTexelc; +}; +struct gl_texture_object +{ + GLenum Target; + GLenum WrapS; + GLenum MinFilter; + GLenum MagFilter; + GLint BaseLevel; + GLint _MaxLevel; + struct gl_texture_image *Image[6][12]; +}; +enum _format +{ + MESA_FORMAT_RGBA_DXT3, MESA_FORMAT_RGBA_DXT5, MESA_FORMAT_RGBA, + MESA_FORMAT_RGB, MESA_FORMAT_ALPHA, MESA_FORMAT_LUMINANCE, +}; +typedef void (*texture_sample_func) (GLcontext * ctx, + const struct gl_texture_object * tObj, + GLuint n, const GLfloat texcoords[][4], + const GLfloat lambda[], + GLchan rgba[][4]); +lerp_2d (GLfloat a, GLfloat b, GLfloat v00, GLfloat v10, GLfloat v01, + GLfloat v11) +{ + const GLfloat temp0 = ((v00) + (a) * ((v10) - (v00))); + const GLfloat temp1 = ((v01) + (a) * ((v11) - (v01))); + return ((temp0) + (b) * ((temp1) - (temp0))); +} +static __inline__ void +lerp_rgba (GLchan result[4], GLfloat t, const GLchan a[4], const GLchan b[4]) +{ + result[0] = (GLchan) (((a[0]) + (t) * ((b[0]) - (a[0]))) + 0.5); + result[1] = (GLchan) (((a[1]) + (t) * ((b[1]) - (a[1]))) + 0.5); + result[2] = (GLchan) (((a[2]) + (t) * ((b[2]) - (a[2]))) + 0.5); +} +static __inline__ void +lerp_rgba_2d (GLchan result[4], GLfloat a, GLfloat b, const GLchan t00[4], + const GLchan t10[4], const GLchan t01[4], const GLchan t11[4]) +{ + result[0] = (GLchan) (lerp_2d (a, b, t00[0], t10[0], t01[0], t11[0]) + 0.5); + result[1] = (GLchan) (lerp_2d (a, b, t00[1], t10[1], t01[1], t11[1]) + 0.5); + result[2] = (GLchan) (lerp_2d (a, b, t00[2], t10[2], t01[2], t11[2]) + 0.5); +} +static __inline__ void +sample_2d_linear_repeat (GLcontext * ctx, + const struct gl_texture_object *tObj, + const struct gl_texture_image *img, + const GLfloat texcoord[4], GLchan rgba[]) +{ + GLint i0, j0, i1, j1; + GLfloat a, b; + GLchan t00[4], t10[4], t01[4], t11[4]; + { + }; + img->FetchTexelc (img, i1, j1, 0, t11); + lerp_rgba_2d (rgba, a, b, t00, t10, t01, t11); +} +sample_2d_nearest_mipmap_linear (GLcontext * ctx, + const struct gl_texture_object *tObj, + GLuint n, const GLfloat texcoord[][4], + const GLfloat lambda[], GLchan rgba[][4]) +{ + GLuint i; + GLint level = linear_mipmap_level (tObj, lambda[i]); + sample_2d_nearest (ctx, tObj, tObj->Image[0][tObj->_MaxLevel], texcoord[i], rgba[i]); + GLchan t0[4], t1[4]; + sample_2d_nearest (ctx, tObj, tObj->Image[0][level], texcoord[i], t0); + sample_2d_nearest (ctx, tObj, tObj->Image[0][level + 1], texcoord[i], t1); +} +static void +sample_2d_linear_mipmap_linear_repeat (GLcontext * ctx, + const struct gl_texture_object *tObj, + GLuint n, const GLfloat texcoord[][4], + const GLfloat lambda[], + GLchan rgba[][4]) +{ + GLuint i; + for (i = 0; i < n; i++) + { + GLint level = linear_mipmap_level (tObj, lambda[i]); + if (level >= tObj->_MaxLevel) + { + GLchan t0[4], t1[4]; + const GLfloat f = ((lambda[i]) - ifloor (lambda[i])); + sample_2d_linear_repeat (ctx, tObj, tObj->Image[0][level], + texcoord[i], t0); + sample_2d_linear_repeat (ctx, tObj, tObj->Image[0][level + 1], + texcoord[i], t1); + lerp_rgba (rgba[i], f, t0, t1); + } + } +} +static void +sample_lambda_2d (GLcontext * ctx, const struct gl_texture_object *tObj, + GLuint n, const GLfloat texcoords[][4], + const GLfloat lambda[], GLchan rgba[][4]) +{ + const struct gl_texture_image *tImg = tObj->Image[0][tObj->BaseLevel]; + GLuint minStart, minEnd; + GLuint magStart, magEnd; + const GLboolean repeatNoBorderPOT = (tObj->WrapS == 0x2901) + && (tImg->_BaseFormat != 0x1900) && tImg->_IsPowerOfTwo; + compute_min_mag_ranges (tObj, n, lambda, &minStart, &minEnd, &magStart, + &magEnd); + if (minStart < minEnd) + { + const GLuint m = minEnd - minStart; + switch (tObj->MinFilter) + { + case 0x2600: + if (repeatNoBorderPOT) + { + case MESA_FORMAT_RGB: + opt_sample_rgb_2d (ctx, tObj, m, texcoords + minStart, + ((void *) 0), rgba + minStart); + case MESA_FORMAT_RGBA: + opt_sample_rgba_2d (ctx, tObj, m, texcoords + minStart, + ((void *) 0), rgba + minStart); + } + { + sample_nearest_2d (ctx, tObj, m, texcoords + minStart, + ((void *) 0), rgba + minStart); + } + break; + sample_2d_nearest_mipmap_linear (ctx, tObj, m, texcoords + minStart, + lambda + minStart, + rgba + minStart); + case 0x2703: + if (repeatNoBorderPOT) + sample_2d_linear_mipmap_linear_repeat (ctx, tObj, m, + texcoords + minStart, + lambda + minStart, + rgba + minStart); + } + switch (tObj->MagFilter) + { + case MESA_FORMAT_RGB: + opt_sample_rgb_2d (ctx, tObj, m, texcoords + magStart, + ((void *) 0), rgba + magStart); + opt_sample_rgba_2d (ctx, tObj, m, texcoords + magStart, + ((void *) 0), rgba + magStart); + sample_nearest_2d (ctx, tObj, m, texcoords + magStart, + ((void *) 0), rgba + magStart); + } + } +} +texture_sample_func +_swrast_choose_texture_sample_func (const struct gl_texture_object *t) +{ + switch (t->Target) + { + case 0x0DE0: + return &sample_lambda_2d; + } +} diff --git a/gcc/testsuite/gcc.c-torture/execute/20071216-1.c b/gcc/testsuite/gcc.c-torture/execute/20071216-1.c new file mode 100644 index 00000000000..a337b773af8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20071216-1.c @@ -0,0 +1,38 @@ +/* PR rtl-optimization/34490 */ + +extern void abort (void); + +static int x; + +int +__attribute__((noinline)) +bar (void) +{ + return x; +} + +int +foo (void) +{ + long int b = bar (); + if ((unsigned long) b < -4095L) + return b; + if (-b != 38) + b = -2; + return b + 1; +} + +int +main (void) +{ + x = 26; + if (foo () != 26) + abort (); + x = -39; + if (foo () != -1) + abort (); + x = -38; + if (foo () != -37) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/20071219-1.c b/gcc/testsuite/gcc.c-torture/execute/20071219-1.c new file mode 100644 index 00000000000..4152711a304 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20071219-1.c @@ -0,0 +1,71 @@ +/* PR c++/34459 */ + +extern void abort (void); +extern void *memset (void *s, int c, __SIZE_TYPE__ n); + +struct S +{ + char s[25]; +}; + +struct S *p; + +void __attribute__((noinline)) +foo (struct S *x, int set) +{ + int i; + for (i = 0; i < sizeof (x->s); ++i) + if (x->s[i] != 0) + abort (); + else if (set) + x->s[i] = set; + p = x; +} + +void __attribute__((noinline)) +test1 (void) +{ + struct S a; + memset (&a.s, '\0', sizeof (a.s)); + foo (&a, 0); + struct S b = a; + foo (&b, 1); + b = a; + b = b; + foo (&b, 0); +} + +void __attribute__((noinline)) +test2 (void) +{ + struct S a; + memset (&a.s, '\0', sizeof (a.s)); + foo (&a, 0); + struct S b = a; + foo (&b, 1); + b = a; + b = *p; + foo (&b, 0); +} + +void __attribute__((noinline)) +test3 (void) +{ + struct S a; + memset (&a.s, '\0', sizeof (a.s)); + foo (&a, 0); + struct S b = a; + foo (&b, 1); + *p = a; + *p = b; + foo (&b, 0); +} + +int +main (void) +{ + test1 (); + test2 (); + test3 (); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr34415.c b/gcc/testsuite/gcc.c-torture/execute/pr34415.c new file mode 100644 index 00000000000..ec75394afe0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr34415.c @@ -0,0 +1,34 @@ +const char *__attribute__((noinline)) +foo (const char *p) +{ + const char *end; + int len = 1; + for (;;) + { + int c = *p; + c = (c >= 'a' && c <= 'z' ? c - 'a' + 'A' : c); + if (c == 'B') + end = p; + else if (c == 'A') + { + end = p; + do + p++; + while (*p == '+'); + } + else + break; + p++; + len++; + } + if (len > 2 && *p == ':') + p = end; + return p; +} + +int +main (void) +{ + const char *input = "Bbb:"; + return foo (input) != input + 2; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr34456.c b/gcc/testsuite/gcc.c-torture/execute/pr34456.c new file mode 100644 index 00000000000..526c954e55a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr34456.c @@ -0,0 +1,30 @@ +#include + +int __attribute__ ((noinline)) debug (void) { return 1; } +int errors; + +struct s { int elt; int (*compare) (int); }; + +static int +compare (const void *x, const void *y) +{ + const struct s *s1 = x, *s2 = y; + int (*compare1) (int); + int elt2; + + compare1 = s1->compare; + elt2 = s2->elt; + if (elt2 != 0 && debug () && compare1 (s1->elt) != 0) + errors++; + return compare1 (elt2); +} + +int bad_compare (int x) { return -x; } +struct s array[2] = { { 1, bad_compare }, { -1, bad_compare } }; + +int +main (void) +{ + qsort (array, 2, sizeof (struct s), compare); + return errors == 0; +} -- cgit v1.2.3