aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/c_kind_params.f90
blob: c595a3bbcf009a272cf69f1d838a16043451e1cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
! { dg-do run }
! { dg-require-effective-target stdint_types }
! { dg-additional-sources c_kinds.c }
! { dg-options "-w -std=c99" }
! the -w option is needed to make f951 not report a warning for 
! the -std=c99 option that the C file needs.
!
module c_kind_params
  use, intrinsic :: iso_c_binding
  implicit none

contains
  subroutine param_test(my_short, my_int, my_long, my_long_long, &
       my_int8_t, my_int_least8_t, my_int_fast8_t, &
       my_int16_t, my_int_least16_t, my_int_fast16_t, &
       my_int32_t, my_int_least32_t, my_int_fast32_t, &
       my_int64_t, my_int_least64_t, my_int_fast64_t, &
       my_intmax_t, my_intptr_t, my_float, my_double, my_long_double, &
       my_char, my_bool) bind(c)
    integer(c_short), value :: my_short
    integer(c_int), value :: my_int
    integer(c_long), value :: my_long
    integer(c_long_long), value :: my_long_long
    integer(c_int8_t), value :: my_int8_t
    integer(c_int_least8_t), value :: my_int_least8_t
    integer(c_int_fast8_t), value :: my_int_fast8_t
    integer(c_int16_t), value :: my_int16_t
    integer(c_int_least16_t), value :: my_int_least16_t
    integer(c_int_fast16_t), value :: my_int_fast16_t
    integer(c_int32_t), value :: my_int32_t
    integer(c_int_least32_t), value :: my_int_least32_t
    integer(c_int_fast32_t), value :: my_int_fast32_t
    integer(c_int64_t), value :: my_int64_t
    integer(c_int_least64_t), value :: my_int_least64_t
    integer(c_int_fast64_t), value :: my_int_fast64_t
    integer(c_intmax_t), value :: my_intmax_t
    integer(c_intptr_t), value :: my_intptr_t
    real(c_float), value :: my_float
    real(c_double), value :: my_double
    real(c_long_double), value :: my_long_double
    character(c_char), value :: my_char
    logical(c_bool), value :: my_bool

    if(my_short     /= 1_c_short)     call abort()
    if(my_int       /= 2_c_int)       call abort()
    if(my_long      /= 3_c_long)      call abort()
    if(my_long_long /= 4_c_long_long) call abort()

    if(my_int8_t      /= 1_c_int8_t)        call abort()
    if(my_int_least8_t  /= 2_c_int_least8_t ) call abort()
    if(my_int_fast8_t  /= 3_c_int_fast8_t ) call abort()

    if(my_int16_t     /= 1_c_int16_t)       call abort()
    if(my_int_least16_t /= 2_c_int_least16_t) call abort()
    if(my_int_fast16_t  /= 3_c_int_fast16_t ) call abort()

    if(my_int32_t     /= 1_c_int32_t)       call abort()
    if(my_int_least32_t /= 2_c_int_least32_t) call abort()
    if(my_int_fast32_t  /= 3_c_int_fast32_t ) call abort()

    if(my_int64_t     /= 1_c_int64_t)       call abort()
    if(my_int_least64_t /= 2_c_int_least64_t) call abort()
    if(my_int_fast64_t  /= 3_c_int_fast64_t ) call abort()

    if(my_intmax_t /= 1_c_intmax_t) call abort()
    if(my_intptr_t /= 0_c_intptr_t) call abort()

    if(my_float       /= 1.0_c_float) call abort()
    if(my_double      /= 2.0_c_double) call abort()
    if(my_long_double /= 3.0_c_long_double) call abort()

    if(my_char        /= c_char_'y') call abort()
    if(my_bool      .neqv. .true._c_bool) call abort()
  end subroutine param_test
    
end module c_kind_params