From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23826 invoked by alias); 14 Jul 2016 15:21:28 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 23742 invoked by uid 89); 14 Jul 2016 15:21:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=COND_EXPR, cond_expr, strips, UD:typeck.c X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 14 Jul 2016 15:21:23 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4853C4AD5C; Thu, 14 Jul 2016 15:21:22 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-98.brq.redhat.com [10.40.204.98]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6EFLKxJ004556 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 14 Jul 2016 11:21:21 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u6EFLJIa028052; Thu, 14 Jul 2016 17:21:19 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u6EFLIp7028051; Thu, 14 Jul 2016 17:21:18 +0200 Date: Thu, 14 Jul 2016 15:21:00 -0000 From: Jakub Jelinek To: Jason Merrill , Marc Glisse Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix up vector cond expr handling in templates (PR c++/71871) Message-ID: <20160714152117.GH7387@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2016-07/txt/msg00840.txt.bz2 Hi! This patch reverts part of https://gcc.gnu.org/ml/gcc-patches/2012-10/msg01665.html which looks wrong to me. The problem is that in templates, if the build_x_conditional_expr arguments aren't type dependent, we might get NON_DEPENDENT_EXPR wrappers around the argument, so after issuing possibly needed diagnostics we need to return back to the original unmodified arguments, which for VEC_COND_EXPR the condition has been bypassing and we ended up with NON_DEPENDENT_EXPR in the IL, which nothing strips away (plus VEC_COND_EXPR isn't really supported in tsubst_copy/tsubst_copy_and_build and perhaps other spots). While we could do build_min_non_dep with VEC_COND_EXPR and teach pt.c about VEC_COND_EXPR, I really don't see advantages of doing that, if we build just COND_EXPR, build_min_non_dep ensures that it will have the right type, and when we instantiate it build_x_conditional_expr will be called again and that will create VEC_COND_EXPR when not processing_template_decl. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2016-07-14 Jakub Jelinek PR c++/71871 * typeck.c (build_x_conditional_expr): Revert the 2012-10-25 change. * g++.dg/ext/vector31.C: New test. --- gcc/cp/typeck.c.jj 2016-07-11 11:14:28.000000000 +0200 +++ gcc/cp/typeck.c 2016-07-14 12:47:48.436699222 +0200 @@ -6288,8 +6288,7 @@ build_x_conditional_expr (location_t loc } expr = build_conditional_expr (loc, ifexp, op1, op2, complain); - if (processing_template_decl && expr != error_mark_node - && TREE_CODE (expr) != VEC_COND_EXPR) + if (processing_template_decl && expr != error_mark_node) { tree min = build_min_non_dep (COND_EXPR, expr, orig_ifexp, orig_op1, orig_op2); --- gcc/testsuite/g++.dg/ext/vector31.C.jj 2016-07-14 13:01:04.933206583 +0200 +++ gcc/testsuite/g++.dg/ext/vector31.C 2016-07-14 13:00:59.943272143 +0200 @@ -0,0 +1,29 @@ +// PR c++/71871 +// { dg-do compile } + +typedef unsigned int V __attribute__ ((__vector_size__ (32))); + +template +void +foo (V *x) +{ + V a = *x; + a = a ? a : -1; + *x = a; +} + +template +void +bar (T *x) +{ + T a = *x; + a = a ? a : -1; + *x = a; +} + +void +test (V *x, V *y) +{ + foo<0> (x); + bar (y); +} Jakub