From patchwork Sun Oct 22 22:22:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 156608 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp965721vqx; Sun, 22 Oct 2023 15:23:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqhj9CvbwWrYh5m/q3dBZ13/c9OQHCj8gNivng2b+VEAgWK7ce2ayH79FxB+FQ5yA/YdLr X-Received: by 2002:a05:6358:3402:b0:143:3a49:e30d with SMTP id h2-20020a056358340200b001433a49e30dmr7851824rwd.12.1698013380706; Sun, 22 Oct 2023 15:23:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698013380; cv=pass; d=google.com; s=arc-20160816; b=KQb4KIURwBR2gwGGUMujmurL4yTwafsIOcLXWfdqpRxzTxBT9VJo6WHt7VRL2o2c/s lbezSLpvLtvxWKrfJcZnLy1kKIoW+/UQAKaZN8lozed22gXmKii50P8eycSYNA1h6aRv lD/4fXgDFG9TuvJRhpAAlU4jWrgz5mSwcK18EquLEPiQr/8zKeO7EikCGbr9WWr4/nJ/ AvnYXFceUZXzrqS3768N2I4HhEJlG1M1Gh80P+i2rem0371W/TfoH2ybWVBUd6KsX1Sa 5Sld+N/4YfF0swAEV3mZpdPb+SEKS0dSli75VdbOcJ0Pl9zeDRueGVUBmALJQaNK2Fba kaTA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=j4OvadKifeimmnP65K+i9NmdPiKJvO4ZwIMZf5IqQe4=; fh=6xfd3IYC8Zt5CA4TsXZHhPmGMhO9cjo3oiHaQc5bSUI=; b=XUtDiHSK7wPHiVp/XYvyBH/kGiGz6ZeFd88dX5YC+DmFu9WLEBXXYhAeXxo7/Nho8b FkaJ8j28ApuRvOpuGKczhBGzax548IGCaTzB2oQub2alivunu7aGIpYTj7vtxvqP9+Gl SWsvci5WrgN8lPtghJF2vgAZevdjM1u8AuPW5sCmxPC5orcs2xB2Ak2RKGOn52ggccbB Bdm4MaO5e20qIhv2uXs++6LtZAWbPDZA9n6zVMwb6vEL4ON4rcoVr0iqfBy3RjUUC6oa TIr8s1Ry+/hxPfEyeWWTFXwfWHoJuspk8pO7+/bwTtTKVsNqZ0+Psma46n0n5JeEHxPT B2Bw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BYGyqHW4; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id t11-20020a0562140c6b00b0066d0585e31bsi4812897qvj.147.2023.10.22.15.23.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 15:23:00 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BYGyqHW4; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 76E6D3858C3A for ; Sun, 22 Oct 2023 22:23:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id 70DBE3858D37 for ; Sun, 22 Oct 2023 22:22:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 70DBE3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 70DBE3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698013356; cv=none; b=BMf/twspBfjStzlBPW0MUoJWKTpwOoMYKHEhsUtco6SpYC6U9sL6DEs6wR2pu1u99y8vojJeWksjSFt+LbibBjsgjtTfMZmkYzPz2z2/45Xtba1d7IFPZrYrN8DRSAKijerPgR6/YCzZKviTFinlg4zx0ouoJ6vWLCIg5hTGCb4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698013356; c=relaxed/simple; bh=398s4XfBmpE7Lt88bYm7+7daXGxEEXjIgmp9SC0lI9Q=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=NpxoqT0YfHUPu8pAAFyA3jiXnKvQARhpZoAeZOjLUr6W8kOJ4oZzelzNRFdS04XOXJOUQ1zycgT00WVqjLV+RRPi9HgYWeVIOMrb4pabN+FlFBpGKrCWC5tnKjKP9ilQ8zN2sKJeIUdNW3ACmIhO0qXEqaVPLcq+2Zmh0PI9LZ8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-584a761b301so1971439a12.3 for ; Sun, 22 Oct 2023 15:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698013353; x=1698618153; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=j4OvadKifeimmnP65K+i9NmdPiKJvO4ZwIMZf5IqQe4=; b=BYGyqHW4nBIDbQJkIo4q6UVVUyKJ2C557EY8Z67TWzu/8IWdvJ0tYjQgjO800ggl2S LF1C3mojVKp23BZ+Mf9DPmq1NI6/O2fT2mN+SxswFiVkiueWLh6ke0lEQjusYgiG0diJ xrPOANtpmIMiX6SUM2hspZ/GROXW8PvwTzU5ScaIYIBvdoh3zSvQ1dd9c5+y1qhkA90/ /f/JrERicdl4ktwKgyxeOuNPdOCfD1j7IKE+yg3vETqaOJrdkpItEXT+zcSbj3axyOR4 hubfYcb5Ys249xp87Vgkbtai84j+HE9fbxRJZjhhicDJpVv+XTlBpIv7fuLlEGkUZLoL dKDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698013353; x=1698618153; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=j4OvadKifeimmnP65K+i9NmdPiKJvO4ZwIMZf5IqQe4=; b=cuZIOv0VBIYJralAyruhmzQpKaqEfn7VAfp7cLkJ1jWo96io+Ewqvknw/HPsrBIx3h aidktZCSHoonysR9AsI1YaLl6s7D7eVCIpWe58E7L8vRAV+71nIUmrwoMNTKnq8wpDcg jVLYZqTnUHxQEwzFJrgYWb18heoQDw5JYA4Jlr5uKjHsKBJpyNBB1txOcggwPwXTTLsn JMr7y0llENvr1rbCxRDxGAsRdMGaHmA4vCCyO0FXkBMIxEzfKSzW4S6Ft1ya5Q12CCqe zgk0DTytAtaxBajgb2zCNvk3cf+NLZ6yFgLATqYl+tTKV7Xn1juyk8KifCbYyF1ZoVbe q4wg== X-Gm-Message-State: AOJu0YydaUX2TGoJPpnj6lQ5gsggN86E1FicZZl3BNn19FEZIKbUu3cl kOcJXk5/wJjkc5QSnQl4zPst5xyJ6G4brQ== X-Received: by 2002:a05:6a20:4428:b0:15c:b7ba:6a4d with SMTP id ce40-20020a056a20442800b0015cb7ba6a4dmr10953929pzb.50.1698013353073; Sun, 22 Oct 2023 15:22:33 -0700 (PDT) Received: from xeond2.wrightpinski.org ([98.97.114.173]) by smtp.gmail.com with ESMTPSA id c4-20020a056a00008400b006be22fde07dsm4948589pfj.106.2023.10.22.15.22.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 15:22:32 -0700 (PDT) From: Andrew Pinski To: gcc-patches@gcc.gnu.org Cc: Andrew Pinski Subject: [PATCH] Use error_mark_node after error in convert Date: Sun, 22 Oct 2023 15:22:30 -0700 Message-Id: <20231022222230.1633485-1-pinskia@gmail.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780496078703505654 X-GMAIL-MSGID: 1780496078703505654 While working on PR c/111903, I Noticed that convert will convert integer_zero_node to that type after an error instead of returning error_mark_node. From what I can tell this was the old way of not having error recovery since other places in this file does return error_mark_node and the places I am replacing date from when the file was imported into the repro (either via a gcc2 merge or earlier). I also had to update the objc front-end to allow for the error_mark_node change, I suspect you could hit the ICE without this change though. Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * convert.cc (convert_to_pointer_1): Return error_mark_node after an error. (convert_to_real_1): Likewise. (convert_to_integer_1): Likewise. (convert_to_complex_1): Likewise. gcc/objc/ChangeLog: * objc-gnu-runtime-abi-01.cc (build_objc_method_call): Allow for error_operand after call to build_c_cast. * objc-next-runtime-abi-01.cc (build_objc_method_call): Likewise. * objc-next-runtime-abi-02.cc (build_v2_build_objc_method_call): Likewise. --- gcc/convert.cc | 12 ++++++------ gcc/objc/objc-gnu-runtime-abi-01.cc | 3 +++ gcc/objc/objc-next-runtime-abi-01.cc | 3 +++ gcc/objc/objc-next-runtime-abi-02.cc | 3 +++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/gcc/convert.cc b/gcc/convert.cc index 5357609d8f0..ac6af7026a7 100644 --- a/gcc/convert.cc +++ b/gcc/convert.cc @@ -96,7 +96,7 @@ convert_to_pointer_1 (tree type, tree expr, bool fold_p) default: error ("cannot convert to a pointer type"); - return convert_to_pointer_1 (type, integer_zero_node, fold_p); + return error_mark_node; } } @@ -332,11 +332,11 @@ convert_to_real_1 (tree type, tree expr, bool fold_p) case POINTER_TYPE: case REFERENCE_TYPE: error ("pointer value used where a floating-point was expected"); - return convert_to_real_1 (type, integer_zero_node, fold_p); + return error_mark_node; default: error ("aggregate value used where a floating-point was expected"); - return convert_to_real_1 (type, integer_zero_node, fold_p); + return error_mark_node; } } @@ -959,7 +959,7 @@ convert_to_integer_1 (tree type, tree expr, bool dofold) default: error ("aggregate value used where an integer was expected"); - return convert (type, integer_zero_node); + return error_mark_node; } } @@ -1053,11 +1053,11 @@ convert_to_complex_1 (tree type, tree expr, bool fold_p) case POINTER_TYPE: case REFERENCE_TYPE: error ("pointer value used where a complex was expected"); - return convert_to_complex_1 (type, integer_zero_node, fold_p); + return error_mark_node; default: error ("aggregate value used where a complex was expected"); - return convert_to_complex_1 (type, integer_zero_node, fold_p); + return error_mark_node; } } diff --git a/gcc/objc/objc-gnu-runtime-abi-01.cc b/gcc/objc/objc-gnu-runtime-abi-01.cc index fbf8307297a..6f45283b307 100644 --- a/gcc/objc/objc-gnu-runtime-abi-01.cc +++ b/gcc/objc/objc-gnu-runtime-abi-01.cc @@ -700,6 +700,9 @@ build_objc_method_call (location_t loc, int super_flag, tree method_prototype, lookup_object = build_c_cast (loc, rcv_p, lookup_object); + if (error_operand_p (lookup_object)) + return error_mark_node; + /* Use SAVE_EXPR to avoid evaluating the receiver twice. */ lookup_object = save_expr (lookup_object); diff --git a/gcc/objc/objc-next-runtime-abi-01.cc b/gcc/objc/objc-next-runtime-abi-01.cc index 70ab5262e17..9e28976043e 100644 --- a/gcc/objc/objc-next-runtime-abi-01.cc +++ b/gcc/objc/objc-next-runtime-abi-01.cc @@ -846,6 +846,9 @@ build_objc_method_call (location_t loc, int super_flag, tree method_prototype, lookup_object = build_c_cast (loc, rcv_p, lookup_object); + if (error_operand_p (lookup_object)) + return error_mark_node; + /* Use SAVE_EXPR to avoid evaluating the receiver twice. */ lookup_object = save_expr (lookup_object); diff --git a/gcc/objc/objc-next-runtime-abi-02.cc b/gcc/objc/objc-next-runtime-abi-02.cc index 6548c0078e0..723b47c9cf6 100644 --- a/gcc/objc/objc-next-runtime-abi-02.cc +++ b/gcc/objc/objc-next-runtime-abi-02.cc @@ -1729,6 +1729,9 @@ build_v2_build_objc_method_call (int super, tree method_prototype, lookup_object = build_c_cast (loc, rcv_p, lookup_object); + if (error_operand_p (lookup_object)) + return error_mark_node; + /* Use SAVE_EXPR to avoid evaluating the receiver twice. */ lookup_object = save_expr (lookup_object);