1/* { dg-do run } */
2/* { dg-options "-fsanitize=bool,enum" } */
3
4#ifndef __cplusplus
5#define bool _Bool
6#endif
7enum A { B = -3, C = 2 } a;
8bool b;
9
10__attribute__((noinline, noclone)) enum A
11foo (bool *p)
12{
13  *p = b;   /* { dg-output "load-bool-enum.c:13:\[^\n\r]*runtime error: \[^\n\r]*load of value 4, which is not a valid value for type '(_B|b)ool'\[^\n\r]*(\n|\r\n|\r)*" } */
14  return a; /* { dg-output "\[^\n\r]*load-bool-enum.c:14:\[^\n\r]*runtime error: \[^\n\r]*load of value 9, which is not a valid value for type 'A'\[^\n\r]*(\n|\r\n|\r)*" { target c++ } } */
15}
16
17int
18main ()
19{
20  char c = 4;
21  int d = 9;
22  if (sizeof (int) != sizeof (a) || sizeof (b) != 1)
23    return 0;
24  __builtin_memcpy (&a, &d, sizeof (int));
25  __builtin_memcpy (&b, &c, 1);
26  bool e;
27  foo (&e);
28  return 0;
29}
30