From patchwork Mon Mar 19 19:50:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 887856 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-474960-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="AeLbunp6"; 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 404ms115R8z9sVM for ; Tue, 20 Mar 2018 06:50:59 +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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=kUV+yNc0oQVjkTHJPuVtVG8wFFLC5 7vCq8mAzpblsDn9/HNZwMjj7bwIoA5/LlyS8DqnQ3I76TTZAEqiiG0Sl8918HscL 3ZibPOTiw9x77cuAbu6vU/H7VrMoxQhNRjHqitIF5IrLYZqEfC2C1m0zfQiaIDP6 +0Z1oMIpGq/Ic8= 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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=AQpfMu8cnusA1A4gEIdIaf9M4q4=; b=AeL bunp6LY8d/2Nfyk+jHp/N0ECTFTCL78jLYdO7ZDWgPyVjKH3676o+Z0tSLZ7esWn YhJAZK86ATxVGqRB7Su51YGRvGCy2vpCU9xqn5ohnF3VlR9tKSXgj0mhxgVMTFdZ hW3jsKAbeilUVufZKRAWf5KbH4hJwxMEm+49+nS0= Received: (qmail 44900 invoked by alias); 19 Mar 2018 19:50:52 -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 44890 invoked by uid 89); 19 Mar 2018 19:50:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 19 Mar 2018 19:50:51 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 195896166C for ; Mon, 19 Mar 2018 19:50:45 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.36.118.110]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C94EA10B0F4C; Mon, 19 Mar 2018 19:50:44 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id w2JJog55018885; Mon, 19 Mar 2018 20:50:43 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w2JJogMU018884; Mon, 19 Mar 2018 20:50:42 +0100 Date: Mon, 19 Mar 2018 20:50:41 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix FIX_TRUNC_EXPR instantiation (PR c++/84942) Message-ID: <20180319195041.GR8577@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes Hi! We instantiate FIX_TRUNC_EXPR using cp_build_unary_op, but that function doesn't look like a good match for this tree, what it really does for it is: 1) handle error_operand_p 2) on ia64 only diagnose __fpreg uses (I believe a cast of __fpreg to int is fine, so we shouldn't warn) 3) and then it does: argtype = TREE_TYPE (arg); return build1 (code, argtype, arg); which creates FIX_TRUNC_EXPR with the type of the argument rather than the integral type it should have. The following patch thus bypasses that function and just builds the FIX_TRUNC_EXPR with the right type. I think we don't need to tsubst the type, because if it is type dependent, we wouldn't be creating FIX_TRUNC_EXPR, but record it just as a some kind of conversion. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-03-19 Jakub Jelinek PR c++/84942 * pt.c (tsubst_copy_and_build) : Don't call cp_build_unary_op, just use build1. * g++.dg/cpp1y/pr84942.C: New test. Jakub --- gcc/cp/pt.c.jj 2018-03-16 21:11:04.440773108 +0100 +++ gcc/cp/pt.c 2018-03-19 10:58:39.803657613 +0100 @@ -17495,8 +17495,10 @@ tsubst_copy_and_build (tree t, complain|decltype_flag)); case FIX_TRUNC_EXPR: - RETURN (cp_build_unary_op (FIX_TRUNC_EXPR, RECUR (TREE_OPERAND (t, 0)), - false, complain)); + op1 = RECUR (TREE_OPERAND (t, 0)); + if (error_operand_p (op1)) + RETURN (error_mark_node); + RETURN (build1 (FIX_TRUNC_EXPR, TREE_TYPE (t), op1)); case ADDR_EXPR: op1 = TREE_OPERAND (t, 0); --- gcc/testsuite/g++.dg/cpp1y/pr84942.C.jj 2018-03-19 11:04:16.201588211 +0100 +++ gcc/testsuite/g++.dg/cpp1y/pr84942.C 2018-03-19 11:02:37.950609950 +0100 @@ -0,0 +1,7 @@ +// PR c++/84942 +// { dg-do compile { target c++14 } } +// { dg-options "-w" } + +int a(__attribute__((b((int)__builtin_inf() * 1ULL / auto)))); +// { dg-error "expected primary-expression before" "" { target *-*-* } .-1 } +// { dg-error "declared as implicit template" "" { target *-*-* } .-2 }