swar-c99-6.3-conversions.c 1.21 KB
/* -----------------------------------------------------------------------------
 *  Copyright (C) 2018-2020 daiteq s.r.o.                http://www.daiteq.com
 *
 *  This program is distributed WITHOUT ANY WARRANTY; without even
 *  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 *  PURPOSE.
 *
 * -----------------------------------------------------------------------------
 *  Filename    : swar-c99-6.3-conversions.c
 *  Authors     : Roman Bartosinski
 *  Description : simple test of clang/LLVM compiler with SWAR extension
 *  Release     :
 *  Version     :
 *  Date        :
 * -----------------------------------------------------------------------------
 */

//A: --has-swar
//C: -daiteq-swar-enable

#define SWAR_USE_UNSIGNED_TYPES
#define SWAR_USE_SIGNED_TYPES
#include "swar-c99.h"

// variable
su32x1b var32x1u;
ss32x1b var32x1s;

unsigned int varUInt;
int varInt;

int main(void)
{
  varUInt = *((unsigned int *)&var32x1u);
  varInt = *((int *)&var32x1s);

#if 0
  varUInt = (unsigned int) var32x1u;
  varInt = (int) var32x1s;
#endif


  var32x1u = *((su32x1b *)&varUInt);
  var32x1s = *((ss32x1b *)&varInt);

#if 0
  var32x1u = (su32x1b) varUInt;
  var32x1s = (ss32x1b) varInt;
#endif
  
  return 0;
}