public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] [Ada] Make middle-end string literals NUL terminated
@ 2018-07-31 12:07 Bernd Edlinger
  2018-08-03 16:50 ` Olivier Hainque
  0 siblings, 1 reply; 41+ messages in thread
From: Bernd Edlinger @ 2018-07-31 12:07 UTC (permalink / raw)
  To: gcc-patches, Richard Biener, Eric Botcazou, Arnaud Charlet

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

Hi!


This fixes a couple STRING_CST that are not explicitly NUL terminated.
These were caught in a new check in varasm.c I am currently working on.

Having a NUL terminated string does not change the binary output, but it
makes things easier for he middle-end.


Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
Is it OK for trunk?


Thanks
Bernd.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-ada-strings.diff --]
[-- Type: text/x-patch; name="patch-ada-strings.diff", Size: 1347 bytes --]

2018-07-31  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* gcc-interface/trans.c (gnat_to_gnu): Make string literal properly
	NUL terminated.
	* gcc-interface/utils2.c (expand_sloc): Likewise.

diff -pur gcc/ada/gcc-interface/trans.c gcc/ada/gcc-interface/trans.c
--- gcc/ada/gcc-interface/trans.c	2018-07-17 10:10:04.000000000 +0200
+++ gcc/ada/gcc-interface/trans.c	2018-07-31 11:16:27.350728886 +0200
@@ -6079,7 +6079,7 @@ gnat_to_gnu (Node_Id gnat_node)
 	     where GCC will want to treat it as a C string.  */
 	  string[i] = 0;
 
-	  gnu_result = build_string (length, string);
+	  gnu_result = build_string (length + 1, string);
 
 	  /* Strings in GCC don't normally have types, but we want
 	     this to not be converted to the array type.  */
diff -pur gcc/ada/gcc-interface/utils2.c gcc/ada/gcc-interface/utils2.c
--- gcc/ada/gcc-interface/utils2.c	2017-12-21 07:57:41.000000000 +0100
+++ gcc/ada/gcc-interface/utils2.c	2018-07-31 11:44:01.517117923 +0200
@@ -1844,7 +1844,7 @@ expand_sloc (Node_Id gnat_node, tree *fi
     }
 
   const int len = strlen (str);
-  *filename = build_string (len, str);
+  *filename = build_string (len + 1, str);
   TREE_TYPE (*filename) = build_array_type (char_type_node,
 					    build_index_type (size_int (len)));
   *line = build_int_cst (NULL_TREE, line_number);

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

end of thread, other threads:[~2018-10-24  9:38 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-31 12:07 [PATCH] [Ada] Make middle-end string literals NUL terminated Bernd Edlinger
2018-08-03 16:50 ` Olivier Hainque
2018-08-03 18:38   ` Bernd Edlinger
2018-08-06 18:17     ` Olivier Hainque
2018-08-07 13:08       ` Bernd Edlinger
2018-08-07 16:41         ` Olivier Hainque
2018-08-07 17:10           ` Bernd Edlinger
2018-08-09 13:08             ` Olivier Hainque
2018-08-04 11:33   ` Bernd Edlinger
2018-08-04 15:43     ` [PATCH] Handle not explicitly zero terminated strings in merge sections Bernd Edlinger
2018-08-04 15:44       ` Bernd Edlinger
2018-08-04 16:06         ` Bernd Edlinger
2018-08-07 12:56           ` Bernd Edlinger
2018-08-17 17:35             ` Bernd Edlinger
2018-09-14 19:02               ` [PATCHv2] " Bernd Edlinger
2018-09-14 19:06                 ` Jakub Jelinek
2018-09-14 19:31                   ` Bernd Edlinger
2018-09-21 11:59                     ` Bernd Edlinger
2018-09-21 12:24                       ` Jakub Jelinek
2018-10-03 16:35                 ` Jeff Law
2018-10-09 13:07                   ` Bernd Edlinger
2018-10-10 18:25                     ` Jeff Law
2018-10-05 18:54                 ` Andreas Schwab
2018-10-05 20:00                   ` Bernd Edlinger
2018-10-08 11:22                     ` Rainer Orth
2018-10-08 13:00                       ` Rainer Orth
2018-10-08 15:42                       ` Bernd Edlinger
2018-10-09 13:08                         ` Rainer Orth
2018-10-22 18:26                           ` Bernd Edlinger
2018-10-22 18:29                             ` Rainer Orth
2018-10-08 22:16                       ` Eric Botcazou
2018-10-09 12:40                         ` Rainer Orth
2018-10-09 17:19                           ` Eric Botcazou
2018-10-10 12:23                             ` Rainer Orth
2018-10-10 15:05                               ` Eric Botcazou
2018-10-10 15:14                                 ` Rainer Orth
2018-10-23  8:36                                   ` Eric Botcazou
2018-10-23  8:37                                     ` Rainer Orth
2018-10-23  8:53                                       ` Eric Botcazou
2018-10-24 10:03                                         ` Rainer Orth
2018-10-24 11:08                                           ` Richard Biener

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