Commit d0497a65 by Steven G. Kargl Committed by Steven G. Kargl

re PR fortran/25078 (EQUILALENCE requires two or more objects)

        PR fortran/25078
        * match.c (gfc_match_equivalence):  Count number of objects.

        gfortran.dg/equiv_5.f90:  New test.

From-SVN: r108426
parent 0e0ed594
2005-12-12 Steven G. Kargl <kargls@comcast.net>
PR fortran/25078
* match.c (gfc_match_equivalence): Count number of objects.
2005-12-11 Aldy Hernandez <aldyh@redhat.com> 2005-12-11 Aldy Hernandez <aldyh@redhat.com>
* lang.opt: Add RejectNegative to ffixed-form and ffree-form. * lang.opt: Add RejectNegative to ffixed-form and ffree-form.
......
...@@ -2599,6 +2599,7 @@ gfc_match_equivalence (void) ...@@ -2599,6 +2599,7 @@ gfc_match_equivalence (void)
match m; match m;
gfc_common_head *common_head = NULL; gfc_common_head *common_head = NULL;
bool common_flag; bool common_flag;
int cnt;
tail = NULL; tail = NULL;
...@@ -2616,6 +2617,7 @@ gfc_match_equivalence (void) ...@@ -2616,6 +2617,7 @@ gfc_match_equivalence (void)
set = eq; set = eq;
common_flag = FALSE; common_flag = FALSE;
cnt = 0;
for (;;) for (;;)
{ {
...@@ -2625,6 +2627,9 @@ gfc_match_equivalence (void) ...@@ -2625,6 +2627,9 @@ gfc_match_equivalence (void)
if (m == MATCH_NO) if (m == MATCH_NO)
goto syntax; goto syntax;
/* count the number of objects. */
cnt++;
if (gfc_match_char ('%') == MATCH_YES) if (gfc_match_char ('%') == MATCH_YES)
{ {
gfc_error ("Derived type component %C is not a " gfc_error ("Derived type component %C is not a "
...@@ -2655,6 +2660,7 @@ gfc_match_equivalence (void) ...@@ -2655,6 +2660,7 @@ gfc_match_equivalence (void)
if (gfc_match_char (')') == MATCH_YES) if (gfc_match_char (')') == MATCH_YES)
break; break;
if (gfc_match_char (',') != MATCH_YES) if (gfc_match_char (',') != MATCH_YES)
goto syntax; goto syntax;
...@@ -2662,6 +2668,12 @@ gfc_match_equivalence (void) ...@@ -2662,6 +2668,12 @@ gfc_match_equivalence (void)
set = set->eq; set = set->eq;
} }
if (cnt < 2)
{
gfc_error ("EQUIVALENCE at %C requires two or more objects");
goto cleanup;
}
/* If one of the members of an equivalence is in common, then /* If one of the members of an equivalence is in common, then
mark them all as being in common. Before doing this, check mark them all as being in common. Before doing this, check
that members of the equivalence group are not in different that members of the equivalence group are not in different
......
2005-12-12 Steven G. Kargl <kargls@comcast.net>
PR fortran/25078
gfortran.dg/equiv_5.f90: New test.
2005-12-12 Daniel Berlin <dberlin@dberlin.org> 2005-12-12 Daniel Berlin <dberlin@dberlin.org>
* gcc.dg/tree-ssa/ssa-pre-2.c: Update due to reassociation changes. * gcc.dg/tree-ssa/ssa-pre-2.c: Update due to reassociation changes.
! { dg-do compile }
! PR fortran/25078
! An equivalence statement requires two or more objcets.
program a
real x
equivalence(x) ! { dg-error "two or more objects" }
end program a
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