From patchwork Sun Aug 11 06:53:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1145203 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-506642-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=gdcproject.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="gJVWCqUe"; 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 465qT76w2Zz9sN1 for ; Sun, 11 Aug 2019 16:54:01 +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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=FVT4YzQfieofL0iYBRaOhpJQOVXJItVpoqKCnw42idcb6O aTVF689K8Jzu2BMAIKV4gafPs9DjefuncvgkokBUjXhvzX+3XHNT60ClldnWTDoU T47ukOkcja0MbpQMaxzSoZ/Q8WdKZrRKRHzEZ8IuAwx5ZLHnsayGDH4j77On4= 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=gQQDGRqQZJQy96W8599TRoa5lUM=; b=gJVWCqUeOqcxNoVUad+v m90fL8mI6bKlvREsvWVCZrTI4vqvNrC01n+SVs4rg1ef9WA0SVxAQlcCbZY664jx TU6RL8DIjfs6p2Zu6fzOJNX0xGK1gXUvig5vEmSIUrOC5kCRk41PItJodY0y9omf Y9d6wqukU/LWqemx6zgD4ZE= Received: (qmail 37855 invoked by alias); 11 Aug 2019 06:53:53 -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 37798 invoked by uid 89); 11 Aug 2019 06:53:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qt1-f176.google.com Received: from mail-qt1-f176.google.com (HELO mail-qt1-f176.google.com) (209.85.160.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 11 Aug 2019 06:53:51 +0000 Received: by mail-qt1-f176.google.com with SMTP id x4so1886629qts.5 for ; Sat, 10 Aug 2019 23:53:50 -0700 (PDT) MIME-Version: 1.0 From: Iain Buclaw Date: Sun, 11 Aug 2019 08:53:37 +0200 Message-ID: Subject: [PATCH, PR d/90601] Committed fix for ICE: gimplification failed (gimplify.c at 13436) To: gcc-patches X-IsSubscribed: yes Hi, The expression that caused the ICE ++(a += 1.0); The D front-end rewrites and applies implicit type conversions so the expression gets simplified as (int)((double) a += 1.0) += 1 The codegen pass would subsequently generate the following invalid code (int)(double) a = (int)((double) a + 1.0) + 1 The LHS expression `(int)(double) a', represented as a FIX_TRUNC_EXPR being what trips as it is not a valid lvalue for assignment. While LHS casts are stripped away, convert_expr adds a double cast because it converts the expression to its original type before converting it to its target type. There is no valid reason why this is done, so it has been removed. Bootstrapped and regression tested on x86_64-linux-gnu. Committed to trunk as r274263. diff --git a/gcc/d/d-convert.cc b/gcc/d/d-convert.cc index b020eab902f..fd4fc3c692d 100644 --- a/gcc/d/d-convert.cc +++ b/gcc/d/d-convert.cc @@ -588,7 +588,6 @@ convert_expr (tree exp, Type *etype, Type *totype) return compound_expr (exp, build_zero_cst (build_ctype (tbtype))); } - exp = fold_convert (build_ctype (etype), exp); gcc_assert (TREE_CODE (exp) != STRING_CST); break; } diff --git a/gcc/testsuite/gdc.dg/pr90601.d b/gcc/testsuite/gdc.dg/pr90601.d new file mode 100644 index 00000000000..88cdaf8c99d --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr90601.d @@ -0,0 +1,22 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90601 +// { dg-do compile } + +int postincr(int a) +{ + return (a += 1.0)++; +} + +int postdecr(int a) +{ + return (a -= 1.0)--; +} + +int preincr(int a) +{ + return ++(a += 1.0); +} + +int predecr(int a) +{ + return --(a -= 1.0); +}