public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran] PR52101 Fix obsolescent warning
@ 2012-07-17  8:14 Tobias Burnus
  2012-07-17  9:04 ` Janus Weil
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Burnus @ 2012-07-17  8:14 UTC (permalink / raw)
  To: gcc patches, gfortran

[-- Attachment #1: Type: text/plain, Size: 453 bytes --]

gfortran warns (with -std=) for the obsolescence of
   character*5 ...
which is correct. However, it also warns when using
   character name*5
which is not (yet) obsolescent.

Fixed by the attached patch. In comment 5 you find Steve's version of 
the patch, which I only saw after writing my patch. The only difference 
seems to be the name of the parameter. Steve uses "entity_decl".

Build and regtested on x86-64-gnu-linux.
OK for the trunk?

Tobias

[-- Attachment #2: old-style-char.diff --]
[-- Type: text/x-patch, Size: 2233 bytes --]

2012-07-17  Tobias Burnus  <burnus@net-b.de>

	PR fortran/52101
	* decl.c (match_char_length): Extra argument, show obsolenscent
	warning only if *length is used after the typename.
	(variable_decl, gfc_match_char_spec): Update call

2012-07-17  Tobias Burnus  <burnus@net-b.de>

	PR fortran/52101
	* gfortran.dg/oldstyle_4.f90: New.

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index c3644b6..c6ba43e 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -723,7 +727,7 @@ syntax:
    char_len_param_value in parenthesis.  */
 
 static match
-match_char_length (gfc_expr **expr, bool *deferred)
+match_char_length (gfc_expr **expr, bool *deferred, bool obsolenscent_check)
 {
   int length;
   match m;
@@ -739,8 +743,9 @@ match_char_length (gfc_expr **expr, bool *deferred)
 
   if (m == MATCH_YES)
     {
-      if (gfc_notify_std (GFC_STD_F95_OBS, "Obsolescent feature: "
-			  "Old-style character length at %C") == FAILURE)
+      if (obsolenscent_check
+	  && gfc_notify_std (GFC_STD_F95_OBS, "Obsolescent feature: "
+			     "Old-style character length at %C") == FAILURE)
 	return MATCH_ERROR;
       *expr = gfc_get_int_expr (gfc_default_integer_kind, NULL, length);
       return m;
@@ -1849,7 +1854,7 @@ variable_decl (int elem)
 
   if (current_ts.type == BT_CHARACTER)
     {
-      switch (match_char_length (&char_len, &cl_deferred))
+      switch (match_char_length (&char_len, &cl_deferred, false))
 	{
 	case MATCH_YES:
 	  cl = gfc_new_charlen (gfc_current_ns, NULL);
@@ -2411,7 +2416,7 @@ gfc_match_char_spec (gfc_typespec *ts)
   /* Try the old-style specification first.  */
   old_char_selector = 0;
 
-  m = match_char_length (&len, &deferred);
+  m = match_char_length (&len, &deferred, true);
   if (m != MATCH_NO)
     {
       if (m == MATCH_YES)
--- /dev/null	2012-07-17 07:28:04.995717470 +0200
+++ gcc/gcc/testsuite/gfortran.dg/oldstyle_4.f90	2012-07-17 08:49:00.000000000 +0200
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! { dg-options "-std=f95" }
+!
+! PR fortran/52101
+!
+! Contributed by John Harper
+!
+program foo
+   character*10 s    ! { dg-warning "Obsolescent feature: Old-style character length" }
+   character    t*10 ! Still okay
+   s = 'foo'
+   t = 'bar'
+end program foo

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch, Fortran] PR52101 Fix obsolescent warning
  2012-07-17  8:14 [Patch, Fortran] PR52101 Fix obsolescent warning Tobias Burnus
@ 2012-07-17  9:04 ` Janus Weil
  0 siblings, 0 replies; 2+ messages in thread
From: Janus Weil @ 2012-07-17  9:04 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc patches, gfortran

Hi,

> gfortran warns (with -std=) for the obsolescence of
>   character*5 ...
> which is correct. However, it also warns when using
>   character name*5
> which is not (yet) obsolescent.
>
> Fixed by the attached patch. In comment 5 you find Steve's version of the
> patch, which I only saw after writing my patch. The only difference seems to
> be the name of the parameter. Steve uses "entity_decl".
>
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?

I think this is also ok (and close to obvious). Thanks!

Btw, I am about to commit a cleanup patch regarding gfc_notify_std
(any minute now) ...

Cheers,
Janus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-17  9:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-17  8:14 [Patch, Fortran] PR52101 Fix obsolescent warning Tobias Burnus
2012-07-17  9:04 ` Janus Weil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).