public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, fortran] Fix PR 82743, warning for truncation on constructors
@ 2019-01-01 18:42 Thomas Koenig
  2019-01-01 19:53 ` Steve Kargl
  2019-01-01 20:29 ` Bugs fixed in 2018 Steve Kargl
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Koenig @ 2019-01-01 18:42 UTC (permalink / raw)
  To: fortran; +Cc: gcc-patches

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

Hello world,

first of all, Happy New Year to everybody!

In 2018, we fixed 333 bugs, an average of 0.91 per day. Not bad at all.

Here is a first contribution towards reaching something similar, or even
better, for 2019.  It is a rather straightforward patch which adds a
missing warning for truncated strings in constructors.

Regression-tested. OK for trunk?

Regards

	Thomas

2019-01-01  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/82743
	* primary.c (gfc_convert_to_structure_constructor): If a character
	in a constructor is too long, add a warning with
	-Wcharacter-truncation.

2019-01-01  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/82743
	* gfortran.dg/structure_constructor_16.f90: New test.

[-- Attachment #2: p1.diff --]
[-- Type: text/x-patch, Size: 576 bytes --]

Index: primary.c
===================================================================
--- primary.c	(Revision 267335)
+++ primary.c	(Arbeitskopie)
@@ -3074,6 +3074,12 @@ gfc_convert_to_structure_constructor (gfc_expr *e,
 
 	      actual->expr->value.character.length = c;
 	      actual->expr->value.character.string = dest;
+
+	      if (warn_line_truncation && c < e)
+		gfc_warning_now (OPT_Wcharacter_truncation,
+				 "CHARACTER expression will be truncated "
+				 "in constructor (%ld/%ld) at %L", (long int) c,
+				 (long int) e, &actual->expr->where);
 	    }
 	}
 

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: structure_constructor_16.f90 --]
[-- Type: text/x-fortran; name="structure_constructor_16.f90", Size: 519 bytes --]

! { dg-do compile }
! { dg-additional-options "-Wcharacter-truncation" }
! PR 82743 - warnings were missing on truncation of structure
! constructors.
! Original test case by Simon Klüpfel
PROGRAM TEST
    TYPE A
        CHARACTER(LEN=1) :: C
    END TYPE A
    TYPE(A) :: A1
    A1=A("123") ! { dg-warning "CHARACTER expression will be truncated" }
    A1=A(C="123") ! { dg-warning "CHARACTER expression will be truncated" }
    A1%C="123" ! { dg-warning "CHARACTER expression will be truncated" }
END PROGRAM TEST

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

* Re: [patch, fortran] Fix PR 82743, warning for truncation on constructors
  2019-01-01 18:42 [patch, fortran] Fix PR 82743, warning for truncation on constructors Thomas Koenig
@ 2019-01-01 19:53 ` Steve Kargl
  2019-01-01 20:29 ` Bugs fixed in 2018 Steve Kargl
  1 sibling, 0 replies; 3+ messages in thread
From: Steve Kargl @ 2019-01-01 19:53 UTC (permalink / raw)
  To: Thomas Koenig; +Cc: fortran, gcc-patches

On Tue, Jan 01, 2019 at 07:42:14PM +0100, Thomas Koenig wrote:
> 
> first of all, Happy New Year to everybody!
> 
> In 2018, we fixed 333 bugs, an average of 0.91 per day. Not bad at all.
> 
> Here is a first contribution towards reaching something similar, or even
> better, for 2019.  It is a rather straightforward patch which adds a
> missing warning for truncated strings in constructors.
> 
> Regression-tested. OK for trunk?
> 
> Regards
> 
> 	Thomas
> 
> 2019-01-01  Thomas Koenig  <tkoenig@gcc.gnu.org>
> 
> 	PR fortran/82743
> 	* primary.c (gfc_convert_to_structure_constructor): If a character
> 	in a constructor is too long, add a warning with
> 	-Wcharacter-truncation.
> 
> 2019-01-01  Thomas Koenig  <tkoenig@gcc.gnu.org>
> 
> 	PR fortran/82743
> 	* gfortran.dg/structure_constructor_16.f90: New test.

Looks good to me.  Thanks for the patch.

-- 
Steve
20170425 https://www.youtube.com/watch?v=VWUpyCsUKR4
20161221 https://www.youtube.com/watch?v=IbCHE-hONow

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

* Bugs fixed in 2018
  2019-01-01 18:42 [patch, fortran] Fix PR 82743, warning for truncation on constructors Thomas Koenig
  2019-01-01 19:53 ` Steve Kargl
@ 2019-01-01 20:29 ` Steve Kargl
  1 sibling, 0 replies; 3+ messages in thread
From: Steve Kargl @ 2019-01-01 20:29 UTC (permalink / raw)
  To: Thomas Koenig; +Cc: fortran, gcc-patches

On Tue, Jan 01, 2019 at 07:42:14PM +0100, Thomas Koenig wrote:
> 
> In 2018, we fixed 333 bugs, an average of 0.91 per day. Not bad at all.
> 

Unfortunately, 468 bugs were submitted in 2018.  We need to 
get new and additional eyes looking at the source.  I don't
know how we do this as efforts in c.l.f to encourage others
to step are typically met with "I don't know C".

-- 
Steve

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

end of thread, other threads:[~2019-01-01 20:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-01 18:42 [patch, fortran] Fix PR 82743, warning for truncation on constructors Thomas Koenig
2019-01-01 19:53 ` Steve Kargl
2019-01-01 20:29 ` Bugs fixed in 2018 Steve Kargl

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).