Hi Alessandro, > I have realized a draft patch for the PR 46321, currently it works > only with the explicit DEALLOCATE.
thanks for the patch! Some first comments without actually looking at the patch in detail ... > Running the regression tests it doesn't pass the following: > > - gfortran.dg/class_19.f03 (too much "__builtin_free") > - gfortran.dg/auto_dealloc_2.f90 (too much "__builtin_free") > - gfortran.dg/dynamic_dispatch_4.f03 (free on invalid pointer) > - gfortran.dg/typebound_operator_9.f03 (fails during the execution test) > > The first two tests fail due to the introduction of "__builtin_free" > in the freeing functions, so it is not a problem. Right. You should certainly fix the "scan-tree-dump-times" checks (by adjusting the numbers properly, and making sure that they are actually what one would expect), in order to make them pass. > The gfortran.dg/dynamic_dispatch_4.f03 had this problem in the past > (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43986); currently it > calls the __free_s_bar_mod_S_bar function instead of the proper > doit(). Sorry, I don't understand the last sentence. Why should it call some "__free..." instead of "doit"? And why is that test case even affected by your patch (you said it would only work with explicit DEALLOCATE, which does not appear in that test case)? > Regarding typebound_operator_9.f03, I don't know how to fix the patch... Unfortunately that test case is rather large, so maybe you should reduce it a bit to find the error (or just do some debugging in order to find out where exactly it fails). Another possibility: Compare the dump (using -fdump-tree-original) with and without the patch. > The patch is written in a "raw" way due to my newbieness, so any > suggestion is well accepted. The patch actually gives a few warnings: /home/jweil/gcc48/trunk/gcc/fortran/class.c: In function ‘gfc_find_derived_vtab’: /home/jweil/gcc48/trunk/gcc/fortran/class.c:912:8: warning: ISO C90 forbids mixed declarations and code [-pedantic] /home/jweil/gcc48/trunk/gcc/fortran/class.c:932:7: warning: C++ style comments are not allowed in ISO C90 [enabled by default] /home/jweil/gcc48/trunk/gcc/fortran/class.c:932:7: warning: (this will be reported only once per input file) [enabled by default] (and similar things in trans-stmt.c). You should definitely fix those. Although a non-buildstrap build still works with those warnings, a full bootstrap will fail. Cheers, Janus