1! { dg-do run } 2! { dg-options "-ffree-line-length-none" } 3! { dg-require-effective-target fortran_integer_16 } 4 5#define CHECK(val,res) \ 6 if (popcnt(val) /= res) call abort ; \ 7 if (runtime_popcnt(val) /= res) call abort 8 9#define CHECK2(val) \ 10 if (poppar(val) /= modulo(popcnt(val),2)) call abort ; \ 11 if (runtime_poppar(val) /= poppar(val)) call abort 12 13 CHECK(0_16, 0) 14 CHECK(1_16, 1) 15 16 CHECK(-1_16,128) 17 CHECK(-8_16,128-3) 18 19 CHECK(huge(0_16), 128-1) 20 21 CHECK(-huge(0_16), 2) 22 23 CHECK2(0_16) 24 CHECK2(17_16) 25 CHECK2(-17_16) 26 CHECK2(huge(0_16)) 27 CHECK2(-huge(0_16)) 28 29contains 30 integer function runtime_popcnt (i) result(res) 31 integer(kind=16), intent(in) :: i 32 res = popcnt(i) 33 end function 34 35 integer function runtime_poppar (i) result(res) 36 integer(kind=16), intent(in) :: i 37 res = poppar(i) 38 end function 39end 40