PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of source
[official-gcc.git] / gcc / testsuite / gcc.dg / pr63762.c
blobdf110676eca6eb7418a9a24ec0a6ad72c8f8d88e
1 /* PR middle-end/63762 */
2 /* { dg-do assemble } */
3 /* { dg-options "-O2" } */
5 #include <stdlib.h>
7 void *astFree ();
8 void *astMalloc ();
9 void astNegate (void *);
10 int astGetNegated (void *);
11 void astGetRegionBounds (void *, double *, double *);
12 int astResampleF (void *, ...);
14 extern int astOK;
16 int
17 MaskF (int inside, int ndim, const int lbnd[], const int ubnd[],
18 float in[], float val)
21 void *used_region;
22 float *c, *d, *out, *tmp_out;
23 double *lbndgd, *ubndgd;
24 int *lbndg, *ubndg, idim, ipix, nax, nin, nout, npix, npixg, result = 0;
25 if (!astOK) return result;
26 lbndg = astMalloc (sizeof (int)*(size_t) ndim);
27 ubndg = astMalloc (sizeof (int)*(size_t) ndim);
28 lbndgd = astMalloc (sizeof (double)*(size_t) ndim);
29 ubndgd = astMalloc (sizeof (double)*(size_t) ndim);
30 if (astOK)
32 astGetRegionBounds (used_region, lbndgd, ubndgd);
33 npix = 1;
34 npixg = 1;
35 for (idim = 0; idim < ndim; idim++)
37 lbndg[ idim ] = lbnd[ idim ];
38 ubndg[ idim ] = ubnd[ idim ];
39 npix *= (ubnd[ idim ] - lbnd[ idim ] + 1);
40 if (npixg >= 0) npixg *= (ubndg[ idim ] - lbndg[ idim ] + 1);
42 if (npixg <= 0 && astOK)
44 if ((inside != 0) == (astGetNegated( used_region ) != 0))
46 c = in;
47 for (ipix = 0; ipix < npix; ipix++) *(c++) = val;
48 result = npix;
51 else if (npixg > 0 && astOK)
53 if ((inside != 0) == (astGetNegated (used_region) != 0))
55 tmp_out = astMalloc (sizeof (float)*(size_t) npix);
56 if (tmp_out)
58 c = tmp_out;
59 for (ipix = 0; ipix < npix; ipix++) *(c++) = val;
60 result = npix - npixg;
62 out = tmp_out;
64 else
66 tmp_out = NULL;
67 out = in;
69 if (inside) astNegate (used_region);
70 result += astResampleF (used_region, ndim, lbnd, ubnd, in, NULL,
71 NULL, NULL, 0, 0.0, 100, val, ndim,
72 lbnd, ubnd, lbndg, ubndg, out, NULL);
73 if (inside) astNegate (used_region);
76 return result;