This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/66291] New: [OOP] Incorrect compile time warning for final procedure in gfortran


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66291

            Bug ID: 66291
           Summary: [OOP] Incorrect compile time warning for final
                    procedure in gfortran
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: casey.webster at gmail dot com
  Target Milestone: ---

Created attachment 35629
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35629&action=edit
patch for spurious array finalizer compile warnings

Gfortarn 5.1.0 emits incorrect warnings regarding final procedures.  This bug
exists in all version of gfortran since 4.9.0 (when `final` was first supported
by gcc).  The warning complains that only array finalizers were found and to
add a scalar finalizer, even though the only final procedure is a scalar
procedure.

A small testcase:

module A
  type :: typeA
   contains
     final :: finalA
  end type typeA
contains
  subroutine finalA(a_type_A)
    type(typeA) :: a_type_A
  end subroutine finalA
end module A

program bug
  use A
end program bug

The bug is trigged upon use of module A.

gcc 5.1.0 (release version) emits the incorrect compile time warning:

% gfortran -Wall -c final_bug_2.f90  
final_bug_2.f90:13:6:

   use A
      1
Warning: Only array FINAL procedures declared for derived type âtypeaâ defined
at (1), suggest also scalar one [-Wsurprising]

As you can see in the testcase, the finalizer is scalar but gfortran complains
that only array finalizers were found.  

This is related to bug 58175 filed agaisnt gcc 4.9.0 in 2013.  I have adapted
the patch supplied in that bug to apply against gcc 5.1.0 and attached it to
this bug.  The patch is originally by Tobias Burnus and I have only adjusted
the patch for 4.9 to successfully apply against 5.1.0.  This patch fixes the
incorrect compile time warnings and I have tested it with the above testcase.


% gcc -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/5.1.0/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/5.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-5.1.0/work/gcc-5.1.0/configure
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/5.1.0
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/5.1.0/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/5.1.0
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/5.1.0/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/5.1.0/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/5.1.0/include/g++-v5
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/5.1.0/python
--enable-objc-gc --enable-languages=c,c++,java,go,objc,obj-c++,fortran
--enable-obsolete --enable-secureplt --disable-werror --with-system-zlib
--enable-nls --without-included-gettext --enable-checking=release
--with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 5.1.0 p1.0,
pie-0.6.3' --enable-libstdcxx-time --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-multilib
--with-multilib-list=m32,m64 --disable-altivec --disable-fixed-point
--enable-targets=all --enable-libgomp --disable-libmudflap --disable-libssp
--enable-libcilkrts --enable-lto --with-isl --disable-isl-version-check
--enable-libsanitizer
Thread model: posix
gcc version 5.1.0 (Gentoo 5.1.0 p1.0, pie-0.6.3)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]