From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7905) id 514223858420; Tue, 16 Jan 2024 18:00:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 514223858420 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705428009; bh=728xBl6vN3jy+DdjfuHExRBoUfSL0WpiE4bZIPfWU7c=; h=From:To:Subject:Date:From; b=pU1mJYgUqDySoLq3/DZFPM2aTuCAJCz5esyriZ7snYRZmpw1xVXK4udVAk6pcgtoI BOE5FzhtVh63Gi03C89RDUX/qGE4l7vtbsxbL/RAT6MVNWNmXIOFwnkj75jAesUvBw 1PXoOr0smfRnWVBEeDB/424NVf2wvOD+FGL1AX0c= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Arthur Cohen To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-7806] gccrs: proc macro: Detect malformed proc_macro_derive X-Act-Checkin: gcc X-Git-Author: Pierre-Emmanuel Patry X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 6bed91c311e0fbfc72ad4de605335900fc98a5e6 X-Git-Newrev: 1b1f8d898857b69b98095fc26b4dd95bafffdc18 Message-Id: <20240116180009.514223858420@sourceware.org> Date: Tue, 16 Jan 2024 18:00:09 +0000 (GMT) List-Id: https://gcc.gnu.org/g:1b1f8d898857b69b98095fc26b4dd95bafffdc18 commit r14-7806-g1b1f8d898857b69b98095fc26b4dd95bafffdc18 Author: Pierre-Emmanuel Patry Date: Tue Jul 18 13:37:03 2023 +0200 gccrs: proc macro: Detect malformed proc_macro_derive A derive procedural macro declaration shall always have at least a trait to refer to. We should error out when it doesn't. gcc/rust/ChangeLog: * util/rust-attributes.cc (AttributeChecker::visit): Add attribute input check. Signed-off-by: Pierre-Emmanuel Patry Diff: --- gcc/rust/util/rust-attributes.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc index a174edc625f..c8451def94e 100644 --- a/gcc/rust/util/rust-attributes.cc +++ b/gcc/rust/util/rust-attributes.cc @@ -561,6 +561,11 @@ AttributeChecker::visit (AST::Function &fun) if (result.name == "proc_macro_derive") { + if (!attribute.has_attr_input ()) + { + rust_error_at (attribute.get_locus (), + "malformed %<%s%> attribute input", name); + } check_crate_type (name, attribute); } else if (result.name == "proc_macro"