File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,8 +66,8 @@ typedef enum {
6666 OPTION_UNKNOWN,
6767} TransformOption;
6868
69- double transform_and_sum (const double * array, size_t size,
70- TransformOption option) {
69+ __attribute__ ((pure)) double transform_and_sum(const double * array, size_t size,
70+ TransformOption option) {
7171 double sum = 0.0;
7272
7373 double factor;
@@ -146,6 +146,7 @@ the specified transformation:
146146! example.f90
147147
148148module options
149+ implicit none
149150 integer, parameter :: OPTION_HALF = 1
150151 integer, parameter :: OPTION_DOUBLE = 2
151152 integer, parameter :: OPTION_UNKNOWN = 3
@@ -163,7 +164,7 @@ program main
163164
164165contains
165166
166- real(kind=real32) function transform_and_sum(array, option)
167+ pure real(kind=real32) function transform_and_sum(array, option)
167168 implicit none
168169
169170 real(kind=real32), intent(in) :: array(:)
Original file line number Diff line number Diff line change @@ -8,8 +8,8 @@ typedef enum {
88 OPTION_UNKNOWN ,
99} TransformOption ;
1010
11- double transform_and_sum (const double * array , size_t size ,
12- TransformOption option ) {
11+ __attribute__(( pure )) double transform_and_sum (const double * array , size_t size ,
12+ TransformOption option ) {
1313 double sum = 0.0 ;
1414
1515 double factor ;
Original file line number Diff line number Diff line change 11! PWR080: Conditionally initialized variables can lead to undefined behavior
22
33module options
4+ implicit none
45 integer , parameter :: OPTION_HALF = 1
56 integer , parameter :: OPTION_DOUBLE = 2
67 integer , parameter :: OPTION_UNKNOWN = 3
@@ -18,7 +19,7 @@ program main
1819
1920contains
2021
21- real (kind= real32) function transform_and_sum(array, option)
22+ pure real (kind= real32) function transform_and_sum(array, option)
2223 implicit none
2324
2425 real (kind= real32), intent (in ) :: array(:)
Original file line number Diff line number Diff line change @@ -8,8 +8,8 @@ typedef enum {
88 OPTION_UNKNOWN ,
99} TransformOption ;
1010
11- double transform_and_sum (const double * array , size_t size ,
12- TransformOption option ) {
11+ __attribute__(( pure )) double transform_and_sum (const double * array , size_t size ,
12+ TransformOption option ) {
1313 double sum = 0.0 ;
1414
1515 // Identity transformation by default
Original file line number Diff line number Diff line change 11! PWR080: Conditionally initialized variables can lead to undefined behavior
22
33module options
4+ implicit none
45 integer , parameter :: OPTION_HALF = 1
56 integer , parameter :: OPTION_DOUBLE = 2
67 integer , parameter :: OPTION_UNKNOWN = 3
@@ -18,7 +19,7 @@ program main
1819
1920contains
2021
21- real (kind= real32) function transform_and_sum(array, option)
22+ pure real (kind= real32) function transform_and_sum(array, option)
2223 implicit none
2324
2425 real (kind= real32), intent (in ) :: array(:)
You can’t perform that action at this time.
0 commit comments