Changeset 5ccc733 for src/AST


Ignore:
Timestamp:
Jun 29, 2024, 5:02:06 AM (18 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
4117761
Parents:
7552fde
Message:

Fix the bug that C style enum cannot to use as an lvalue

Location:
src/AST
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.cpp

    r7552fde r5ccc733  
    203203}
    204204
     205bool EnumDecl::isTyped() const { return base;}
     206
     207bool EnumDecl::isOpague() const { return isCfa && !isTyped(); }
    205208}
    206209
  • src/AST/Decl.hpp

    r7552fde r5ccc733  
    308308class EnumDecl final : public AggregateDecl {
    309309public:
    310         // isTyped indicated if the enum has a declaration like:
     310        // isCfa indicated if the enum has a declaration like:
    311311        // enum (type_optional) Name {...}
    312         bool isTyped;
    313         // if isTyped == true && base.get() == nullptr, it is a "void" type enum
     312        bool isCfa;
     313        // if isCfa == true && base.get() == nullptr, it is a "opague" enum
    314314        ptr<Type> base;
    315315        enum class EnumHiding { Visible, Hide } hide;
    316316        std::vector< ast::ptr<ast::EnumInstType>> inlinedDecl; // child enums
    317317
    318         EnumDecl( const CodeLocation& loc, const std::string& name, bool isTyped = false,
     318        EnumDecl( const CodeLocation& loc, const std::string& name, bool isCfa = false,
    319319                std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall,
    320320                Type const * base = nullptr, EnumHiding hide = EnumHiding::Hide,
    321321                std::unordered_map< std::string, long long > enumValues = std::unordered_map< std::string, long long >() )
    322         : AggregateDecl( loc, name, std::move(attrs), linkage ), isTyped(isTyped), base(base), hide(hide), enumValues(enumValues) {}
     322        : AggregateDecl( loc, name, std::move(attrs), linkage ), isCfa(isCfa), base(base), hide(hide), enumValues(enumValues) {}
    323323
    324324        /// gets the integer value for this enumerator, returning true iff value found
     
    336336
    337337        bool isSubTypeOf(const ast::EnumDecl *) const;
     338        bool isTyped() const;
     339        bool isOpague() const;
    338340private:
    339341        EnumDecl * clone() const override { return new EnumDecl{ *this }; }
Note: See TracChangeset for help on using the changeset viewer.