+2008-03-28 Daniel Franke <franke.daniel@gmail.com>
+ Paul Richard Thomas <paul.richard.thomas@gmail.com>
+
+ PR fortran/34714
+ * primary.c (match_variable): Improved matching of function
+ result variables.
+ * resolve.c (resolve_allocate_deallocate): Removed checks if
+ the actual argument for STAT is a variable.
+
2008-03-28 Tobias Burnus <burnus@net-b.de>
* symbol.c (gfc_get_default_type): Fix error message; option
break;
case FL_PROCEDURE:
- /* Check for a nonrecursive function result */
- if (sym->attr.function && sym->result == sym && !sym->attr.external)
+ /* Check for a nonrecursive function result variable. */
+ if (sym->attr.function
+ && !sym->attr.external
+ && sym->result == sym
+ && ((sym == gfc_current_ns->proc_name
+ && sym == gfc_current_ns->proc_name->result)
+ || (gfc_current_ns->parent
+ && sym == gfc_current_ns->parent->proc_name->result)
+ || (sym->attr.entry
+ && sym->ns == gfc_current_ns)
+ || (sym->attr.entry
+ && sym->ns == gfc_current_ns->parent)))
{
/* If a function result is a derived type, then the derived
type may still have to be resolved. */
{
gfc_symbol *s = NULL;
gfc_alloc *a;
- bool is_variable;
if (code->expr)
s = code->expr->symtree->n.sym;
if (gfc_pure (NULL) && gfc_impure_variable (s))
gfc_error ("Illegal STAT variable in %s statement at %C "
"for a PURE procedure", fcn);
-
- is_variable = false;
- if (s->attr.flavor == FL_VARIABLE)
- is_variable = true;
- else if (s->attr.function && s->result == s
- && (gfc_current_ns->proc_name == s
- ||
- (gfc_current_ns->parent
- && gfc_current_ns->parent->proc_name == s)))
- is_variable = true;
- else if (gfc_current_ns->entries && s->result == s)
- {
- gfc_entry_list *el;
- for (el = gfc_current_ns->entries; el; el = el->next)
- if (el->sym == s)
- {
- is_variable = true;
- }
- }
- else if (gfc_current_ns->parent && gfc_current_ns->parent->entries
- && s->result == s)
- {
- gfc_entry_list *el;
- for (el = gfc_current_ns->parent->entries; el; el = el->next)
- if (el->sym == s)
- {
- is_variable = true;
- }
- }
-
- if (s->attr.flavor == FL_UNKNOWN
- && gfc_add_flavor (&s->attr, FL_VARIABLE,
- s->name, NULL) == SUCCESS)
- is_variable = true;
-
- if (!is_variable)
- gfc_error ("STAT tag in %s statement at %L must be "
- "a variable", fcn, &code->expr->where);
-
}
if (s && code->expr->ts.type != BT_INTEGER)
+2008-03-28 Daniel Franke <franke.daniel@gmail.com>
+
+ PR fortran/34714
+ * gfortran.dg/alloc_alloc_expr_3.f90: New test.
+ * gfortran.dg/allocate_stat.f90: Adjusted error-match text.
+ * gfortran.dg/func_assign.f90: Likewise.
+ * gfortran.dg/implicit_11.f90: Likewise.
+ * gfortran.dg/proc_assign_1.f90: Likewise.
+ * gfortran.dg/proc_assign_2.f90: Likewise.
+ * gfortran.dg/procedure_lvalue.f90: Likewise.
+
2008-03-28 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/35699
--- /dev/null
+! { dg-do compile }
+!
+! PR fortran/34714 - ICE on invalid
+! Testcase contributed by Martin Reinecke <martin AT mpa-garching DOT mpg DOT de>
+!
+
+module foo
+ type bar
+ logical, pointer, dimension(:) :: baz
+ end type
+contains
+
+function func1()
+ type(bar) func1
+ allocate(func1%baz(1))
+end function
+
+function func2()
+ type(bar) func2
+ allocate(func1%baz(1)) ! { dg-error "is not a variable" }
+end function
+
+end module foo
+
+! { dg-final { cleanup-modules "foo" } }
end interface
real, pointer :: gain
integer, parameter :: res = 2
- allocate (gain,STAT=func2) ! { dg-error "STAT tag in ALLOCATE statement at .1. must be a variable" }
+ allocate (gain,STAT=func2) ! { dg-error "is not a variable" }
deallocate(gain)
end subroutine sub
end function one
subroutine sub()
integer, pointer :: p
- allocate(p, stat=one) ! { dg-error "STAT tag in ALLOCATE statement at .1. must be a variable" }
+ allocate(p, stat=one) ! { dg-error "is not a variable" }
if(associated(p)) deallocate(p)
- allocate(p, stat=two) ! { dg-error "STAT tag in ALLOCATE statement at .1. must be a variable" }
+ allocate(p, stat=two) ! { dg-error "is not a variable" }
if(associated(p)) deallocate(p)
end subroutine sub
end module test
end interface
sub = 'a' ! { dg-error "is not a variable" }
fun = 4.4 ! { dg-error "is not a variable" }
- funget = 4 ! { dg-error "is not a VALUE" }
- bar = 5 ! { dg-error "is not a VALUE" }
+ funget = 4 ! { dg-error "is not a variable" }
+ bar = 5 ! { dg-error "is not a variable" }
end subroutine a
end module mod
SUBROUTINE AD0001
REAL RLA1(:)
ALLOCATABLE RLA1
- ALLOCATE (RLA1(NF10), STAT = ISTAT2) ! { dg-error "must be a variable" }
+ ALLOCATE (RLA1(NF10), STAT = ISTAT2) ! { dg-error "is not a variable" }
END SUBROUTINE
END MODULE tests2
end subroutine foobar\r
end function foo\r
subroutine bar() ! This was the original bug.\r
- foo = 10 ! { dg-error "is not a VALUE" }\r
+ foo = 10 ! { dg-error "is not a variable" }\r
end subroutine bar\r
integer function oh_no ()\r
oh_no = 1\r
- foo = 5 ! { dg-error "is not a VALUE" }\r
+ foo = 5 ! { dg-error "is not a variable" }\r
end function oh_no\r
end module simple\r
\r
stmt_fcn (w) = sin (w) \r
call x (y ())\r
x = 10 ! { dg-error "is not a variable" }\r
- y = 20 ! { dg-error "is not a VALUE" }\r
- foo_er = 8 ! { dg-error "is not a VALUE" }\r
- ext1 = 99 ! { dg-error "is not a VALUE" }\r
- ext2 = 99 ! { dg-error "is not a VALUE" }\r
+ y = 20 ! { dg-error "is not a variable" }\r
+ foo_er = 8 ! { dg-error "is not a variable" }\r
+ ext1 = 99 ! { dg-error "is not a variable" }\r
+ ext2 = 99 ! { dg-error "is not a variable" }\r
stmt_fcn = 1.0 ! { dg-error "is not a variable" }\r
w = stmt_fcn (1.0)\r
contains\r
subroutine x (i)\r
integer i\r
- y = i ! { dg-error "is not a VALUE" }\r
+ y = i ! { dg-error "is not a variable" }\r
end subroutine x\r
function y ()\r
integer y\r
END FUNCTION
LOGICAL FUNCTION f2()
- f1 = .FALSE. ! { dg-error "not a VALUE" }
+ f1 = .FALSE. ! { dg-error "is not a variable" }
END FUNCTION
END FUNCTION
END MODULE
subroutine r
use t
- b = 1. ! { dg-error "is not a VALUE" }
+ b = 1. ! { dg-error "is not a variable" }
y = a(1.)
end subroutine r