Changeset 13edbac for src/Validate/EnumAndPointerDecay.cpp
- Timestamp:
- Oct 28, 2022, 5:12:26 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- be5f0a5
- Parents:
- 2856982c (diff), fa2e183 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Validate/EnumAndPointerDecay.cpp
r2856982c r13edbac 21 21 #include "AST/Type.hpp" 22 22 #include "SymTab/FixFunction.h" 23 #include "Validate/NoIdSymbolTable.hpp" 23 24 24 25 namespace Validate { … … 26 27 namespace { 27 28 28 struct EnumAndPointerDecayCore final : public ast::WithCodeLocation {29 struct EnumAndPointerDecayCore final : public WithNoIdSymbolTable, public ast::WithCodeLocation { 29 30 ast::EnumDecl const * previsit( ast::EnumDecl const * decl ); 30 31 ast::FunctionDecl const * previsit( ast::FunctionDecl const * decl ); … … 39 40 // Set the type of each member of the enumeration to be EnumContant. 40 41 auto mut = ast::mutate( decl ); 41 for ( ast::ptr<ast::Decl> & member : mut->members ) { 42 ast::ObjectDecl const * object = member.strict_as<ast::ObjectDecl>(); 43 member = ast::mutate_field( object, &ast::ObjectDecl::type, 44 new ast::EnumInstType( decl, ast::CV::Const ) ); 42 std::vector<ast::ptr<ast::Decl>> buffer; 43 for ( auto it = decl->members.begin(); it != decl->members.end(); ++it ) { 44 if ( ast::ObjectDecl const * object = (*it).as<ast::ObjectDecl>() ) { 45 buffer.push_back( ast::mutate_field( object, &ast::ObjectDecl::type, new ast::EnumInstType( decl, ast::CV::Const ) ) ); 46 } else if ( ast::InlineValueDecl const * value = (*it).as<ast::InlineValueDecl>() ) { 47 if ( auto targetEnum = symtab.lookupEnum( value->name ) ) { 48 for ( auto singleMember : targetEnum->members ) { 49 auto copyingMember = singleMember.as<ast::ObjectDecl>(); 50 buffer.push_back( new ast::ObjectDecl( 51 value->location, // use the "inline" location 52 copyingMember->name, 53 new ast::EnumInstType( decl, ast::CV::Const ), 54 // Construct a new EnumInstType as the type 55 copyingMember->init, 56 copyingMember->storage, 57 copyingMember->linkage, 58 copyingMember->bitfieldWidth, 59 {}, 60 copyingMember->funcSpec 61 ) ); 62 } 63 } 64 } 45 65 } 66 mut->members = buffer; 46 67 return mut; 47 68 }
Note: See TracChangeset
for help on using the changeset viewer.