From patchwork Thu Nov 14 11:09:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1194758 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-513355-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="F5W+zbFm"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="Li0QReiX"; 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 47DJfg36vNz9sNT for ; Thu, 14 Nov 2019 22:10:03 +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:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=q6NOnNRuAbg2PGNZhO9Rz0xJpmTD6naEB3qE0x+uo0Ba3x8Me7 Fd/rYQWSeHf0UhrDlf+Tgj3YYPHyDz44aldnqxpK/q0M3mqm83ScNzFBrxDz022P O7UEfZoSZAgg1fmlv0kjMBBzIvDE1EWCEv7+qlE7toSKcD0yKlcmj3Aa0= 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=XI0QcBoKUoc2IJUihlfyKTY8dlc=; b=F5W+zbFmK1+AV+KLBUVD ME1G/KlsJ8sVtYyDPY98cfUtGfnvD5qNNsOxo7ctRhQsaQE3vd9NbPzAaN5doW2O naLnOvje50LZWbkGcgRUJ5QdnNP5AJ5Wz/hie/sbtnO4XUKyWnyD1FMduXXHhFli YANA02ONjtPAVpWKJJYybSo= Received: (qmail 75555 invoked by alias); 14 Nov 2019 11:09:46 -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 75498 invoked by uid 89); 14 Nov 2019 11:09:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=65, fsc, xj, 87 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; Thu, 14 Nov 2019 11:09:43 +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 xAEB8vWf109677; Thu, 14 Nov 2019 11:09:41 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=2V93OLrlvRCqSVc95glE9+dd77heCqf9I0o9oHdU53M=; b=Li0QReiXYr9YZlCVBn+Lc2YXVu67Co0V0cylFkredWybzkTjX/ddk0JXVhCZ1uhR8hj2 hljXftryBoSirb3ff9H60zadnZ3TMQVRMfT0EOKanQbZc4/jsXXO0iJTRkaHjV9FPrAU stmI5aYyzrW/Qr3h9rDd7UrxKQ2KuV192mcervrwWNTgOOosr31P7OfHyjeQHfh88iU9 BnbU8iiYzPLbKGjJ6UNkJGfsTFRXFoIBjaFOAj93gR6gNsQFDR4SDed+qVarB17aYlKn FE5bEcTQKvgblLHT0NfdtUFP3Qe4x4p4qo40kusL4US/DCly9PGRHwVoOr3RuhNfR8To RA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2w5mvu2gve-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Nov 2019 11:09:41 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAEB9E2b017102; Thu, 14 Nov 2019 11:09:40 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2w8ng88gfs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Nov 2019 11:09:40 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xAEB9dU0010460; Thu, 14 Nov 2019 11:09:39 GMT Received: from [192.168.1.4] (/82.55.26.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 14 Nov 2019 03:09:38 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Use cp_expr_loc_or_input_loc in a few additional typeck.c places Message-ID: <73376a81-9bdb-fcd7-9cca-e803fff99d87@oracle.com> Date: Thu, 14 Nov 2019 12:09:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi, tested x86_64-linux. Thanks, Paolo. /////////////////////// /cp 2019-11-14 Paolo Carlini * typeck.c (cp_build_addr_expr_1): Use cp_expr_loc_or_input_loc in three places. (lvalue_or_else): Use it in one place. /testsuite 2019-11-14 Paolo Carlini * g++.dg/cpp0x/addressof2.C: Test locations too. * g++.dg/cpp0x/rv-lvalue-req.C: Likewise. * g++.dg/expr/crash2.C: Likewise. * g++.dg/expr/lval1.C: Likewise. * g++.dg/expr/unary2.C: Likewise. * g++.dg/ext/lvaddr.C: Likewise. * g++.dg/ext/lvalue1.C: Likewise. * g++.dg/tree-ssa/pr20280.C: Likewise. * g++.dg/warn/Wplacement-new-size.C: Likewise. * g++.old-deja/g++.law/temps1.C: Likewise. Index: cp/typeck.c =================================================================== --- cp/typeck.c (revision 278216) +++ cp/typeck.c (working copy) @@ -6126,7 +6126,7 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue if (kind == clk_none) { if (complain & tf_error) - lvalue_error (input_location, lv_addressof); + lvalue_error (cp_expr_loc_or_input_loc (arg), lv_addressof); return error_mark_node; } if (strict_lvalue && (kind & (clk_rvalueref|clk_class))) @@ -6134,7 +6134,8 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue if (!(complain & tf_error)) return error_mark_node; /* Make this a permerror because we used to accept it. */ - permerror (input_location, "taking address of rvalue"); + permerror (cp_expr_loc_or_input_loc (arg), + "taking address of rvalue"); } } @@ -6228,7 +6229,8 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue if (bitfield_p (arg)) { if (complain & tf_error) - error ("attempt to take address of bit-field"); + error_at (cp_expr_loc_or_input_loc (arg), + "attempt to take address of bit-field"); return error_mark_node; } @@ -10431,7 +10433,7 @@ lvalue_or_else (tree ref, enum lvalue_use use, tsu if (kind == clk_none) { if (complain & tf_error) - lvalue_error (input_location, use); + lvalue_error (cp_expr_loc_or_input_loc (ref), use); return 0; } else if (kind & (clk_rvalueref|clk_class)) Index: testsuite/g++.dg/cpp0x/addressof2.C =================================================================== --- testsuite/g++.dg/cpp0x/addressof2.C (revision 278216) +++ testsuite/g++.dg/cpp0x/addressof2.C (working copy) @@ -8,19 +8,19 @@ addressof (T &x) noexcept return __builtin_addressof (x); } -auto a = __builtin_addressof (1); // { dg-error "lvalue required as unary" } -auto b = addressof (1); // { dg-error "cannot bind non-const lvalue reference of type" } +auto a = __builtin_addressof (1); // { dg-error "31:lvalue required as unary" } +auto b = addressof (1); // { dg-error "21:cannot bind non-const lvalue reference of type" } struct S { int s : 5; int t; void foo (); } s; auto c = __builtin_addressof (s); auto d = addressof (s); -auto e = __builtin_addressof (s.s); // { dg-error "attempt to take address of bit-field" } -auto f = addressof (s.s); // { dg-error "cannot bind bit-field" } -auto g = __builtin_addressof (S{}); // { dg-error "taking address of rvalue" } -auto h = addressof (S{}); // { dg-error "cannot bind non-const lvalue reference of type" } -auto i = __builtin_addressof (S::t); // { dg-error "invalid use of non-static data member" } -auto j = __builtin_addressof (S::foo); // { dg-error "invalid use of non-static member function" } +auto e = __builtin_addressof (s.s); // { dg-error "33:attempt to take address of bit-field" } +auto f = addressof (s.s); // { dg-error "23:cannot bind bit-field" } +auto g = __builtin_addressof (S{}); // { dg-error "31:taking address of rvalue" } +auto h = addressof (S{}); // { dg-error "21:cannot bind non-const lvalue reference of type" } +auto i = __builtin_addressof (S::t); // { dg-error "34:invalid use of non-static data member" } +auto j = __builtin_addressof (S::foo); // { dg-error "34:invalid use of non-static member function" } void foo (bool b) @@ -28,6 +28,6 @@ foo (bool b) lab:; char c; long long int d; - auto k = __builtin_addressof (lab); // { dg-error "was not declared in this scope" } - auto l = __builtin_addressof (b ? c : d); // { dg-error "lvalue required as unary" } + auto k = __builtin_addressof (lab); // { dg-error "33:.lab. was not declared in this scope" } + auto l = __builtin_addressof (b ? c : d); // { dg-error "35:lvalue required as unary" } } Index: testsuite/g++.dg/cpp0x/rv-lvalue-req.C =================================================================== --- testsuite/g++.dg/cpp0x/rv-lvalue-req.C (revision 278216) +++ testsuite/g++.dg/cpp0x/rv-lvalue-req.C (working copy) @@ -4,7 +4,7 @@ template T&& declval(); int main() { - &declval(); // { dg-error "rvalue" } + &declval(); // { dg-error "16:taking address of rvalue" } declval() = declval(); // { dg-error "15:using rvalue as lvalue" } declval()++; // { dg-error "15:using rvalue as lvalue" } --declval(); // { dg-error "17:using rvalue as lvalue" } Index: testsuite/g++.dg/expr/crash2.C =================================================================== --- testsuite/g++.dg/expr/crash2.C (revision 278216) +++ testsuite/g++.dg/expr/crash2.C (working copy) @@ -8,7 +8,7 @@ int& foo::x=temp; int main() { int x = 3; - &foo::x = x; // { dg-error "" } + &foo::x = x; // { dg-error "3:lvalue required" } return 0; } Index: testsuite/g++.dg/expr/lval1.C =================================================================== --- testsuite/g++.dg/expr/lval1.C (revision 278216) +++ testsuite/g++.dg/expr/lval1.C (working copy) @@ -3,5 +3,5 @@ void f () { int n; - (char) n = 1; // { dg-error "" } + (char) n = 1; // { dg-error "3:lvalue required" } } Index: testsuite/g++.dg/expr/unary2.C =================================================================== --- testsuite/g++.dg/expr/unary2.C (revision 278216) +++ testsuite/g++.dg/expr/unary2.C (working copy) @@ -8,8 +8,8 @@ int n; void f(void) { - -n = 0; // { dg-error "lvalue" } - +n = 0; // { dg-error "lvalue" } + -n = 0; // { dg-error "3:lvalue" } + +n = 0; // { dg-error "3:lvalue" } } template Index: testsuite/g++.dg/ext/lvaddr.C =================================================================== --- testsuite/g++.dg/ext/lvaddr.C (revision 278216) +++ testsuite/g++.dg/ext/lvaddr.C (working copy) @@ -6,5 +6,5 @@ void f() { int n; - char* p = &(char) n; // { dg-error "lvalue" } + char* p = &(char) n; // { dg-error "14:lvalue" } } Index: testsuite/g++.dg/ext/lvalue1.C =================================================================== --- testsuite/g++.dg/ext/lvalue1.C (revision 278216) +++ testsuite/g++.dg/ext/lvalue1.C (working copy) @@ -4,7 +4,7 @@ int main () { char c; - static_cast(c) = 2; // { dg-error "lvalue" "not an lvalue" } + static_cast(c) = 2; // { dg-error "3:lvalue" "not an lvalue" } return c != 2; } Index: testsuite/g++.dg/tree-ssa/pr20280.C =================================================================== --- testsuite/g++.dg/tree-ssa/pr20280.C (revision 278216) +++ testsuite/g++.dg/tree-ssa/pr20280.C (working copy) @@ -57,7 +57,8 @@ void f(X &x, bool b) h (b ? x.i : x.k); h (b ? x.j : x.k); - (long &)(b ? x.i : x.j); // { dg-error "address of bit-field" } - (long &)(b ? x.i : x.k); // { dg-error "address of bit-field" } - (long &)(b ? x.j : x.k); // { dg-error "address of bit-field" } + (long &)(b ? x.i : x.j); // { dg-error "18:attempt to take address of bit-field" } + (long &)(b ? x.i : x.k); // { dg-error "18:attempt to take address of bit-field" } + // { dg-error "24:attempt to take address of bit-field" "" { target *-*-* } .-1 } + (long &)(b ? x.j : x.k); // { dg-error "24:attempt to take address of bit-field" } } Index: testsuite/g++.dg/warn/Wplacement-new-size.C =================================================================== --- testsuite/g++.dg/warn/Wplacement-new-size.C (revision 278216) +++ testsuite/g++.dg/warn/Wplacement-new-size.C (working copy) @@ -314,11 +314,11 @@ void test (void *p, int n) new (&sssac4_2) char[sizeof sssac4_2 + 1]; // { dg-warning "placement" } // taking the address of a temporary is allowed with -fpermissive - new (&fsc ().c) int; // { dg-warning "address|placement" } - new (&fasc1 ().ac) int; // { dg-warning "address|placement" } - new (&fasc2 ().ac) int; // { dg-warning "address|placement" } - new (&fasc3 ().ac) int; // { dg-warning "address|placement" } - new (&fasc4 ().ac) int; // { dg-warning "address|placement" } + new (&fsc ().c) int; // { dg-warning "18:taking address|placement" } + new (&fasc1 ().ac) int; // { dg-warning "20:taking address|placement" } + new (&fasc2 ().ac) int; // { dg-warning "20:taking address|placement" } + new (&fasc3 ().ac) int; // { dg-warning "20:taking address|placement" } + new (&fasc4 ().ac) int; // { dg-warning "20:taking address|placement" } new (&uac1) int; // { dg-warning "placement" } new (&uac2) int; // { dg-warning "placement" } Index: testsuite/g++.old-deja/g++.law/temps1.C =================================================================== --- testsuite/g++.old-deja/g++.law/temps1.C (revision 278216) +++ testsuite/g++.old-deja/g++.law/temps1.C (working copy) @@ -17,4 +17,4 @@ struct cookie }; cookie cat(&foo("apabepa"));// { dg-warning "deprecated conversion|forbids converting a string constant" "dep" } -// { dg-warning "taking address of rvalue" "add" { target *-*-* } .-1 } +// { dg-warning "13:taking address of rvalue" "add" { target *-*-* } .-1 }