https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70392
Bug ID: 70392 Summary: [openacc] inconsistent line numbers in uninitialised warnings for if clause Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org Target Milestone: --- I. uninitialized warning, regular 1. In fortran, the line number for the uninitialized warning is the one for the use: ... $ cat -n uninit.f95 1 subroutine foo 2 3 integer :: i 4 5 i = i + 1 6 7 end subroutine foo $ gfortran -Wuninitialized uninit.f95 -S uninit.f95:5:0: i = i + 1 Warning: ‘i’ is used uninitialized in this function [-Wuninitialized] .... 2. In C, that's the same: ... $ cat -n uninit.c 1 void 2 foo (void) 3 { 4 int i; 5 6 i++; 7 } $ gcc -Wuninitialized uninit.c -S uninit.c: In function ‘foo’: uninit.c:6:4: warning: ‘i’ is used uninitialized in this function [-Wuninitialized] i++; ~^~ ... 3. And in C++, still the same: ... $ g++ -Wuninitialized uninit.c -S uninit.c: In function ‘void foo()’: uninit.c:6:6: warning: ‘i’ is used uninitialized in this function [-Wuninitialized] i++; ^ ... II. uninitialized warning, openacc if-clause 1. Again, in Fortran, the line number for the uninitialized warning is the one for the use: ... $ cat -n uninit-if.f95 1 2 program test 3 implicit none 4 logical :: b, b2, b3, b4 5 integer :: data, data2 6 7 !$acc parallel if(b) 8 !$acc end parallel 9 10 !$acc kernels if(b2) 11 !$acc end kernels 12 13 !$acc data if(b3) 14 !$acc end data 15 16 !$acc update if(b4) self(data2) 17 18 end program test $ gfortran -Wuninitialized uninit-if.f95 -S -fopenacc uninit-if.f95:7:0: !$acc parallel if(b) Warning: ‘b’ is used uninitialized in this function [-Wuninitialized] uninit-if.f95:10:0: !$acc kernels if(b2) Warning: ‘b2’ is used uninitialized in this function [-Wuninitialized] uninit-if.f95:13:0: !$acc data if(b3) Warning: ‘b3’ is used uninitialized in this function [-Wuninitialized] uninit-if.f95:16:0: !$acc update if(b4) self(data2) Warning: ‘b4’ is used uninitialized in this function [-Wuninitialized] ... 2. In C, that's the same: ... $ cat -n uninit-if.c 1 #include <stdbool.h> 2 3 int 4 main (void) 5 { 6 int i, i2, i3, i4; 7 bool b, b2, b3, b4; 8 int data, data2; 9 10 #pragma acc parallel if(i) 11 ; 12 13 #pragma acc parallel if(b) 14 ; 15 16 #pragma acc kernels if(i2) 17 ; 18 19 #pragma acc kernels if(b2) 20 ; 21 22 #pragma acc data if(i3) 23 ; 24 25 #pragma acc data if(b3) 26 ; 27 28 #pragma acc update if(i4) self(data) 29 ; 30 31 #pragma acc update if(b4) self(data2) 32 ; 33 34 } $ ./lean/install/bin/gcc -Wuninitialized uninit-if.c -S -fopenacc uninit-if.c: In function ‘main’: uninit-if.c:10:27: warning: ‘i’ is used uninitialized in this function [-Wuninitialized] #pragma acc parallel if(i) ^ uninit-if.c:13:27: warning: ‘b’ is used uninitialized in this function [-Wuninitialized] #pragma acc parallel if(b) ^ uninit-if.c:16:26: warning: ‘i2’ is used uninitialized in this function [-Wuninitialized] #pragma acc kernels if(i2) ^~ uninit-if.c:19:26: warning: ‘b2’ is used uninitialized in this function [-Wuninitialized] #pragma acc kernels if(b2) ^~ uninit-if.c:22:23: warning: ‘i3’ is used uninitialized in this function [-Wuninitialized] #pragma acc data if(i3) ^~ uninit-if.c:25:23: warning: ‘b3’ is used uninitialized in this function [-Wuninitialized] #pragma acc data if(b3) ^~ uninit-if.c:28:25: warning: ‘i4’ is used uninitialized in this function [-Wuninitialized] #pragma acc update if(i4) self(data) ^~ uninit-if.c:31:25: warning: ‘b4’ is used uninitialized in this function [-Wuninitialized] #pragma acc update if(b4) self(data2) ^~ ... 3. For C++ however, for the bool variables, we get the line number of the declaration: ... $ ./lean/install/bin/g++ -Wuninitialized uninit-if.c -S -fopenacc uninit-if.c: In function ‘int main()’: uninit-if.c:10:29: warning: ‘i’ is used uninitialized in this function [-Wuninitialized] #pragma acc parallel if(i) ^ uninit-if.c:7:8: warning: ‘b’ is used uninitialized in this function [-Wuninitialized] bool b, b2, b3, b4; ^ uninit-if.c:16:29: warning: ‘i2’ is used uninitialized in this function [-Wuninitialized] #pragma acc kernels if(i2) ^ uninit-if.c:7:11: warning: ‘b2’ is used uninitialized in this function [-Wuninitialized] bool b, b2, b3, b4; ^~ uninit-if.c:22:26: warning: ‘i3’ is used uninitialized in this function [-Wuninitialized] #pragma acc data if(i3) ^ uninit-if.c:7:15: warning: ‘b3’ is used uninitialized in this function [-Wuninitialized] bool b, b2, b3, b4; ^~ uninit-if.c:28:39: warning: ‘i4’ is used uninitialized in this function [-Wuninitialized] #pragma acc update if(i4) self(data) ^ uninit-if.c:7:19: warning: ‘b4’ is used uninitialized in this function [-Wuninitialized] bool b, b2, b3, b4; ^~ ...