From patchwork Tue Nov 21 06:14:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 839909 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-467507-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="TBO/jW6O"; 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 3ygwKt072Rz9ryk for ; Tue, 21 Nov 2017 17:14:56 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=UXUlt4CpJ8JDqsgF7yzzzRNLsWsNRkHVAkJKA2bo7XicrL nQ5sxkYHEb4Vl416V5pqhg3RyMB6AN9x/sQRz0mbQ+bwe84FSI9Zs975p6yVDGT/ RKVsx+j4ZqQa18eTSJNYOkX9qz33sp73IrgunIro26Zdh1Lp533BdTQkwHtR4= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=wN7IMEJWDSOrfErRPdNP2aNHizE=; b=TBO/jW6OvZua8c3tvf1Y BikL4HYmWnrPZK/7IO6VKNSL3hRJgxeEEzHv8PPItxy3ilZfNYK99U23CsRkfdbB R2QxfprvZlf2qU5dL9ttb9FgYwjZKoxZi+Dd6TxuEmcI25TiUlwzgGL1kh+BKWxW 9h6MRVkHPapjD4QpvXnSZKI= Received: (qmail 88033 invoked by alias); 21 Nov 2017 06:14:47 -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 88020 invoked by uid 89); 21 Nov 2017 06:14:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=HTo:D*googlegroups.com, nonnumeric, H*r:10.80.179, UD:statements.cc X-HELO: mail-wm0-f45.google.com Received: from mail-wm0-f45.google.com (HELO mail-wm0-f45.google.com) (74.125.82.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Nov 2017 06:14:45 +0000 Received: by mail-wm0-f45.google.com with SMTP id x63so845177wmf.4 for ; Mon, 20 Nov 2017 22:14:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=7TLaUOkxG7o19nxEDrrKMqvbpIfyXIIuPZRFTMXJGQU=; b=Jx2sszmRtmEAVoviAbyUCGKiQoYo5Pc7PQsWtENRll5pnlDQs2PvGfe0dL1Amoq8rB slaqzx1XuEDcJSTFuEMEZIe+mYONKgHC5YLEEKgkw+0CaUGwZl+d57fTAbSTDlgAvo2H JHvsTsJeop7Y7T3DyEe5mNMEP27RQCEGrE5738YEffJX5qkFYH1LMcgp7MBuDhZHZKRn lzd5jl4eeHnTdUZf/93/tZrZpJ7NWymybu9jrG7cnh74MqO8UjmRkMaQTwbX1uFy5tw+ CE3gewwfdcC8xakpgaszYiG0UssHkQMdz4Le5u3F26yMw322Kt0L4iD4CTpLhGB4pwN5 H0kw== X-Gm-Message-State: AJaThX7ZebL0M4ZINd4nmSh1M09Lz8dSqYkzS0Z7TjSzI3QEtZWlxEHU Davl4wXjiWX9d+OakbIL6+TIw0WIos0ZNmQ6B5ZvSg== X-Google-Smtp-Source: AGs4zMYNiVaZV23VMODgYMu5xrx5FU/+BWj36sWDEDxU/qPLPtilTMs4f7fKUk6y4X4322GstmFbXR6NH8rmx/CGrSM= X-Received: by 10.80.221.11 with SMTP id t11mr22912418edk.84.1511244883419; Mon, 20 Nov 2017 22:14:43 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.179.240 with HTTP; Mon, 20 Nov 2017 22:14:42 -0800 (PST) From: Ian Lance Taylor Date: Mon, 20 Nov 2017 22:14:42 -0800 Message-ID: Subject: Go patch committed: report error for ++/-- applied to a non-numeric type To: gcc-patches , "gofrontend-dev@googlegroups.com" This patch to the Go frontend reports an error when ++ or -- is used with a non-numeric type. This avoids a later compiler crash. This fixes GCC PR 83071. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 254748) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -cb5dc1ce98857884a2215c461dd1d7de530f9f5e +5485b3faed476f6d051833d1790b5f77be9d1efc The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: gcc/go/gofrontend/statements.cc =================================================================== --- gcc/go/gofrontend/statements.cc (revision 254748) +++ gcc/go/gofrontend/statements.cc (working copy) @@ -1826,6 +1826,11 @@ Statement* Inc_dec_statement::do_lower(Gogo*, Named_object*, Block*, Statement_inserter*) { Location loc = this->location(); + if (!this->expr_->type()->is_numeric_type()) + { + this->report_error("increment or decrement of non-numeric type"); + return Statement::make_error_statement(loc); + } Expression* oexpr = Expression::make_integer_ul(1, this->expr_->type(), loc); Operator op = this->is_inc_ ? OPERATOR_PLUSEQ : OPERATOR_MINUSEQ; return Statement::make_assignment_operation(op, this->expr_, oexpr, loc);