Re: [Patch, fortran] F2008 - implement pointer function assignment

2015-09-03 Thread Dominique d'Humières
Dear Paul,

I have tested your patch (with the two patches in pr67429) and got the 
following regressions:

FAIL: gfortran.dg/bind_c_usage_12.f03   -O   (test for errors, line 33)
FAIL: gfortran.dg/bind_c_usage_12.f03   -O   (test for errors, line 51)
FAIL: gfortran.dg/bind_c_usage_12.f03   -O   (test for errors, line 61)
FAIL: gfortran.dg/bind_c_usage_12.f03   -O  (test for excess errors)
FAIL: gfortran.dg/derived_function_interface_1.f90   -O   (test for errors, 
line 41)
FAIL: gfortran.dg/derived_function_interface_1.f90   -O  (test for excess 
errors)
FAIL: gfortran.dg/error_recovery_3.f90   -O   (test for errors, line 9)
FAIL: gfortran.dg/error_recovery_3.f90   -O  (test for excess errors)
FAIL: gfortran.dg/func_decl_1.f90   -O   (test for errors, line 16)
FAIL: gfortran.dg/func_decl_1.f90   -O   (test for errors, line 22)
FAIL: gfortran.dg/func_decl_1.f90   -O  (test for excess errors)
FAIL: gfortran.dg/func_decl_4.f90   -O   (test for errors, line 20)
FAIL: gfortran.dg/func_decl_4.f90   -O  (test for excess errors)
FAIL: gfortran.dg/proc_assign_1.f90   -O   (test for errors, line 68)
FAIL: gfortran.dg/proc_assign_1.f90   -O   (test for errors, line 73)
FAIL: gfortran.dg/proc_assign_1.f90   -O  (internal compiler error)
FAIL: gfortran.dg/proc_assign_1.f90   -O  (test for excess errors)
FAIL: gfortran.dg/typebound_proc_23.f90   -O0  (internal compiler error)
FAIL: gfortran.dg/typebound_proc_23.f90   -O0  (test for excess errors)
UNRESOLVED: gfortran.dg/typebound_proc_23.f90   -O0  compilation failed to 
produce executable
FAIL: gfortran.dg/typebound_proc_23.f90   -O1  (internal compiler error)
FAIL: gfortran.dg/typebound_proc_23.f90   -O1  (test for excess errors)
UNRESOLVED: gfortran.dg/typebound_proc_23.f90   -O1  compilation failed to 
produce executable
FAIL: gfortran.dg/typebound_proc_23.f90   -O2  (internal compiler error)
FAIL: gfortran.dg/typebound_proc_23.f90   -O2  (test for excess errors)
UNRESOLVED: gfortran.dg/typebound_proc_23.f90   -O2  compilation failed to 
produce executable
FAIL: gfortran.dg/typebound_proc_23.f90   -O3 -fomit-frame-pointer 
-funroll-loops -fpeel-loops -ftracer -finline-functions  (internal compiler 
error)
FAIL: gfortran.dg/typebound_proc_23.f90   -O3 -fomit-frame-pointer 
-funroll-loops -fpeel-loops -ftracer -finline-functions  (test for excess 
errors)
UNRESOLVED: gfortran.dg/typebound_proc_23.f90   -O3 -fomit-frame-pointer 
-funroll-loops -fpeel-loops -ftracer -finline-functions  compilation failed to 
produce executable
FAIL: gfortran.dg/typebound_proc_23.f90   -O3 -g  (internal compiler error)
FAIL: gfortran.dg/typebound_proc_23.f90   -O3 -g  (test for excess errors)
UNRESOLVED: gfortran.dg/typebound_proc_23.f90   -O3 -g  compilation failed to 
produce executable
FAIL: gfortran.dg/typebound_proc_23.f90   -Os  (internal compiler error)
FAIL: gfortran.dg/typebound_proc_23.f90   -Os  (test for excess errors)
UNRESOLVED: gfortran.dg/typebound_proc_23.f90   -Os  compilation failed to 
produce executable
FAIL: gfortran.dg/use_7.f90   -O   (test for errors, line 42)
FAIL: gfortran.dg/use_7.f90   -O   (test for errors, line 43)
FAIL: gfortran.dg/use_7.f90   -O   (test for errors, line 44)
FAIL: gfortran.dg/use_7.f90   -O   (test for errors, line 45)
FAIL: gfortran.dg/use_7.f90   -O   (test for errors, line 46)
FAIL: gfortran.dg/use_7.f90   -O  (test for excess errors)

The failures for typebound_proc_23.f90 and proc_assign_1.f90 are ICEs

f951: internal compiler error: Segmentation fault: 11

The failures for gfortran.dg/bind_c_usage_12.f03 are

/opt/gcc/_clean/gcc/testsuite/gfortran.dg/bind_c_usage_12.f03:33:25:

   integer(c_int) function int2() bind(c, name="jjj") ! { dg-error "No binding 
name is allowed" }
 1
Error: Syntax error in data declaration at (1)

/opt/gcc/_clean/gcc/testsuite/gfortran.dg/bind_c_usage_12.f03:51:25:

   integer(c_int) function int2() bind(c, name="kkk") ! { dg-error "No binding 
name is allowed" }
 1
Error: Syntax error in data declaration at (1)

/opt/gcc/_clean/gcc/testsuite/gfortran.dg/bind_c_usage_12.f03:61:25:

   integer(c_int) function int2() bind(c, name="mmm") ! { dg-error "No binding 
name is allowed" }
 1
Error: Syntax error in data declaration at (1)

I also see

/opt/gcc/work/gcc/testsuite/gfortran.dg/func_decl_1.f90:16:0: Error: 
Unclassifiable statement at (1)
/opt/gcc/work/gcc/testsuite/gfortran.dg/func_decl_1.f90:22:0: Error: 
Unclassifiable statement at (1)

/opt/gcc/work/gcc/testsuite/gfortran.dg/use_7.f90:42:0: Error: Unclassifiable 
statement at (1)
/opt/gcc/work/gcc/testsuite/gfortran.dg/use_7.f90:43:0: Error: Unclassifiable 
statement at (1)
/opt/gcc/work/gcc/testsuite/gfortran.dg/use_7.f90:44:0: Error: Unclassifiable 
statement at (1)
/opt/gcc/work/gcc/testsuite/gfortran.dg/use_7.f90:45:0: Error: Unclassifiable 
statement at (1)
/opt/gcc/work/gcc/testsuite/gfortran.dg/use_7.f90:46:0: Error: Unclassifiable 
statement at (1)

Cheers,

Dominique



Re: [Patch, fortran] F2008 - implement pointer function assignment

2015-08-27 Thread FX
Hi Paul,

I’ll get to reviewing the patch tonight or tomorrow…

I think it shouldn’t be too hard to get the ambiguity lifted. We already can do 
it for array assignment vs. statement functions, so maybe we could get a hint 
from that?

touille /tmp $ cat a.f90
  integer :: f(2) = 0
  integer :: x = 1
  f(x) = x
  x = 2
  print *, f(x)
end
touille /tmp $ cat b.f90
  integer :: f
  integer :: x = 1
  f(x) = x
  x = 2
  print *, f(x)
end
touille /tmp $ gfortran a.f90  ./a.out
   0
touille /tmp $ gfortran b.f90  ./a.out
   2



FX

Re: [Patch, fortran] F2008 - implement pointer function assignment

2015-08-27 Thread Mikael Morin

Le 27/08/2015 16:54, FX a écrit :

I think it shouldn’t be too hard to get the ambiguity lifted. We already can do 
it for array assignment vs. statement functions, so maybe we could get a hint 
from that?

Well, for array assignments, the array is declared before, whereas for 
pointer functions, the declaration can come after (contained functions). 
 That's an important difference, I think.


Mikael


Re: [Patch, fortran] F2008 - implement pointer function assignment

2015-08-27 Thread Paul Richard Thomas
Dear FX and Mikael,

Please hold off on reviewing the patch until I say so. Some rather
trivial looking tidying up before submission has introduced a dozen or
so regressions :-(

Cheers

Paul

On 27 August 2015 at 16:54, FX fxcoud...@gmail.com wrote:
 Hi Paul,

 I’ll get to reviewing the patch tonight or tomorrow…

 I think it shouldn’t be too hard to get the ambiguity lifted. We already can 
 do it for array assignment vs. statement functions, so maybe we could get a 
 hint from that?

 touille /tmp $ cat a.f90
   integer :: f(2) = 0
   integer :: x = 1
   f(x) = x
   x = 2
   print *, f(x)
 end
 touille /tmp $ cat b.f90
   integer :: f
   integer :: x = 1
   f(x) = x
   x = 2
   print *, f(x)
 end
 touille /tmp $ gfortran a.f90  ./a.out
0
 touille /tmp $ gfortran b.f90  ./a.out
2



 FX



-- 
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.

Groucho Marx


[Patch, fortran] F2008 - implement pointer function assignment

2015-08-26 Thread Paul Richard Thomas
Dear All,

The attached patch more or less implements the assignment of
expressions to the result of a pointer function. To wit:

my_ptr_fcn (arg1, arg2...) = expr

arg1 would usually be the target, pointed to by the function. The
patch parses these statements and resolves them into:

temp_ptr = my_ptr_fcn (arg1, arg2...)
temp_ptr = expr

I say more or less implemented because I have ducked one of the
headaches here. At the end of the specification block, there is an
ambiguity between statement functions and pointer function
assignments. I do not even try to resolve this ambiguity and require
that there be at least one other type of executable statement before
these beasts. This can undoubtedly be fixed but the effort seems to me
to be unwarranted at the present time.

I had a stupid amount of trouble with the test fmt_tab_1.f90. I have
no idea why but the gfc_warning no longer showed the offending line,
although the line number in the error message was OK. Changing to
gfc_warning_now fixed the problem. Also, I can see no reason why this
should be dg-run and so changed to dg-compile. Finally, I set
-std=legacy to stop the generic error associated with tabs.

Bootstraps and regtests on x86_64/FC21 - OK for trunk?

Now back to trying to get my head round parameterized derived types!

Cheers

Paul

2015-08-26  Paul Thomas  pa...@gcc.gnu.org

* decl.c (get_proc_name): Return if statement function is
found.
* io.c (next_char_not_space): Change tab warning to warning now
to prevent locus being lost.
* match.c (gfc_match_ptr_fcn_assign): New function.
* match.h : Add prototype for gfc_match_ptr_fcn_assign.
* parse.c : Add static flag 'in_specification_block'.
(decode_statement): If in specification block match a statement
function, otherwise if standard embraces F2008 try to match a
pointer function assignment.
(parse_interface): Set 'in_specification_block' on exiting from
parse_spec.
(parse_spec): Set and then reset 'in_specification_block'.
(gfc_parse_file): Set 'in_specification_block'.
* resolve.c (get_temp_from_expr): Extend to include functions
and array constructors as rvalues..
(resolve_ptr_fcn_assign): New function.
(gfc_resolve_code): Call it on finding a pointer function as an
lvalue.
* symbol.c (gfc_add_procedure): Add a sentence to the error to
flag up the ambiguity between a statement function and pointer
function assignment at the end of the specification block.

2015-08-26  Paul Thomas  pa...@gcc.gnu.org

* gfortran.dg/fmt_tab_1.f90: Change from run to compile and set
standard as legacy.
* gfortran.dg/ptr_func_assign_1.f08: New test.
Index: gcc/fortran/decl.c
===
*** gcc/fortran/decl.c  (revision 227118)
--- gcc/fortran/decl.c  (working copy)
*** get_proc_name (const char *name, gfc_sym
*** 901,906 
--- 901,908 
  return rc;
  
sym = *result;
+   if (sym-attr.proc == PROC_ST_FUNCTION)
+ return rc;
  
if (sym-attr.module_procedure
 sym-attr.if_source == IFSRC_IFBODY)
Index: gcc/fortran/io.c
===
*** gcc/fortran/io.c(revision 227118)
--- gcc/fortran/io.c(working copy)
*** next_char_not_space (bool *error)
*** 200,206 
if (c == '\t')
{
  if (gfc_option.allow_std  GFC_STD_GNU)
!   gfc_warning (0, Extension: Tab character in format at %C);
  else
{
  gfc_error (Extension: Tab character in format at %C);
--- 200,206 
if (c == '\t')
{
  if (gfc_option.allow_std  GFC_STD_GNU)
!   gfc_warning_now (0, Extension: Tab character in format at %C);
  else
{
  gfc_error (Extension: Tab character in format at %C);
Index: gcc/fortran/match.c
===
*** gcc/fortran/match.c (revision 227118)
--- gcc/fortran/match.c (working copy)
*** match
*** 4886,4892 
  gfc_match_st_function (void)
  {
gfc_error_buffer old_error;
- 
gfc_symbol *sym;
gfc_expr *expr;
match m;
--- 4886,4891 
*** gfc_match_st_function (void)
*** 4926,4931 
--- 4925,5000 
return MATCH_YES;
  
  undo_error:
+   gfc_pop_error (old_error);
+   return MATCH_NO;
+ }
+ 
+ 
+ /* Match an assignment to a pointer function (F2008). This could, in
+general be ambiguous with a statement function. In this implementation
+it remains so if it is the first statement after the specification
+block.  */
+ 
+ match
+ gfc_match_ptr_fcn_assign (void)
+ {
+   gfc_error_buffer old_error;
+   locus old_loc;
+   gfc_symbol *sym;
+   gfc_expr *expr;
+   match m;
+   char name[GFC_MAX_SYMBOL_LEN + 1];
+ 
+   old_loc = gfc_current_locus;
+   m = gfc_match_name (name);
+   if (m != MATCH_YES)
+ return m;
+ 
+