| 1 |
// Copyright (C) 2020-2025 Free Software Foundation, Inc. |
| 2 |
|
| 3 |
// This file is part of GCC. |
| 4 |
|
| 5 |
// GCC is free software; you can redistribute it and/or modify it under |
| 6 |
// the terms of the GNU General Public License as published by the Free |
| 7 |
// Software Foundation; either version 3, or (at your option) any later |
| 8 |
// version. |
| 9 |
|
| 10 |
// GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
| 11 |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 13 |
// for more details. |
| 14 |
|
| 15 |
// You should have received a copy of the GNU General Public License |
| 16 |
// along with GCC; see the file COPYING3. If not see |
| 17 |
// <http://www.gnu.org/licenses/>. |
| 18 |
|
| 19 |
#ifndef RUST_FEATURE_GATE_H |
| 20 |
#define RUST_FEATURE_GATE_H |
| 21 |
|
| 22 |
#include "rust-ast-visitor.h" |
| 23 |
#include "rust-feature.h" |
| 24 |
|
| 25 |
namespace Rust { |
| 26 |
|
| 27 |
class FeatureGate : public AST::DefaultASTVisitor |
| 28 |
{ |
| 29 |
public: |
| 30 |
FeatureGate () {} |
| 31 |
|
| 32 |
using AST::DefaultASTVisitor::visit; |
| 33 |
|
| 34 |
void check (AST::Crate &crate); |
| 35 |
void visit (AST::Crate &crate) override; |
| 36 |
|
| 37 |
void visit (AST::LifetimeParam &lifetime_param) override; |
| 38 |
void visit (AST::ConstGenericParam &const_param) override; |
| 39 |
void visit (AST::BorrowExpr &expr) override; |
| 40 |
void visit (AST::BoxExpr &expr) override; |
| 41 |
void visit (AST::TypeParam ¶m) override; |
| 42 |
void visit (AST::UseTreeGlob &use_tree) override; |
| 43 |
void visit (AST::Function &function) override; |
| 44 |
void visit (AST::TraitImpl &impl) override; |
| 45 |
void visit (AST::Trait &trait) override; |
| 46 |
void visit (AST::ExternalTypeItem &item) override; |
| 47 |
void visit (AST::ExternBlock &block) override; |
| 48 |
void visit (AST::MacroRulesDefinition &rules_def) override; |
| 49 |
void visit (AST::RangePattern &pattern) override; |
| 50 |
|
| 51 |
private: |
| 52 |
void gate (Feature::Name name, location_t loc, const std::string &error_msg); |
| 53 |
void check_rustc_attri (const std::vector<AST::Attribute> &attributes); |
| 54 |
void |
| 55 |
check_may_dangle_attribute (const std::vector<AST::Attribute> &attributes); |
| 56 |
std::set<Feature::Name> valid_features; |
| 57 |
}; |
| 58 |
} // namespace Rust |
| 59 |
#endif |