From patchwork Tue Jan 31 13:26:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 50933 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2817664wrn; Tue, 31 Jan 2023 07:33:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXsxpThnEAa/g3tU3bhNQxBZbSA/1ObgrAx2CF9W5dXDHcuWiZ4nezC/1v0pkJAAcV8Ksb+s X-Received: by 2002:a17:906:647:b0:86e:f59e:9cc0 with SMTP id t7-20020a170906064700b0086ef59e9cc0mr53060923ejb.18.1675179201324; Tue, 31 Jan 2023 07:33:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675179201; cv=none; d=google.com; s=arc-20160816; b=ATBAepnE1EfIe300bVn0j6zSIQZYNqmeuALp+9/uVVjVZWQ5Hrsi3bvp4zzFa5MG8J CXjjQqDQQzXs4updAoYK+wIyjhmuZ6P6g78KmsfcoUzo/xq0SjMlAPhsDbrnkNYkODKq kFPWSZrGPM/mg+XDiz71mGIiZGe1HKLHhG0ZelzboN822CSJXFwWAdV0pcgbksBcQwdv YlWT1x0Ly2dyKSULl10eshEB7LfJFwFFJiNxKPGMLH5bRdmDX9zrChWdoENWYUHfnoSZ yeepULFEykGNLTf0pUg69fyds329+7Km9kKIFpqeVNsy7aHPvYIJMqd+/FEOzGSvxl5w 1glA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender: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 :dmarc-filter:delivered-to; bh=SabJY9K7b6ta46mpHRs3WIlOSaA713jVqGTz3Xbvn/c=; b=G7XeH55ESp4hvKMHmTEpk/ucNUHsProwaoirnpQFztJ3vUJTLVov9grzdmyVZZQry4 d/R1cvFE0tcLOOxCJiGfChjrkOUTbCAmIQMbkbBgzqfCODlciCVEzYULYbQRQUU66PON CxEfX7c92lwXl4WyceifbLyHD+rElJeZ+xMh9h6O85LJgGOM35WVnqZTKfgeL+Wsu31w 8zzf0l/qIKsBPWEB9HPPkOABAVC/qGamnQZsN5flZgeAndicgJCY5MWVhaWRdOlKc4zz 5uHBacEGHhP4SQHVg+b+O3JMyZ9hC7OWvY3PbhMgrDggBym6zJ1IZH4W5jC4JLGQx06l XGyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=EURNVpF8; 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" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id vj15-20020a170907130f00b00889353ad3c6si6635114ejb.253.2023.01.31.07.33.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 07:33:21 -0800 (PST) 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=@embecosm.com header.s=google header.b=EURNVpF8; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 93DB43899016 for ; Tue, 31 Jan 2023 13:25:21 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id E3092395A057 for ; Tue, 31 Jan 2023 13:22:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E3092395A057 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x330.google.com with SMTP id d4-20020a05600c3ac400b003db1de2aef0so10583910wms.2 for ; Tue, 31 Jan 2023 05:22:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=SabJY9K7b6ta46mpHRs3WIlOSaA713jVqGTz3Xbvn/c=; b=EURNVpF8v2Gxty0iwa8eaW1I6yLEEJ1Y/5DBbUTdKS9QvRvofOIiUXNolrwLJVM9vH qtVi6n7wMaZ0WfJ+Gd1L/33p6XodAfdUf9COA3fZCaUM8mYDuDFB6HYjOhIk+D3qMYg1 /wKkdQODQpewv4Zz0Htkbuhh/+22ZXnNc8kntSs9tCQ7E2KhfvvnlhMcBnDXrQslrswj Plf34SFOIwUtDD2zvvHt4vm47dAoVSnnqNwz7bB75jOZryXKIMRsne0DWBRxRoXBbaBF 3JpNxrZZ5CYIuWAi9m2JfkIC1m/x1eEiR7mSWcRsQCr6Q0pDCEhPXmOIAJ/HKltG9B1z bxFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=SabJY9K7b6ta46mpHRs3WIlOSaA713jVqGTz3Xbvn/c=; b=UuCA8Pt2C/e+Vlm6+eUYQzNzwwckMEzcFScE+kuLm1EqXfxK39HqCahiy5h0WMuWYp Ps73eCOj5fDfS8Ujt/HLPFrXpcrYuEN61bwgMN5g69dyuyutlj4a1vMQ+0AOcIkX5XGy 4WaudJlmYATmua2ioL/DVvNUFbeaXY8oqHWo7pkiZg6sSaQMsv2HUI9ZgcT50Uqo9pSp adL24n+mR2ayuensubvvMYUjTwfKW/ihTLbjp+96PC6cGvzSuv9CGxpnMHZKLeC/qA4I rB1rOja64/sWfrlOZENbUyaJvObsLWzG2/hGSeKZdYU0oNw2CNCItwL8qFdmHRM4ih4b rQkw== X-Gm-Message-State: AO0yUKUP5Z9VS7QYWiA/2S77q+zy8vqU4YNqGyGorzpkpqt38rlvYS3x NoUiECQfvwkex0c/aSu1OMZZiSiyzjfMd42jvA== X-Received: by 2002:a05:600c:aca:b0:3dc:561a:79d8 with SMTP id c10-20020a05600c0aca00b003dc561a79d8mr9368229wmr.35.1675171342408; Tue, 31 Jan 2023 05:22:22 -0800 (PST) Received: from platypus.lan ([2001:861:5e4c:3bb0:6424:328a:1734:3249]) by smtp.gmail.com with ESMTPSA id 2-20020a05600c028200b003dc4baaedd3sm10528840wmk.37.2023.01.31.05.22.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 05:22:22 -0800 (PST) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, liushuyu Subject: [COMMITTED] gccrs: testsuite: add loop condition execution test Date: Tue, 31 Jan 2023 14:26:07 +0100 Message-Id: <20230131132607.662907-1-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Spam-Status: No, score=-15.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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.29 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 Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756552706382792535?= X-GMAIL-MSGID: =?utf-8?q?1756552706382792535?= From: liushuyu gcc/testsuite/ChangeLog: * rust/execute/torture/loop-condition-eval.rs: New test. Signed-off-by: Zixing Liu Tested on x86_64-pc-linux-gnu, committed on master. --- .../execute/torture/loop-condition-eval.rs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 gcc/testsuite/rust/execute/torture/loop-condition-eval.rs diff --git a/gcc/testsuite/rust/execute/torture/loop-condition-eval.rs b/gcc/testsuite/rust/execute/torture/loop-condition-eval.rs new file mode 100644 index 00000000000..008965917ab --- /dev/null +++ b/gcc/testsuite/rust/execute/torture/loop-condition-eval.rs @@ -0,0 +1,21 @@ +// { dg-output "1\n" } +pub fn test() -> u64 { + let mut n = 113383; // #20 in https://oeis.org/A006884 + while n != 1 { + n = if n % 2 == 0 { n / 2 } else { 3 * n + 1 }; + } + n +} + +pub fn test_1() -> u64 { + test() +} + +extern "C" { + fn printf(fmt: *const i8, ...); +} + +fn main() -> i32 { + unsafe { printf("%lu\n" as *const str as *const i8, test_1()) } + 0 +}