aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSteven G. Kargl <kargl@gcc.gnu.org>2019-06-27 17:52:00 +0000
committerSteven G. Kargl <kargl@gcc.gnu.org>2019-06-27 17:52:00 +0000
commitc2fe65930a4b48017042e49516eb338c9e241e53 (patch)
treeb33219a6ab48866b7456403126706057e7cab1e1 /gcc
parent76715c3216cf6ccd071fc852920af55d6b0054ae (diff)
downloadgcc-c2fe65930a4b48017042e49516eb338c9e241e53.zip
gcc-c2fe65930a4b48017042e49516eb338c9e241e53.tar.gz
gcc-c2fe65930a4b48017042e49516eb338c9e241e53.tar.bz2
re PR fortran/90987 (Wrong error message with variables named "COMMON*")
2019-06-27 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/90987 * match.c (gfc_match_common): Adjust parsing of fixed and free form source code containing, e.g., COMMONI. 2019-06-27 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/90987 * gfortran.dg/common_1.f: new test. * gfortran.dg/common_26.f90: Ditto. From-SVN: r272756
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog8
-rw-r--r--gcc/fortran/match.c28
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/gfortran.dg/common_1.f14
-rw-r--r--gcc/testsuite/gfortran.dg/common_26.f9014
5 files changed, 67 insertions, 5 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 65a2578..699b072 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,7 +1,13 @@
+2019-06-27 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/90987
+ * gfortran.dg/common_1.f: new test.
+ * gfortran.dg/common_26.f90: Ditto.
+
2019-06-26 Steven G. Kargl <kargl@gcc.gnu.org>
PR Fortran/90988
- ChangeLog forgotten with revision 272698
+ ChangeLog forgotten with revision 272667
* decl.c (access_attr_decl): Use temporary variable to reduce
unreadability of code. Normalize jumping to return.
(gfc_match_protected): Fix parsing error. Add comments to
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 1c08da7..0f3b213 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -5115,6 +5115,14 @@ gfc_match_common (void)
gfc_array_spec *as;
gfc_equiv *e1, *e2;
match m;
+ char c;
+
+ /* COMMON has been matched. In free form source code, the next character
+ needs to be whitespace or '/'. Check that here. Fixed form source
+ code needs to be checked below. */
+ c = gfc_peek_ascii_char ();
+ if (gfc_current_form == FORM_FREE && !gfc_is_whitespace (c) && c != '/')
+ return MATCH_NO;
as = NULL;
@@ -5279,10 +5287,24 @@ gfc_match_common (void)
gfc_gobble_whitespace ();
if (gfc_match_eos () == MATCH_YES)
goto done;
- if (gfc_peek_ascii_char () == '/')
+ c = gfc_peek_ascii_char ();
+ if (c == '/')
break;
- if (gfc_match_char (',') != MATCH_YES)
- goto syntax;
+ if (c != ',')
+ {
+ /* In Fixed form source code, gfortran can end up here for an
+ expression of the form COMMONI = RHS. This may not be an
+ error, so return MATCH_NO. */
+ if (gfc_current_form == FORM_FIXED && c == '=')
+ {
+ gfc_free_array_spec (as);
+ return MATCH_NO;
+ }
+ goto syntax;
+ }
+ else
+ gfc_match_char (',');
+
gfc_gobble_whitespace ();
if (gfc_peek_ascii_char () == '/')
break;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 250efa3..57aeaa3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2019-06-27 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/90987
+ * match.c (gfc_match_common): Adjust parsing of fixed and free form
+ source code containing, e.g., COMMONI.
+
2019-06-27 Jan Hubicka <jh@suse.cz>
* g++.dg/lto/alias-2_0.C: New testcase.
@@ -63,7 +69,7 @@
2019-06-26 Steven G. Kargl <kargl@gcc.gnu.org>
PR Fortran/90988
- ChangeLog forgotten with revision 272698
+ ChangeLog forgotten with revision 272667
* gfortran.dg/pr90988_1.f90: New test.
* gfortran.dg/pr90988_2.f90: Ditto.
* gfortran.dg/pr90988_3.f90: Ditto.
diff --git a/gcc/testsuite/gfortran.dg/common_1.f b/gcc/testsuite/gfortran.dg/common_1.f
new file mode 100644
index 0000000..2c5e96a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/common_1.f
@@ -0,0 +1,14 @@
+! { dg-do compile }
+ module mymod
+ type :: mytyp
+ integer :: i
+ end type mytyp
+ contains
+ subroutine mysub
+ implicit none
+ type(mytyp) :: a
+ integer :: commoni,commonj
+ commoni = a%i
+ commonj = a%j ! { dg-error "is not a member of" }
+ end subroutine mysub
+ end module mymod
diff --git a/gcc/testsuite/gfortran.dg/common_26.f90 b/gcc/testsuite/gfortran.dg/common_26.f90
new file mode 100644
index 0000000..5834d7c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/common_26.f90
@@ -0,0 +1,14 @@
+! { dg-do compile }
+module mymod
+ type :: mytyp
+ integer :: i
+ end type mytyp
+contains
+ subroutine mysub
+ implicit none
+ type(mytyp) :: a
+ integer :: commoni,commonj
+ commoni = a%i
+ commonj = a%j ! { dg-error "is not a member of" }
+ end subroutine mysub
+end module mymod