Message ID | 20240130121026.807464-66-arthur.cohen@embecosm.com |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1192274dyb; Tue, 30 Jan 2024 04:45:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8y4wG0qZ7XTZ4BKMhtL98oebBfVCYHSSn2RMDXMc47o5CWtKAH7CB2iJntAM0/sM3TXpl X-Received: by 2002:a05:6214:2aab:b0:68c:6336:1d19 with SMTP id js11-20020a0562142aab00b0068c63361d19mr1001678qvb.130.1706618728996; Tue, 30 Jan 2024 04:45:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706618728; cv=pass; d=google.com; s=arc-20160816; b=TtXra7ZTB0MxKUh5SjOsBGjpf2Cg9Vqwc99/BWpc2NI3khFbfZXXhSmk2J3NUCtS1M mtzcOQKz/1EksyBf2Vr3geKzNI1UaKxpAE/rr5fqvoI+FwWQol71L4OIsLIlZeDWyJst FwMg9+RXMydjPA4h0C9l+dd5J9yiRkn7vNYxUukvvZyuzojIGCi11rAPTDuSEhZL4UH/ 8SW/2I9cUFBdf9ZAQpgGrxMnXpRKvXSHXNjvlnUemkM/CqZxFSm/umAxLRr5PlTTQlNd TVPW67wB3FZLbBq+RSDKiYp5iGTfy5POFSMP8LjC5uyOaV5d7FYNtvPtzUYqYn6baber SVtQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=nB5Y/pE8eC3pgLib4epj/PNs7fzwaFqAJ5cV6cRW1jg=; fh=s1GzlUPo1djGkCl3rkRJI30hDOSCVwGp0RAbVwQ8dxQ=; b=Lf/CEJkY5RUy20St0XNqfodHkqJIePMLkaO9On2mV6uIyrZ+YnvjjEViY2aKXRjPmW OiZoEQxEIhz8o+D7OTR3Y0zlEMBafqqKUzPBuaR/6GQSoY6EpXjNu4H3iDbui2tWYbk8 8KuBdQ0VZVLO0cZoNv0qqwuFEDfvvtdb1nyFuXGwbMr/VBvPtgj44aE9JcxEmxem+Myt eQtn6IyS1zg7gq+TP2TD/ZwJUP5TH5T4fePpcI4U01IG7AsIQIUQDAST0sDP/SOMML4q BvsYXxirdQ8wdg16jDFZfsE/K0PI9D/uPhvbEx1VXsx+zRbs5+qtz3mRVbexUclgbJZ5 K7uA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=gekQagey; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 1-20020a0562140d6100b0068c544178c7si3110627qvs.465.2024.01.30.04.45.28 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:45:28 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=gekQagey; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 3D2D638708C0 for <ouuuleilei@gmail.com>; Tue, 30 Jan 2024 12:44:36 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 11B193857C5A for <gcc-patches@gcc.gnu.org>; Tue, 30 Jan 2024 12:11:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 11B193857C5A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 11B193857C5A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::431 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616738; cv=none; b=nILxz6nWUBZhS6XwfzDibzjNfROM4E2xwaVO5FmQlI0NAeIa4qWLC2aRa/Lfh8m6+TJegLSDzGEvBGS3y9++dMIUXkylyy8A5Z4bPZXfo7F6oIJjTfnMu0/kxLti43TO9gUt/C3lSVKqpnbBWUPsZHTaUcCwXqaaa2S3h27ZNE0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616738; c=relaxed/simple; bh=UoJRc1bkZHjxdnrsydb3aUnoPpkT44TombNUGjiUXU4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=PTHFr/1nL0IxXRe4EVHEmV1Yv8hN3nZONMoLp4E0DJHtYttrrfRbH8OsaL2yPbdS7M0P9mcLp7bGYKKeI9zXebPz/O6P/Q4lklfbACSZn8Q+oqkGJZ2WVxOax8jvxgRi4joB+bdOm4bvfxRRotzmAYiQsNyL3Y+FTxSlPsbIRvs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-339289fead2so3051117f8f.3 for <gcc-patches@gcc.gnu.org>; Tue, 30 Jan 2024 04:11:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1706616701; x=1707221501; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=nB5Y/pE8eC3pgLib4epj/PNs7fzwaFqAJ5cV6cRW1jg=; b=gekQageyQZGd9aopp4pyZaKyK47wp0hYyCx8I/feFlbe0z0hlPOZnx1Ro6IhjvbowW 2MUDwC+uC7b4zJejTh7hMlw/Tu98uZKzZqtzri6+x1qFWtC+L3iWRkTFC9NbKMRb9klv IrDxwrPGHmlF0u1oRvHKVol2hIQkFX6yWcQKfNYKANbAU0lnxM5lCG86KIPOnZ6H7/tc I60GBxu5Z/k0QG0eVlKuJuqwQ1nntpVfRsaYI4KVGPMyrd0arMUQzp9oa2Hxumr+j0A1 mr2kwW4IXfRWmHu11vebPSiCX3vrWxhoCGIiMvJpm1MQgxaLdvCyK6YbJgN5HJnA9YLv 0QVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706616701; x=1707221501; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=nB5Y/pE8eC3pgLib4epj/PNs7fzwaFqAJ5cV6cRW1jg=; b=ic3XLcaID2Ds0g+gC3UYJ6C0gv8Uxhr60dhWhTDZYEnL6a1yCJYvPMepoauCJG3Tku 2cAotBvAnoyZN4x/JymP4LAoxkidtDzvp6US7dst0vnoMnbpVgRQ5dDD0eA92qo9LaRH 3aQabDIBT/F8Fw8QF6QRpRKCkw+oh4eU4NQQvmh8KcW4z5+0Fg+aheV+85Qh35SI7qRy pTSPNn0hx4032yy0/6zy+kc9zmtAQBLgJwfAJ0Xn5G6k1DH2eX2w0MDbP2SaG9cx9EET QJ4ld3H7T7Akg3/1ZaWKHuaPa5FsLPb3qSbYHk6hfjTyJNzAhSvd62XkqA4WWT4Nntaa njkA== X-Gm-Message-State: AOJu0Yy85KU0n2FIUyXoet8YNKytt3z5rAZpaRzTzbK7713eBXVlO7BT oJFeMaW+Knc2y723gQxyO7X2+/eG2D4eQSZZDnCw0AIuq5hjxmIvXI4X1PC9ILxoMh/FBHB4TCb yeQ== X-Received: by 2002:adf:d1cf:0:b0:33a:eda2:baf7 with SMTP id b15-20020adfd1cf000000b0033aeda2baf7mr4267073wrd.63.1706616696619; Tue, 30 Jan 2024 04:11:36 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id f9-20020a056000036900b00339307d9d31sm10569894wrf.112.2024.01.30.04.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:11:36 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> Subject: [COMMITTED 063/101] gccrs: Add validation for functions without body Date: Tue, 30 Jan 2024 13:07:19 +0100 Message-ID: <20240130121026.807464-66-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240130121026.807464-2-arthur.cohen@embecosm.com> References: <20240130121026.807464-2-arthur.cohen@embecosm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Reply-To: arthur.cohen@embecosm.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789519440374428331 X-GMAIL-MSGID: 1789519440374428331 |
Series |
[COMMITTED,001/101] gccrs: Add visibility to trait item
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Arthur Cohen
Jan. 30, 2024, 12:07 p.m. UTC
From: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> Add checks in the ast validation pass to error out with functions (either free or associated) without a definition. gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add a validation check and emit an error depending on the context. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> --- gcc/rust/checks/errors/rust-ast-validation.cc | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/gcc/rust/checks/errors/rust-ast-validation.cc b/gcc/rust/checks/errors/rust-ast-validation.cc index 2743eb0ca29..6fb142c7845 100644 --- a/gcc/rust/checks/errors/rust-ast-validation.cc +++ b/gcc/rust/checks/errors/rust-ast-validation.cc @@ -109,6 +109,16 @@ ASTValidation::visit (AST::Function &function) function.get_self_param ()->get_locus (), "%<self%> parameter is only allowed in associated functions"); + if (!function.has_body ()) + { + if (context.back () == Context::INHERENT_IMPL + || context.back () == Context::TRAIT_IMPL) + rust_error_at (function.get_locus (), + "associated function in %<impl%> without body"); + else if (context.back () != Context::TRAIT) + rust_error_at (function.get_locus (), "free function without a body"); + } + if (function.is_variadic ()) rust_error_at ( function.get_function_params ().back ()->get_locus (),