Commit 13001f33 by Janus Weil

re PR fortran/49638 ([OOP] length parameter is ignored when overriding type…

re PR fortran/49638 ([OOP] length parameter is ignored when overriding type bound character functions with constant length.)

2011-08-20  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/49638
	* dependency.c (gfc_dep_compare_expr): Add new result value "-3".
	(gfc_check_element_vs_section,gfc_check_element_vs_element): Handle
	result value "-3".
        * frontend-passes.c (optimize_comparison): Ditto.
	* interface.c (gfc_check_typebound_override): Ditto.


2011-08-20  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/49638
	* gfortran.dg/typebound_override_1.f90: Modified.

From-SVN: r177932
parent 894113c3
2011-08-20 Janus Weil <janus@gcc.gnu.org>
PR fortran/49638
* dependency.c (gfc_dep_compare_expr): Add new result value "-3".
(gfc_check_element_vs_section,gfc_check_element_vs_element): Handle
result value "-3".
* frontend-passes.c (optimize_comparison): Ditto.
* interface.c (gfc_check_typebound_override): Ditto.
2011-08-19 Mikael Morin <mikael.morin@sfr.fr> 2011-08-19 Mikael Morin <mikael.morin@sfr.fr>
PR fortran/50129 PR fortran/50129
......
...@@ -230,8 +230,12 @@ gfc_dep_compare_functions (gfc_expr *e1, gfc_expr *e2, bool impure_ok) ...@@ -230,8 +230,12 @@ gfc_dep_compare_functions (gfc_expr *e1, gfc_expr *e2, bool impure_ok)
return -2; return -2;
} }
/* Compare two values. Returns 0 if e1 == e2, -1 if e1 < e2, +1 if e1 > e2, /* Compare two expressions. Return values:
and -2 if the relationship could not be determined. */ * +1 if e1 > e2
* 0 if e1 == e2
* -1 if e1 < e2
* -2 if the relationship could not be determined
* -3 if e1 /= e2, but we cannot tell which one is larger. */
int int
gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2) gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2)
...@@ -304,9 +308,9 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2) ...@@ -304,9 +308,9 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2)
r = gfc_dep_compare_expr (e1->value.op.op2, e2->value.op.op2); r = gfc_dep_compare_expr (e1->value.op.op2, e2->value.op.op2);
if (l == 0 && r == 0) if (l == 0 && r == 0)
return 0; return 0;
if (l == 0 && r != -2) if (l == 0 && r > -2)
return r; return r;
if (l != -2 && r == 0) if (l > -2 && r == 0)
return l; return l;
if (l == 1 && r == 1) if (l == 1 && r == 1)
return 1; return 1;
...@@ -317,9 +321,9 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2) ...@@ -317,9 +321,9 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2)
r = gfc_dep_compare_expr (e1->value.op.op2, e2->value.op.op1); r = gfc_dep_compare_expr (e1->value.op.op2, e2->value.op.op1);
if (l == 0 && r == 0) if (l == 0 && r == 0)
return 0; return 0;
if (l == 0 && r != -2) if (l == 0 && r > -2)
return r; return r;
if (l != -2 && r == 0) if (l > -2 && r == 0)
return l; return l;
if (l == 1 && r == 1) if (l == 1 && r == 1)
return 1; return 1;
...@@ -354,9 +358,9 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2) ...@@ -354,9 +358,9 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2)
r = gfc_dep_compare_expr (e1->value.op.op2, e2->value.op.op2); r = gfc_dep_compare_expr (e1->value.op.op2, e2->value.op.op2);
if (l == 0 && r == 0) if (l == 0 && r == 0)
return 0; return 0;
if (l != -2 && r == 0) if (l > -2 && r == 0)
return l; return l;
if (l == 0 && r != -2) if (l == 0 && r > -2)
return -r; return -r;
if (l == 1 && r == -1) if (l == 1 && r == -1)
return 1; return 1;
...@@ -375,8 +379,8 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2) ...@@ -375,8 +379,8 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2)
l = gfc_dep_compare_expr (e1->value.op.op1, e2->value.op.op1); l = gfc_dep_compare_expr (e1->value.op.op1, e2->value.op.op1);
r = gfc_dep_compare_expr (e1->value.op.op2, e2->value.op.op2); r = gfc_dep_compare_expr (e1->value.op.op2, e2->value.op.op2);
if (l == -2) if (l <= -2)
return -2; return l;
if (l == 0) if (l == 0)
{ {
...@@ -387,7 +391,7 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2) ...@@ -387,7 +391,7 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2)
if (e1_left->expr_type == EXPR_CONSTANT if (e1_left->expr_type == EXPR_CONSTANT
&& e2_left->expr_type == EXPR_CONSTANT && e2_left->expr_type == EXPR_CONSTANT
&& e1_left->value.character.length && e1_left->value.character.length
!= e2_left->value.character.length) != e2_left->value.character.length)
return -2; return -2;
else else
return r; return r;
...@@ -411,7 +415,7 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2) ...@@ -411,7 +415,7 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2)
} }
if (e1->expr_type != e2->expr_type) if (e1->expr_type != e2->expr_type)
return -2; return -3;
switch (e1->expr_type) switch (e1->expr_type)
{ {
...@@ -434,7 +438,7 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2) ...@@ -434,7 +438,7 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2)
if (are_identical_variables (e1, e2)) if (are_identical_variables (e1, e2))
return 0; return 0;
else else
return -2; return -3;
case EXPR_OP: case EXPR_OP:
/* Intrinsic operators are the same if their operands are the same. */ /* Intrinsic operators are the same if their operands are the same. */
...@@ -1406,7 +1410,7 @@ gfc_check_element_vs_section( gfc_ref *lref, gfc_ref *rref, int n) ...@@ -1406,7 +1410,7 @@ gfc_check_element_vs_section( gfc_ref *lref, gfc_ref *rref, int n)
if (!start || !end) if (!start || !end)
return GFC_DEP_OVERLAP; return GFC_DEP_OVERLAP;
s = gfc_dep_compare_expr (start, end); s = gfc_dep_compare_expr (start, end);
if (s == -2) if (s <= -2)
return GFC_DEP_OVERLAP; return GFC_DEP_OVERLAP;
/* Assume positive stride. */ /* Assume positive stride. */
if (s == -1) if (s == -1)
...@@ -1553,7 +1557,7 @@ gfc_check_element_vs_element (gfc_ref *lref, gfc_ref *rref, int n) ...@@ -1553,7 +1557,7 @@ gfc_check_element_vs_element (gfc_ref *lref, gfc_ref *rref, int n)
if (contains_forall_index_p (r_start) || contains_forall_index_p (l_start)) if (contains_forall_index_p (r_start) || contains_forall_index_p (l_start))
return GFC_DEP_OVERLAP; return GFC_DEP_OVERLAP;
if (i != -2) if (i > -2)
return GFC_DEP_NODEP; return GFC_DEP_NODEP;
return GFC_DEP_EQUAL; return GFC_DEP_EQUAL;
} }
......
...@@ -682,7 +682,7 @@ optimize_comparison (gfc_expr *e, gfc_intrinsic_op op) ...@@ -682,7 +682,7 @@ optimize_comparison (gfc_expr *e, gfc_intrinsic_op op)
&& op1->ts.type != BT_COMPLEX && op2->ts.type != BT_COMPLEX)) && op1->ts.type != BT_COMPLEX && op2->ts.type != BT_COMPLEX))
{ {
eq = gfc_dep_compare_expr (op1, op2); eq = gfc_dep_compare_expr (op1, op2);
if (eq == -2) if (eq <= -2)
{ {
/* Replace A // B < A // C with B < C, and A // B < C // B /* Replace A // B < A // C with B < C, and A // B < C // B
with A < C. */ with A < C. */
......
...@@ -3574,7 +3574,8 @@ gfc_check_typebound_override (gfc_symtree* proc, gfc_symtree* old) ...@@ -3574,7 +3574,8 @@ gfc_check_typebound_override (gfc_symtree* proc, gfc_symtree* old)
switch (compval) switch (compval)
{ {
case -1: case -1:
case 1: case 1:
case -3:
gfc_error ("Character length mismatch between '%s' at '%L' and " gfc_error ("Character length mismatch between '%s' at '%L' and "
"overridden FUNCTION", proc->name, &where); "overridden FUNCTION", proc->name, &where);
return FAILURE; return FAILURE;
......
2011-08-20 Janus Weil <janus@gcc.gnu.org>
PR fortran/49638
* gfortran.dg/typebound_override_1.f90: Modified.
2011-08-20 Jakub Jelinek <jakub@redhat.com> 2011-08-20 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/48739 PR tree-optimization/48739
......
...@@ -23,7 +23,7 @@ module m ...@@ -23,7 +23,7 @@ module m
procedure, nopass :: b => b2 ! { dg-error "should have matching result types and ranks" } procedure, nopass :: b => b2 ! { dg-error "should have matching result types and ranks" }
procedure, nopass :: c => c2 ! { dg-warning "Possible character length mismatch" } procedure, nopass :: c => c2 ! { dg-warning "Possible character length mismatch" }
procedure, nopass :: d => d2 ! valid, check for commutativity (+,*) procedure, nopass :: d => d2 ! valid, check for commutativity (+,*)
procedure, nopass :: e => e2 ! { dg-warning "Possible character length mismatch" } procedure, nopass :: e => e2 ! { dg-error "Character length mismatch" }
end type end type
contains contains
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment