brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 039a114 Raw
71 lines · c
1// RUN: %clang_cc1 %s -O1 -emit-llvm -o - | FileCheck %s2 3/* Test for builtin conj, creal, cimag.  */4/* Origin: Joseph Myers <jsm28@cam.ac.uk> */5 6extern float _Complex conjf (float _Complex);7extern double _Complex conj (double _Complex);8extern long double _Complex conjl (long double _Complex);9 10extern float crealf (float _Complex);11extern double creal (double _Complex);12extern long double creall (long double _Complex);13 14extern float cimagf (float _Complex);15extern double cimag (double _Complex);16extern long double cimagl (long double _Complex);17 18extern void abort (void);19extern void link_error (void);20 21int22main (void)23{24  /* For each type, test both runtime and compile time (constant folding)25     optimization.  */26  volatile float _Complex fc = 1.0F + 2.0iF;27  volatile double _Complex dc = 1.0 + 2.0i;28  volatile long double _Complex ldc = 1.0L + 2.0iL;29  /* Test floats.  */30  if (__builtin_conjf (fc) != 1.0F - 2.0iF)31    abort ();32  if (__builtin_conjf (1.0F + 2.0iF) != 1.0F - 2.0iF)33    link_error ();34  if (__builtin_crealf (fc) != 1.0F)35    abort ();36  if (__builtin_crealf (1.0F + 2.0iF) != 1.0F)37    link_error ();38  if (__builtin_cimagf (fc) != 2.0F)39    abort ();40  if (__builtin_cimagf (1.0F + 2.0iF) != 2.0F)41    link_error ();42  /* Test doubles.  */43  if (__builtin_conj (dc) != 1.0 - 2.0i)44    abort ();45  if (__builtin_conj (1.0 + 2.0i) != 1.0 - 2.0i)46    link_error ();47  if (__builtin_creal (dc) != 1.0)48    abort ();49  if (__builtin_creal (1.0 + 2.0i) != 1.0)50    link_error ();51  if (__builtin_cimag (dc) != 2.0)52    abort ();53  if (__builtin_cimag (1.0 + 2.0i) != 2.0)54    link_error ();55  /* Test long doubles.  */56  if (__builtin_conjl (ldc) != 1.0L - 2.0iL)57    abort ();58  if (__builtin_conjl (1.0L + 2.0iL) != 1.0L - 2.0iL)59    link_error ();60  if (__builtin_creall (ldc) != 1.0L)61    abort ();62  if (__builtin_creall (1.0L + 2.0iL) != 1.0L)63    link_error ();64  if (__builtin_cimagl (ldc) != 2.0L)65    abort ();66  if (__builtin_cimagl (1.0L + 2.0iL) != 2.0L)67    link_error ();68}69 70// CHECK-NOT: link_error71