1 /* Verify that an anti-range ~[A, B] with small positive A and B
2 is handled correctly and doesn't trigger warnings.
4 { dg-options "-O2 -Wall" }
5 { dg-require-effective-target alloca } */
7 typedef __typeof__ (sizeof 0) size_t;
12 // Test case distilled from gcc/cp/semantics.c
14 int omp_reduction_id (int i
, int j
, const char *mm
)
34 const char prefix
[] = "omp declare reduction ";
35 size_t lenp
= sizeof (prefix
);
37 if (__builtin_strncmp (p
, prefix
, lenp
- 1) == 0)
40 size_t len
= __builtin_strlen (p
);
41 size_t lenm
= m
? __builtin_strlen (m
) + 1 : 0;
42 char *name
= ((char *) __builtin_alloca(lenp
+ len
+ lenm
));
45 __builtin_memcpy (name
, prefix
, lenp
- 1);
47 __builtin_memcpy (name
+ lenp
- 1, p
, len
+ 1);
50 name
[lenp
+ len
- 1] = '~';
51 __builtin_memcpy (name
+ lenp
+ len
, m
, lenm
);
53 return (__builtin_constant_p (name
)
54 ? f (name
, __builtin_strlen (name
)) : g (name
));
57 // Test case derived from gcc/d/dmd/root/filename.c.
59 const char *ext (const char *str
)
61 size_t len
= __builtin_strlen(str
);
63 const char *e
= str
+ len
;
68 case '.': return e
+ 1;
80 const char *removeExt (const char *str
)
82 const char *e
= ext (str
);
85 size_t len
= (e
- str
) - 1;
86 char *n
= (char *)__builtin_malloc (len
+ 1);
87 __builtin_memcpy(n
, str
, len
);