From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 7346B3846911 for ; Tue, 21 Feb 2023 12:04:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7346B3846911 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-wr1-x42c.google.com with SMTP id z8so3885277wrm.8 for ; Tue, 21 Feb 2023 04:04:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; 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=b4l4lMg+R/elc2tKtPjjaADgQ8YpFK0wm0cOTUenBgw=; b=a1dKDhPmQ76T4qe9Rt7MkoCH1VVIJvsbDkn5jFr46GDjLdfH2lnfkr+zNtYYvfnGAU fuwRiHK9eCK29vs7FwEpK5vKYIwyjOFB/k9FuwY4P3h9uS4U8SMfpj0W3OKcU9YK6u9C BkvyU3lsWwCy5+7k43/e7o92aC3yD1cP4E8hL0U/7+M7HeB4NkaJMF4jsgXPpA9e9iSV i7rTG/konDWRKuOzbO/MFckgUJvPkA1WES5bYhhrfjHo481KUCoM/sN5xfte/pbvv/Mm +aQ8UznwKuZfxOkQkxuVHQjnpzRHGcskajCNyAK6/JlurG5iIjBgaVg7LxOtoOyoEqUW Y5EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=b4l4lMg+R/elc2tKtPjjaADgQ8YpFK0wm0cOTUenBgw=; b=G6rnJf0Ga2N91JuCrz97hthI6H5VeMS5rFGj/LFuQSt7OLux/zqG1zoFK5wTpiAmGf k70cG2sBliyEo6MJQdR4JLgzwQnug343LOCrDpg2bcGr8uEB1QvP5vMsKZ7yoIvb61Nu WBkKS6B317HQVY5GLiCgJHmHtuUVFH7c409/VLAHC+kBdhz4hXShqZuAH60zxsHlD7AT d4SgwCin9qGroglfevw8J81exQGvmatlf+vzcxcuCnRTLwuw+YADThF4cQuodZxorUsB TagNI0pSliLZtC4nYZRqqs5vTQW3PW6M+lHfNyof5Hnuy4awhEdnsEuPBy8Yh+85Lkx+ nSTw== X-Gm-Message-State: AO0yUKWeGNPohSRYHCGTSu6NR80ldcTJ18dwxlcjua81O7ZobpIyTwfA Y90w6LRwGukchAR3MNfw6T8din8uanWULWulzA== X-Google-Smtp-Source: AK7set/h96QrNG4fUgzs+PrxB3KjGFRt9PEYimWDcp902w1aM0jaSIeBmPPAmdNuv/CggXe+U1cPlg== X-Received: by 2002:a5d:6089:0:b0:2c5:5936:16db with SMTP id w9-20020a5d6089000000b002c5593616dbmr3922014wrt.42.1676981066064; Tue, 21 Feb 2023 04:04:26 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id c15-20020adffb4f000000b002c55b0e6ef1sm5013811wrs.4.2023.02.21.04.04.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:04:25 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Jakub Dupak Subject: [committed 076/103] gccrs: ast: Dump raw pointer type Date: Tue, 21 Feb 2023 13:02:06 +0100 Message-Id: <20230221120230.596966-77-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230221120230.596966-1-arthur.cohen@embecosm.com> References: <20230221120230.596966-1-arthur.cohen@embecosm.com> Reply-To: arthur.cohen@embecosm.com MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.7 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Jakub Dupak gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing RawPointer visitor. Signed-off-by: Jakub Dupak --- gcc/rust/ast/rust-ast-dump.cc | 200 +++++++++++++++++++--------------- 1 file changed, 112 insertions(+), 88 deletions(-) diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc index 9f73d0565ac..e6d6e070709 100644 --- a/gcc/rust/ast/rust-ast-dump.cc +++ b/gcc/rust/ast/rust-ast-dump.cc @@ -269,7 +269,7 @@ Dump::visit (DelimTokenTree &delim_tok_tree) } void -Dump::visit (AttrInputMetaItemContainer &input) +Dump::visit (AttrInputMetaItemContainer &) {} void @@ -311,7 +311,7 @@ Dump::visit (LifetimeParam &lifetime_param) } void -Dump::visit (ConstGenericParam &lifetime_param) +Dump::visit (ConstGenericParam &) {} // rust-path.h @@ -322,15 +322,15 @@ Dump::visit (PathInExpression &path) } void -Dump::visit (TypePathSegment &segment) +Dump::visit (TypePathSegment &) {} void -Dump::visit (TypePathSegmentGeneric &segment) +Dump::visit (TypePathSegmentGeneric &) {} void -Dump::visit (TypePathSegmentFunction &segment) +Dump::visit (TypePathSegmentFunction &) {} void @@ -346,7 +346,7 @@ Dump::visit (QualifiedPathInExpression &path) } void -Dump::visit (QualifiedPathInType &path) +Dump::visit (QualifiedPathInType &) {} // rust-expr.h @@ -357,15 +357,15 @@ Dump::visit (LiteralExpr &expr) } void -Dump::visit (AttrInputLiteral &attr_input) +Dump::visit (AttrInputLiteral &) {} void -Dump::visit (MetaItemLitExpr &meta_item) +Dump::visit (MetaItemLitExpr &) {} void -Dump::visit (MetaItemPathLit &meta_item) +Dump::visit (MetaItemPathLit &) {} void @@ -623,35 +623,35 @@ Dump::visit (ArrayIndexExpr &expr) } void -Dump::visit (TupleExpr &expr) +Dump::visit (TupleExpr &) {} void -Dump::visit (TupleIndexExpr &expr) +Dump::visit (TupleIndexExpr &) {} void -Dump::visit (StructExprStruct &expr) +Dump::visit (StructExprStruct &) {} void -Dump::visit (StructExprFieldIdentifier &field) +Dump::visit (StructExprFieldIdentifier &) {} void -Dump::visit (StructExprFieldIdentifierValue &field) +Dump::visit (StructExprFieldIdentifierValue &) {} void -Dump::visit (StructExprFieldIndexValue &field) +Dump::visit (StructExprFieldIndexValue &) {} void -Dump::visit (StructExprStructFields &expr) +Dump::visit (StructExprStructFields &) {} void -Dump::visit (StructExprStructBase &expr) +Dump::visit (StructExprStructBase &) {} void @@ -669,15 +669,15 @@ Dump::visit (CallExpr &expr) } void -Dump::visit (MethodCallExpr &expr) +Dump::visit (MethodCallExpr &) {} void -Dump::visit (FieldAccessExpr &expr) +Dump::visit (FieldAccessExpr &) {} void -Dump::visit (ClosureExprInner &expr) +Dump::visit (ClosureExprInner &) {} void @@ -696,15 +696,15 @@ Dump::visit (BlockExpr &expr) } void -Dump::visit (ClosureExprInnerTyped &expr) +Dump::visit (ClosureExprInnerTyped &) {} void -Dump::visit (ContinueExpr &expr) +Dump::visit (ContinueExpr &) {} void -Dump::visit (BreakExpr &expr) +Dump::visit (BreakExpr &) {} void @@ -730,7 +730,7 @@ Dump::visit (RangeToExpr &expr) } void -Dump::visit (RangeFullExpr &expr) +Dump::visit (RangeFullExpr &) { stream << ".."; } @@ -751,27 +751,27 @@ Dump::visit (RangeToInclExpr &expr) } void -Dump::visit (ReturnExpr &expr) +Dump::visit (ReturnExpr &) {} void -Dump::visit (UnsafeBlockExpr &expr) +Dump::visit (UnsafeBlockExpr &) {} void -Dump::visit (LoopExpr &expr) +Dump::visit (LoopExpr &) {} void -Dump::visit (WhileLoopExpr &expr) +Dump::visit (WhileLoopExpr &) {} void -Dump::visit (WhileLetLoopExpr &expr) +Dump::visit (WhileLetLoopExpr &) {} void -Dump::visit (ForLoopExpr &expr) +Dump::visit (ForLoopExpr &) {} void @@ -807,35 +807,35 @@ Dump::visit (IfExprConseqIf &expr) } void -Dump::visit (IfExprConseqIfLet &expr) +Dump::visit (IfExprConseqIfLet &) {} void -Dump::visit (IfLetExpr &expr) +Dump::visit (IfLetExpr &) {} void -Dump::visit (IfLetExprConseqElse &expr) +Dump::visit (IfLetExprConseqElse &) {} void -Dump::visit (IfLetExprConseqIf &expr) +Dump::visit (IfLetExprConseqIf &) {} void -Dump::visit (IfLetExprConseqIfLet &expr) +Dump::visit (IfLetExprConseqIfLet &) {} void -Dump::visit (MatchExpr &expr) +Dump::visit (MatchExpr &) {} void -Dump::visit (AwaitExpr &expr) +Dump::visit (AwaitExpr &) {} void -Dump::visit (AsyncBlockExpr &expr) +Dump::visit (AsyncBlockExpr &) {} // rust-item.h @@ -959,23 +959,23 @@ Dump::visit (Module &module) } void -Dump::visit (ExternCrate &crate) +Dump::visit (ExternCrate &) {} void -Dump::visit (UseTreeGlob &use_tree) +Dump::visit (UseTreeGlob &) {} void -Dump::visit (UseTreeList &use_tree) +Dump::visit (UseTreeList &) {} void -Dump::visit (UseTreeRebind &use_tree) +Dump::visit (UseTreeRebind &) {} void -Dump::visit (UseDeclaration &use_decl) +Dump::visit (UseDeclaration &) {} void @@ -1117,11 +1117,11 @@ Dump::visit (Union &union_item) } void -Dump::visit (ConstantItem &const_item) +Dump::visit (ConstantItem &) {} void -Dump::visit (StaticItem &static_item) +Dump::visit (StaticItem &) {} void @@ -1259,7 +1259,7 @@ Dump::visit (TraitImpl &impl) } void -Dump::visit (ExternalStaticItem &item) +Dump::visit (ExternalStaticItem &) {} void @@ -1386,36 +1386,36 @@ Dump::visit (MacroRulesDefinition &rules_def) } void -Dump::visit (MacroInvocation ¯o_invoc) +Dump::visit (MacroInvocation &) {} void -Dump::visit (MetaItemPath &meta_item) +Dump::visit (MetaItemPath &) {} void -Dump::visit (MetaItemSeq &meta_item) +Dump::visit (MetaItemSeq &) {} void -Dump::visit (MetaWord &meta_item) +Dump::visit (MetaWord &) {} void -Dump::visit (MetaNameValueStr &meta_item) +Dump::visit (MetaNameValueStr &) {} void -Dump::visit (MetaListPaths &meta_item) +Dump::visit (MetaListPaths &) {} void -Dump::visit (MetaListNameValueStr &meta_item) +Dump::visit (MetaListNameValueStr &) {} // rust-pattern.h void -Dump::visit (LiteralPattern &pattern) +Dump::visit (LiteralPattern &) {} void @@ -1425,88 +1425,88 @@ Dump::visit (IdentifierPattern &pattern) } void -Dump::visit (WildcardPattern &pattern) +Dump::visit (WildcardPattern &) {} -// void Dump::visit(RangePatternBound& bound){} +// void Dump::visit(RangePatternBound& ){} void -Dump::visit (RangePatternBoundLiteral &bound) +Dump::visit (RangePatternBoundLiteral &) {} void -Dump::visit (RangePatternBoundPath &bound) +Dump::visit (RangePatternBoundPath &) {} void -Dump::visit (RangePatternBoundQualPath &bound) +Dump::visit (RangePatternBoundQualPath &) {} void -Dump::visit (RangePattern &pattern) +Dump::visit (RangePattern &) {} void -Dump::visit (ReferencePattern &pattern) +Dump::visit (ReferencePattern &) {} -// void Dump::visit(StructPatternField& field){} +// void Dump::visit(StructPatternField& ){} void -Dump::visit (StructPatternFieldTuplePat &field) +Dump::visit (StructPatternFieldTuplePat &) {} void -Dump::visit (StructPatternFieldIdentPat &field) +Dump::visit (StructPatternFieldIdentPat &) {} void -Dump::visit (StructPatternFieldIdent &field) +Dump::visit (StructPatternFieldIdent &) {} void -Dump::visit (StructPattern &pattern) +Dump::visit (StructPattern &) {} -// void Dump::visit(TupleStructItems& tuple_items){} +// void Dump::visit(TupleStructItems& ){} void -Dump::visit (TupleStructItemsNoRange &tuple_items) +Dump::visit (TupleStructItemsNoRange &) {} void -Dump::visit (TupleStructItemsRange &tuple_items) +Dump::visit (TupleStructItemsRange &) {} void -Dump::visit (TupleStructPattern &pattern) +Dump::visit (TupleStructPattern &) {} -// void Dump::visit(TuplePatternItems& tuple_items){} +// void Dump::visit(TuplePatternItems& ){} void -Dump::visit (TuplePatternItemsMultiple &tuple_items) +Dump::visit (TuplePatternItemsMultiple &) {} void -Dump::visit (TuplePatternItemsRanged &tuple_items) +Dump::visit (TuplePatternItemsRanged &) {} void -Dump::visit (TuplePattern &pattern) +Dump::visit (TuplePattern &) {} void -Dump::visit (GroupedPattern &pattern) +Dump::visit (GroupedPattern &) {} void -Dump::visit (SlicePattern &pattern) +Dump::visit (SlicePattern &) {} // rust-stmt.h void -Dump::visit (EmptyStmt &stmt) +Dump::visit (EmptyStmt &) {} void @@ -1560,40 +1560,64 @@ Dump::visit (TraitBound &bound) } void -Dump::visit (ImplTraitType &type) +Dump::visit (ImplTraitType &) {} void -Dump::visit (TraitObjectType &type) +Dump::visit (TraitObjectType &) {} void -Dump::visit (ParenthesisedType &type) +Dump::visit (ParenthesisedType &) {} void -Dump::visit (ImplTraitTypeOneBound &type) +Dump::visit (ImplTraitTypeOneBound &) {} void -Dump::visit (TraitObjectTypeOneBound &type) +Dump::visit (TraitObjectTypeOneBound &) {} void -Dump::visit (TupleType &type) +Dump::visit (TupleType &) {} void -Dump::visit (NeverType &type) +Dump::visit (NeverType &) {} void Dump::visit (RawPointerType &type) -{} +{ + // Syntax: + // * ( mut | const ) TypeNoBounds + + if (type.get_pointer_type () == RawPointerType::MUT) + stream << "*mut "; + else /* RawPointerType::CONST */ + stream << "*const "; + + visit (type.get_type_pointed_to ()); +} void Dump::visit (ReferenceType &type) { + // Syntax: + // & Lifetime? mut? TypeNoBounds + + stream << '&'; + + if (type.has_lifetime ()) + { + visit (type.get_lifetime ()); + stream << ' '; + } + + if (type.get_has_mut ()) + stream << "mut "; + visit (type.get_type_referenced ()); } @@ -1606,7 +1630,7 @@ Dump::visit (ArrayType &type) stream << '['; visit (type.get_elem_type ()); stream << "; "; - visit(type.get_size_expr()); + visit (type.get_size_expr ()); stream << ']'; } @@ -1622,13 +1646,13 @@ Dump::visit (SliceType &type) } void -Dump::visit (InferredType &type) +Dump::visit (InferredType &) { stream << "_"; } void -Dump::visit (BareFunctionType &type) +Dump::visit (BareFunctionType &) {} } // namespace AST -- 2.39.1