1 // RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -ffreestanding -verify %s 2 // RUN: %clang_cc1 -std=c++11 -triple i686-pc-linux-gnu -ffreestanding -verify %s 3 // RUN: %clang_cc1 -std=c++11 -triple avr-unknown-unknown -ffreestanding -verify %s 4 5 // expected-no-diagnostics 6 7 // Test that checks that the builtins return the same type as the stdint.h type 8 // withe the same witdh. This is done by first declaring a variable of a stdint 9 // type of the correct width and the redeclaring the variable with the type that 10 // the builting return. If the types are different you should the an error from 11 // clang of the form: 12 // "redefinition of '<varname>' with a different type: '<type1>' vs '<type2>' 13 // (with gcc you get an error message 14 // "conflicting declaration '<type> <varname>'"). 15 16 #include <stdint.h> 17 18 extern uint16_t bswap16; 19 decltype(__builtin_bswap16(0)) bswap16 = 42; 20 extern uint32_t bswap32; 21 decltype(__builtin_bswap32(0)) bswap32 = 42; 22 extern uint64_t bswap64; 23 decltype(__builtin_bswap64(0)) bswap64 = 42; 24 25 #ifdef __clang__ 26 extern uint8_t bitrev8; 27 decltype(__builtin_bitreverse8(0)) bitrev8 = 42; 28 extern uint16_t bitrev16; 29 decltype(__builtin_bitreverse16(0)) bitrev16 = 42; 30 extern uint32_t bitrev32; 31 decltype(__builtin_bitreverse32(0)) bitrev32 = 42; 32 extern uint64_t bitrev64; 33 decltype(__builtin_bitreverse64(0)) bitrev64 = 42; 34 35 extern uint8_t rotl8; 36 decltype(__builtin_rotateleft8(0,0)) rotl8 = 42; 37 extern uint16_t rotl16; 38 decltype(__builtin_rotateleft16(0,0)) rotl16 = 42; 39 extern uint32_t rotl32; 40 decltype(__builtin_rotateleft32(0,0)) rotl32 = 42; 41 extern uint64_t rotl64; 42 decltype(__builtin_rotateleft64(0,0)) rotl64 = 42; 43 44 extern uint8_t rotr8; 45 decltype(__builtin_rotateright8(0,0)) rotr8 = 42; 46 extern uint16_t rotr16; 47 decltype(__builtin_rotateright16(0,0)) rotr16 = 42; 48 extern uint32_t rotr32; 49 decltype(__builtin_rotateright32(0,0)) rotr32 = 42; 50 extern uint64_t rotr64; 51 decltype(__builtin_rotateright64(0,0)) rotr64 = 42; 52 #endif 53