PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of source
[official-gcc.git] / gcc / testsuite / gcc.dg / pr84670-3.c
blobb60a94a837e49492e105e4aee3af14d4c05d8ffe
1 /* { dg-do compile } */
2 /* { dg-options "-Os -fno-strict-overflow" } */
4 typedef unsigned char u8;
5 typedef unsigned short u16;
6 typedef unsigned int u32;
7 typedef u16 acpi_rs_length;
8 typedef u32 acpi_rsdesc_size;
9 struct acpi_resource_source
11 u16 string_length;
12 char *string_ptr;
14 static u16
15 acpi_rs_strcpy (char *destination, char *source)
17 u16 i;
18 for (i = 0; source[i]; i++)
21 return ((u16) (i + 1));
23 union aml_resource;
24 acpi_rs_length
25 acpi_rs_get_resource_source (acpi_rs_length resource_length,
26 acpi_rs_length minimum_length,
27 struct acpi_resource_source * resource_source,
28 union aml_resource * aml, char *string_ptr)
30 acpi_rsdesc_size total_length;
31 u8 *aml_resource_source;
32 if (total_length > (acpi_rsdesc_size) (minimum_length + 1))
34 resource_source->string_length =
35 acpi_rs_strcpy (resource_source->string_ptr,
36 ((char *) (void *) (&aml_resource_source[1])));