- Timestamp:
- Feb 3, 2025, 11:46:55 AM (8 months ago)
- Branches:
- master
- Children:
- 54f70c6
- Parents:
- bbbff10
- Location:
- src/AST
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Decl.cpp
rbbbff10 r90e683b 169 169 } 170 170 171 bool EnumDecl::isTyped() const { return base; }172 173 bool EnumDecl::isOpaque() const { return isCfa && !isTyped(); }174 175 171 } 176 172 -
src/AST/Decl.hpp
rbbbff10 r90e683b 306 306 enum class EnumAttribute{ Value, Posn, Label }; 307 307 308 /// enum declaration `enum Foo { ... };` 308 /// enum declaration `enum Foo { ... };` or `enum(...) Foo { ... };` 309 309 class EnumDecl final : public AggregateDecl { 310 310 public: … … 317 317 std::vector< ast::ptr<ast::EnumInstType>> inlinedDecl; // child enums 318 318 319 bool is_c_enum () const { return !isCfa; } 320 bool is_opaque_enum() const { return isCfa && nullptr == base; } 321 bool is_typed_enum () const { return isCfa && nullptr != base; } 322 319 323 EnumDecl( const CodeLocation& loc, const std::string& name, bool isCfa = false, 320 324 std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall, … … 331 335 const char * typeString() const override { return aggrString( Enum ); } 332 336 333 bool isTyped() const;334 bool isOpaque() const;335 337 private: 336 338 EnumDecl * clone() const override { return new EnumDecl{ *this }; } -
src/AST/Util.cpp
rbbbff10 r90e683b 85 85 // Check that `type->returns` corresponds with `decl->returns`. 86 86 assert( type->returns.size() == decl->returns.size() ); 87 } 88 89 /// Check that an enumeration has not been made with an inconsistent spec. 90 void isEnumerationConsistent( const EnumDecl * node ) { 91 if ( node->is_c_enum() ) { 92 assert( nullptr == node->base ); 93 } 87 94 } 88 95 … … 135 142 previsit( (const ParseNode *)node ); 136 143 functionDeclMatchesType( node ); 144 } 145 146 void previsit( const EnumDecl * node ) { 147 previsit( (const ParseNode *)node ); 148 isEnumerationConsistent( node ); 137 149 } 138 150
Note:
See TracChangeset
for help on using the changeset viewer.