From patchwork Tue Jul 31 12:07:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 951570 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-482732-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="qCUCZlEl"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41fwDc4BbNz9s2g for ; Tue, 31 Jul 2018 22:07:44 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type:mime-version; q=dns; s= default; b=ltaCd74d9H2b8kc+epKqZUT26A6aUCSGEL6ZUWLPdH9Y7AONk2MFU 5ewCjPMGHwJTPIYeDMA/RjOSTOkhyxnxuZltpRzLDvEu0fqTwbxeD4WSxNyFmKae /4RpUxN8Z1BHMwEyb5k2E/Y7cgbF86ac8a5pQQs/7TYK59yz1cmKAY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type:mime-version; s= default; bh=GNGonkTrArlJ1fuauub7vpSjLgA=; b=qCUCZlElQF1JJLcZmm6r aaHvPSAssNNBn+5gg227xqF0HivOQPHD+s6Qf9s6sionf7BN9C7uUfaz/1NIw7DN pbIWH2OS/M/3+49LIkJak0JqCkn8VR9MxY9zoUJtf5nmGCg4X84xZ+/2RrlYKXt7 tWX+JiYAw8pnEU+jZzxLZII= Received: (qmail 84338 invoked by alias); 31 Jul 2018 12:07:35 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 84190 invoked by uid 89); 31 Jul 2018 12:07:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: EUR03-DB5-obe.outbound.protection.outlook.com Received: from mail-oln040092071033.outbound.protection.outlook.com (HELO EUR03-DB5-obe.outbound.protection.outlook.com) (40.92.71.33) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 31 Jul 2018 12:07:32 +0000 Received: from AM5EUR03FT051.eop-EUR03.prod.protection.outlook.com (10.152.16.54) by AM5EUR03HT221.eop-EUR03.prod.protection.outlook.com (10.152.17.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.1017.14; Tue, 31 Jul 2018 12:07:29 +0000 Received: from AM5PR0701MB2657.eurprd07.prod.outlook.com (10.152.16.55) by AM5EUR03FT051.mail.protection.outlook.com (10.152.16.246) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.1038.3 via Frontend Transport; Tue, 31 Jul 2018 12:07:29 +0000 Received: from AM5PR0701MB2657.eurprd07.prod.outlook.com ([fe80::b1fe:1b4f:88c3:5243]) by AM5PR0701MB2657.eurprd07.prod.outlook.com ([fe80::b1fe:1b4f:88c3:5243%9]) with mapi id 15.20.1017.010; Tue, 31 Jul 2018 12:07:29 +0000 From: Bernd Edlinger To: "gcc-patches@gcc.gnu.org" , Richard Biener , Eric Botcazou , Arnaud Charlet Subject: [PATCH] [Ada] Make middle-end string literals NUL terminated Date: Tue, 31 Jul 2018 12:07:29 +0000 Message-ID: received-spf: None (protection.outlook.com: hotmail.de does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=bernd.edlinger@hotmail.de; MIME-Version: 1.0 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. 2018-07-31 Bernd Edlinger * 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);