From patchwork Fri Aug 23 09:54:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1152080 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-507579-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="cX1HvDWC"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="Dy0+LVlr"; 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 46FGyw6Cznz9sNk for ; Fri, 23 Aug 2019 19:57:11 +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:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=WY1OV5Iq1d5dUCWf/G2DcAWDuT0Efg2OCOpiFh2QX4FthhdtIt 9gsjfouDbrtIGquuUC5N7zYWV+1inx5/G0GykW+erZjjj+ZZX+EIagq4y5gQVlm5 f+zgdDjbL1gTebhAdYgJum+Kko95htCQIQATolR3yhX9lKZ86QeM9iVpU= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=6sL1nCXw0BSi+50dNgmbMi7Mbg8=; b=cX1HvDWCDuauSm0Jb/pc i7eYlI4hnzjPeIbwIGW00GsGepcstVAGpWnK4tZVQ+NTc54eWbc5S62a9cVrnwju wCrVJ5PAv1pXBj4J2uCc9UHMUwULY5LTvKO6DTl0RHgyStoleelJwpXCAMgoQT0a z6h7mzBEHvvi0xfPRVsHdO0= Received: (qmail 36529 invoked by alias); 23 Aug 2019 09:57:03 -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 36517 invoked by uid 89); 23 Aug 2019 09:57:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=quantity, 2015 X-HELO: userp2130.oracle.com Received: from userp2130.oracle.com (HELO userp2130.oracle.com) (156.151.31.86) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 23 Aug 2019 09:57:02 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7N9sIx5059867; Fri, 23 Aug 2019 09:57:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : from : subject : message-id : date : mime-version : content-type; s=corp-2019-08-05; bh=4A3gnIg9TAAwLemvLeSbyGOOs82xcOKRjGaixgDNQ4Y=; b=Dy0+LVlrsCeQS8zRiAR1QF1zys3zjAqqeR5q8HGEGS9fYaCOsSLdZ1PN7MwKMfCDvgiu suv4G0YOBSqOUQ2hCqPxDrX59TAg37oWvI0rTJUHJ0azoRnywVIPzASID03HOz//XJrj /2cj8W22PBVqGpwMuUfQqWlVm9uAByQ1xYGktfAUDYtwaQmga5d5/JO+HB8JaMcqwfvq KYi+kQU/E1dFakz6CUiDRs/0MBcESKbPSEHHQDRD+fqKEmdWBNntho36J8pICSiGAI5y vzJDrvKZcvtaDAMCElIiivhMAE4GdxNtcRNIXOSitulqRHlwZzOODfAvM0idR3wnL3a3 fw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2ue90u3wu0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Aug 2019 09:57:00 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7N9qfFT194727; Fri, 23 Aug 2019 09:54:59 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2ujca7vbvy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Aug 2019 09:54:59 +0000 Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7N9swKq018529; Fri, 23 Aug 2019 09:54:58 GMT Received: from [192.168.1.4] (/79.19.31.88) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 23 Aug 2019 02:54:58 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Fix finish_switch_cond location Message-ID: <3cf20318-6fa3-ca78-1cf7-4d859b377524@oracle.com> Date: Fri, 23 Aug 2019 11:54:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, a rather straightforward tweak. We could imagine much more heavily reworking the code to avoid saving the original condition (build_expr_type_conversion return NULL_TREE upon error), I'm not sure if it's worth it. Tested x86_64-linux. Thanks, Paolo. //////////////////////// /cp 2019-08-23 Paolo Carlini * semantics.c (finish_switch_cond): Improve error message location. /testsuite 2019-08-23 Paolo Carlini * g++.dg/conversion/simd4.C: Test all the locations. Index: cp/semantics.c =================================================================== --- cp/semantics.c (revision 274845) +++ cp/semantics.c (working copy) @@ -1185,10 +1185,12 @@ finish_switch_cond (tree cond, tree switch_stmt) if (!processing_template_decl) { /* Convert the condition to an integer or enumeration type. */ + tree orig_cond = cond; cond = build_expr_type_conversion (WANT_INT | WANT_ENUM, cond, true); if (cond == NULL_TREE) { - error ("switch quantity not an integer"); + error_at (cp_expr_loc_or_input_loc (orig_cond), + "switch quantity not an integer"); cond = error_mark_node; } /* We want unlowered type here to handle enum bit-fields. */ Index: testsuite/g++.dg/conversion/simd4.C =================================================================== --- testsuite/g++.dg/conversion/simd4.C (revision 274845) +++ testsuite/g++.dg/conversion/simd4.C (working copy) @@ -20,15 +20,15 @@ foo () v[b]; // { dg-error "4:invalid types" } w[b]; // { dg-error "4:invalid types" } new int[t]; - new int[u]; // { dg-error "new-declarator must have integral" } - new int[v]; // { dg-error "new-declarator must have integral" } - new int[w]; // { dg-error "new-declarator must have integral" } + new int[u]; // { dg-error "11:expression in new-declarator must have integral" } + new int[v]; // { dg-error "11:expression in new-declarator must have integral" } + new int[w]; // { dg-error "11:expression in new-declarator must have integral" } switch (t) { default: break; } - switch (u) { default: break; } // { dg-error "switch quantity not an integer" } - switch (v) { default: break; } // { dg-error "switch quantity not an integer" } - switch (w) { default: break; } // { dg-error "switch quantity not an integer" } + switch (u) { default: break; } // { dg-error "11:switch quantity not an integer" } + switch (v) { default: break; } // { dg-error "11:switch quantity not an integer" } + switch (w) { default: break; } // { dg-error "11:switch quantity not an integer" } t = ~t; - u = ~u; // { dg-error "wrong type argument to bit-complement" } + u = ~u; // { dg-error "8:wrong type argument to bit-complement" } v = ~v; - w = ~w; // { dg-error "wrong type argument to bit-complement" } + w = ~w; // { dg-error "8:wrong type argument to bit-complement" } }