From patchwork Fri May 15 09:59:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Glisse X-Patchwork-Id: 472708 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 AA2A8140283 for ; Fri, 15 May 2015 19:59:12 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=dLfmhgge; dkim-atps=neutral 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:subject:message-id:mime-version:content-type; q=dns; s= default; b=gYwp00dvURHy3AjsAfX2ZsC9OLQ1MGnRFJTCNqrkHrQLYScutY7Ax RH7hcH6jwxbUSXW9S9glNElolEPpMBq/+KzmzAqHlsw+70M+62JMgwT9ZqR5CoBb OJ5uGQOaKfkTOFkJNclUBbFD574GnhA1Ai8L71hjp/B72R1vFR5uoU= 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:subject:message-id:mime-version:content-type; s= default; bh=eaeZ3BKxcMOMj/DfGEfcplaerHI=; b=dLfmhggeO2VBCLTSOyN1 DFH8GBnW+vjeAbD2Fejnugl4mTvq13MiL4Qf7fX+yLv6TZdJSu0Xv/+219ebdNDb vSpzFhITL9V3V+4CMdNuE9I0ms8ywiG0jeiUtyvTKlfSXWl/21RcTg2tnmTnskYS YFimAZXE0bzykcmAqTYmzhU= Received: (qmail 1279 invoked by alias); 15 May 2015 09:59:05 -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 1248 invoked by uid 89); 15 May 2015 09:59:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_20, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mail2-relais-roc.national.inria.fr Received: from mail2-relais-roc.national.inria.fr (HELO mail2-relais-roc.national.inria.fr) (192.134.164.83) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 15 May 2015 09:59:03 +0000 Received: from stedding.saclay.inria.fr (HELO stedding) ([193.55.250.194]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/AES128-SHA; 15 May 2015 11:59:00 +0200 Received: from glisse (helo=localhost) by stedding with local-esmtp (Exim 4.85) (envelope-from ) id 1YtCOS-0007bc-6X for gcc-patches@gcc.gnu.org; Fri, 15 May 2015 11:59:00 +0200 Date: Fri, 15 May 2015 11:59:00 +0200 (CEST) From: Marc Glisse To: gcc-patches@gcc.gnu.org Subject: Improve error message for vector conversion Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Hello, this patch was regtested on ppc64le-redhat-linux. 2015-05-15 Marc Glisse gcc/ * convert.c (convert_to_integer, convert_to_vector): Include the types in the error message. gcc/testsuite/ * gcc.dg/simd-1.c: Update to the new message. Index: gcc/convert.c =================================================================== --- gcc/convert.c (revision 223214) +++ gcc/convert.c (working copy) @@ -913,21 +913,23 @@ convert_to_integer (tree type, tree expr return build1 (FIXED_CONVERT_EXPR, type, expr); case COMPLEX_TYPE: return convert (type, fold_build1 (REALPART_EXPR, TREE_TYPE (TREE_TYPE (expr)), expr)); case VECTOR_TYPE: if (!tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (TREE_TYPE (expr)))) { - error ("can%'t convert between vector values of different size"); + error ("can%'t convert a vector of type %qT" + " to type %qT which has different size", + TREE_TYPE (expr), type); return error_mark_node; } return build1 (VIEW_CONVERT_EXPR, type, expr); default: error ("aggregate value used where an integer was expected"); return convert (type, integer_zero_node); } } @@ -997,21 +999,23 @@ convert_to_complex (tree type, tree expr tree convert_to_vector (tree type, tree expr) { switch (TREE_CODE (TREE_TYPE (expr))) { case INTEGER_TYPE: case VECTOR_TYPE: if (!tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (TREE_TYPE (expr)))) { - error ("can%'t convert between vector values of different size"); + error ("can%'t convert a value of type %qT" + " to vector type %qT which has different size", + TREE_TYPE (expr), type); return error_mark_node; } return build1 (VIEW_CONVERT_EXPR, type, expr); default: error ("can%'t convert value to a vector"); return error_mark_node; } } Index: gcc/testsuite/gcc.dg/simd-1.c =================================================================== --- gcc/testsuite/gcc.dg/simd-1.c (revision 223214) +++ gcc/testsuite/gcc.dg/simd-1.c (working copy) @@ -38,21 +38,21 @@ hanneke () /* Casted different signed SIMD assignment. */ f = (uv4si) a; /* Assignment between scalar and SIMD of different size. */ foo = a; /* { dg-error "incompatible types when assigning" } */ /* Casted assignment between scalar and SIMD of same size. */ foo = (typeof (foo)) foo2; /* Casted assignment between scalar and SIMD of different size. */ - foo1 = (typeof (foo1)) foo2; /* { dg-error "can't convert between vector values of different size" } */ + foo1 = (typeof (foo1)) foo2; /* { dg-error "can't convert a vector of type" } */ /* Operators on compatible SIMD types. */ a += b + b; a -= b; a *= b; a /= b; a = -b; /* Operators on incompatible SIMD types. */ a = b + c; /* { dg-error "invalid operands to binary +" } */