Exemplo n.º 1
0
void
check_foo (void)
{
  if (foo_ptr != foo)
    __builtin_abort ();
  if (foo_ptr() != 1)
    __builtin_abort ();
  if (foo() != 1)
    __builtin_abort ();
}
Exemplo n.º 2
0
void
check_bar (void)
{
  func_p bar_ptr = get_bar ();
  if (bar_ptr != bar)
    __builtin_abort ();
  if (bar_ptr() != -1)
    __builtin_abort ();
  if (bar() != -1)
    __builtin_abort ();
}
Exemplo n.º 3
0
int
main (void)
{
  long i;
  for (i = 0; i < 65536; i++)
    if (foo ("abcdefghijkl", 12) != buf)
      __builtin_abort ();
  if (foo (buf2, 64) != buf)
    __builtin_abort ();
  return 0;
}
Exemplo n.º 4
0
int
main ()
{
  A a = { 0 };
  O<int> o;
  if (o.foo (a) != 123)
    __builtin_abort ();
  signed char d = 2;
  if ((b << d) != 123)
    __builtin_abort ();
}
Exemplo n.º 5
0
int
main ()
{
#if __cplusplus > 201703L
  if (!seen)
    __builtin_abort ();
#else
  if (seen)
    __builtin_abort ();
#endif
}
Exemplo n.º 6
0
int
main (void)
{
    if (__builtin_fma (d_a, d_b, d_c) != (2.0 * 3.0) + 4.0)
        __builtin_abort ();

    if (__builtin_fmaf (f_a, f_b, f_c) != (2.0f * 3.0f) + 4.0f)
        __builtin_abort ();

    return 0;
}
Exemplo n.º 7
0
int main(void)
{
  st a;
  next = &a;
  f();
  if (next->iIndex != 0xFFFE)
    __builtin_abort ();
  if (next->iIndex1 != 0xFFFE)
    __builtin_abort ();
  return 0;
}
int
main ()
{
  if (bar (42) != 44)
    __builtin_abort ();

  if (foo (42) != 45)
    __builtin_abort ();

  return 0;
}
Exemplo n.º 9
0
int main ()
{
  if (test (10, 20, 30) != 20)
    __builtin_abort ();
  if (test (12, 20, 30) != 20)
    __builtin_abort ();
  if (test (26, 20, 30) != 20)
    __builtin_abort ();
  if (test (30, 20, 30) != 30)
    __builtin_abort ();
  return 0;
}
Exemplo n.º 10
0
int
main ()
{
  int cnt = 0;
  for (const auto &m : { &A::f, &A::g, &A::h })
    {
      A a;
      if ((a.*m) () != ++cnt)
	__builtin_abort ();
    }
  if (cnt != 3)
    __builtin_abort ();
}
Exemplo n.º 11
0
int
check_mem (char *mem, int val, int len)
{
  int i;

  if (mem[0] != 0x71)
    __builtin_abort();
  for (i = 1; i <= len; i++)
    if (mem[i] != val)
      __builtin_abort();
  if (mem[len + 1] != 0x71 + (len + 1) % 4)
    __builtin_abort();
}
Exemplo n.º 12
0
__attribute__((noinline, noclone)) void
bar (double p[][4])
{
  int i;
  double d = 172.0;
  for (i = 0; i < 4096; i++)
    {
      if (p[i][0] != 6.0 || p[i][1] != 6.0 || p[i][2] != 10.0)
	__builtin_abort ();
      if (__builtin_fabs (p[i][3] - d) > 0.25)
	__builtin_abort ();
    }
}
Exemplo n.º 13
0
int
main ()
{
  C c;
  if (foo (static_cast<B *> (&c)) != &c)
    __builtin_abort ();
  if (foo (0))
    __builtin_abort ();
  if (bar (static_cast<B *> (&c)) != &c)
    __builtin_abort ();
  baz (0);
  return 0;
}
Exemplo n.º 14
0
int main()
{
  V v1 = {0,1};
  V v2 = {0,2};

  if (foo(&a,0,&v1) != 0)
    __builtin_abort();
  if (foo(&a,0,&v2) != 1)
    __builtin_abort();
  if (foo(&a,1,&v1) != 0)
    __builtin_abort();
  return 0;
}
Exemplo n.º 15
0
static void
avx512f_test (void)
{
  if (_mm512_cvtss_f32 (_mm512_set_ps (13.0f, 24.5f, 23.0f, 22.5f,
				       2.0f, 3.0f, 4.0f, 5.0f,
				       6.0f, 7.0f, 8.0f, 9.0f,
				       10.0f, 11.0f, 12.0f, 13.5f)) != 13.5f)
    __builtin_abort ();

  if (foo (_mm512_set_ps (13.25f, 24.25f, 23.75f, 22.0f,
			  2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f,
			  10.0f, 11.0f, 12.0f, 12.25f)) != 12.25f)
    __builtin_abort ();
}
Exemplo n.º 16
0
int main()
{
  int ar[1] = { 42 };
  A* ap = new(ar) A;

  // When the constructor starts the object has indeterminate value.
  if (ap->i == 42) __builtin_abort();

  ap->i = 42;
  ap->~A();

  // When the destructor ends the object no longer exists.
  if (ar[0] == 42) __builtin_abort();
}
Exemplo n.º 17
0
void
test (void)
{
  vector int l;
  int i;
  for (i = 0; i < 4; i++)
    u.c[i] = i;
  l = u.k;
  if (foo (64, l))
    __builtin_abort ();
  l += u.k;
  if (foo (64, l))
    __builtin_abort ();
}
Exemplo n.º 18
0
int
main ()
{
  fputs ("UBSAN TEST START\n", stderr);

  y = 1;
  if (foo (8 - 2040) != 8 - 1)
    __builtin_abort ();
  if (bar (1) != 8 - 1)
    __builtin_abort ();

  fputs ("UBSAN TEST END\n", stderr);
  return 0;
}
Exemplo n.º 19
0
int
main ()
{
  A<int> a[4][3][2];
  static int a2[4][3][2] = {{{ 0, 0 }, { 0, 0 }, { 0, 0 }},
			    {{ 312, 381 }, { 295, 356 }, { 337, 335 }},
			    {{ 1041, 975 }, { 1016, 1085 }, { 935, 1060 }},
			    {{ 0, 0 }, { 0, 0 }, { 0, 0 }}};
  A<int> (*p)[3][2] = &a[1];
  M<int> y[5] = { 0, 1, 1, 1, 0 };
  int y2[5] = { 0, 6561, 2401, 289, 0 };
  char z2[10] = { 48, 49, 50, 51, 0, 0, 0, 0, 0, 0 };
  B<long> w[1][2];
  foo (p, y + 1, w, 1, 3L, 4L, 3, 4, 2L, 5);
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 2; k++)
	if (a[i][j][k].t != a2[i][j][k])
	  __builtin_abort ();
  for (int i = 0; i < 5; i++)
    if (y[i].t != y2[i])
      __builtin_abort ();
  for (int i = 0; i < 10; i++)
    if (z[i].t != z2[i])
      __builtin_abort ();
  if (w[0][0].t != ~0x249249L || w[0][1].t != ~0x249249L)
    __builtin_abort ();
  S s;
  s.foo (1, 3L, 4L, 3, 4, 2L, 5);
  for (int i = 0; i < 9; i++)
    if (s.a[i].t != (i < 4 ? 0x55555555ULL : 0))
      __builtin_abort ();
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 2; k++)
	if (a3[i][j][k].t != a2[i][j][k])
	  __builtin_abort ();
  for (int i = 0; i < 5; i++)
    if (y3[i].t != y2[i])
      __builtin_abort ();
  for (int i = 0; i < 10; i++)
    if (s.z[i].t != z2[i])
      __builtin_abort ();
  if (w3[0][0].t != ~0x249249L || w3[0][1].t != ~0x249249L)
    __builtin_abort ();
  if (s.b[0] != 78 || s.b[1] != 12 || s.b[2] != 22
      || s.b[3] != 84 || s.b[4] != 127)
    __builtin_abort ();
}
Exemplo n.º 20
0
int
main (void)
{
  a = ONE;
  b = 1;
  if (fn1 () != ONE)
    __builtin_abort ();

  a = TWO;
  b = 0;
  if (fn1 () != 0)
    __builtin_abort ();

  return 0;
}
main ()
{
  int res;

  f = get_fptr(0);
  f (2);
  if (gl != 42)
    __builtin_abort ();

  g = get_fptr(1);
  if (g (2) != 42)
    __builtin_abort ();

  return 0;
}
Exemplo n.º 22
0
void
f0 (void)
{
  int i, j, k;
  unsigned int j2, k2;
  #pragma omp for reduction(+: l) schedule(runtime)
  for (i = ji; i < ki; i++)
    l++;
  if (l != 0)
    __builtin_abort ();
  #pragma omp parallel for reduction(+: l) schedule(runtime)
  for (i = ji; i < ki; i++)
    l++;
  if (l != 0)
    __builtin_abort ();
  #pragma omp for reduction(+: l) collapse(3) schedule(runtime)
  for (j = 0; j < 4; j++)
    for (i = ji; i < ki; i++)
      for (k = 0; k < 5; k += 2)
	l++;
  if (l != 0)
    __builtin_abort ();
  #pragma omp parallel for reduction(+: l) collapse(3) schedule(runtime)
  for (j = 0; j < 4; j++)
    for (i = ji; i < ki; i++)
      for (k = 0; k < 5; k += 2)
	l++;
  if (l != 0)
    __builtin_abort ();
  #pragma omp for reduction(+: l) collapse(3) schedule(runtime)
  for (j2 = 0; j2 < 4; j2++)
    for (i = ji; i < ki; i++)
      for (k2 = 0; k2 < 5; k2 += 2)
	l++;
  if (l != 0)
    __builtin_abort ();
  #pragma omp parallel for reduction(+: l) collapse(3) schedule(runtime)
  for (j2 = 0; j2 < 4; j2++)
    for (i = ji; i < ki; i++)
      for (k2 = 0; k2 < 5; k2 += 2)
	l++;
  if (l != 0)
    __builtin_abort ();
  #pragma omp parallel for reduction(+: l) collapse(3) schedule(runtime)
  for (j = 0; j < 4; j++)
    for (i = ji; i < ki; i++)
      for (k = ki + 10; k < ji - 10; k += 2)
	l++;
  if (l != 0)
    __builtin_abort ();
  #pragma omp parallel for reduction(+: l) collapse(3) schedule(runtime)
  for (j = ki + 10; j < ji - 10; j++)
    for (i = ji; i < ki; i++)
      for (k = 0; k < 5; k += 2)
	l++;
  if (l != 0)
    __builtin_abort ();
}
Exemplo n.º 23
0
void
f3 (void)
{
  unsigned long long int i, j, k;
  long long int j2, k2;
  #pragma omp for reduction(+: l) schedule(runtime)
  for (i = jull; i < kull; i++)
    l++;
  if (l != 0)
    __builtin_abort ();
  #pragma omp parallel for reduction(+: l) schedule(runtime)
  for (i = jull; i < kull; i++)
    l++;
  if (l != 0)
    __builtin_abort ();
  #pragma omp for reduction(+: l) collapse(3) schedule(runtime)
  for (j = 0; j < 4; j++)
    for (i = jull; i < kull; i++)
      for (k = 0; k < 5; k += 2)
	l++;
  if (l != 0)
    __builtin_abort ();
  #pragma omp parallel for reduction(+: l) collapse(3) schedule(runtime)
  for (j = 0; j < 4; j++)
    for (i = jull; i < kull; i++)
      for (k = 0; k < 5; k += 2)
	l++;
  if (l != 0)
    __builtin_abort ();
  #pragma omp for reduction(+: l) collapse(3) schedule(runtime)
  for (j2 = 0; j2 < 4; j2++)
    for (i = jull; i < kull; i++)
      for (k2 = 0; k2 < 5; k2 += 2)
	l++;
  if (l != 0)
    __builtin_abort ();
  #pragma omp parallel for reduction(+: l) collapse(3) schedule(runtime)
  for (j2 = 0; j2 < 4; j2++)
    for (i = jull; i < kull; i++)
      for (k2 = 0; k2 < 5; k2 += 2)
	l++;
  if (l != 0)
    __builtin_abort ();
  #pragma omp parallel for reduction(+: l) collapse(3) schedule(runtime)
  for (j = 0; j < 4; j++)
    for (i = jull; i < kull; i++)
      for (k = kull; k < jull; k += 2)
	l++;
  if (l != 0)
    __builtin_abort ();
  #pragma omp parallel for reduction(+: l) collapse(3) schedule(runtime)
  for (j = kull; j < jull; j++)
    for (i = jull; i < kull; i++)
      for (k = 0; k < 5; k += 2)
	l++;
  if (l != 0)
    __builtin_abort ();
}
Exemplo n.º 24
0
int
foo3 (struct S x, struct S y, struct S z)
{
    if (z.a != 9)
        __builtin_abort ();
    return 0;
}
Exemplo n.º 25
0
int main(void)
{
  double x = -0.0;
  if (copysign_bug (x) != 2)
    __builtin_abort ();
  return 0;
}
Exemplo n.º 26
0
static void
bmi2_test ()
{
  u128 x = foo((v32u16){(unsigned short) ~0xba31, 0x47c6}, (v32u64){64}, (v32u64){0, 0x8b217e2514d23242, 0xac569b6dff9f82, 0x9d4cffe03c139c});
  if (x != 0x3c74da5ca328d09)
    __builtin_abort();
}
Exemplo n.º 27
0
main()
{
  *ptr=1;
  typepun ();
  if (*ptr)
    __builtin_abort ();
}
Exemplo n.º 28
0
void
foo (void *frame, uword_t error_code)
{
  aligned j;
  if (check_int (frame, &j, __alignof__(j)))
    __builtin_abort ();
}
Exemplo n.º 29
0
__attribute__((noinline, noclone)) void
foo (int x)
{
  if (x != -3161)
    __builtin_abort ();
  asm volatile ("" : : : "memory");
}
Exemplo n.º 30
0
int main(void)
{
  const signed short test_vec[] = { 1, 1, 1, 1, 1, 1, 1, 1 };
  if (scalarproduct_int16_vsx (test_vec, test_vec, 8) != 8)
    __builtin_abort ();
  return 0;
}