Changeset 77de429
- Timestamp:
- Oct 19, 2022, 1:42:29 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 72b5805e, e874605
- Parents:
- 9511841
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Decl.hpp
r9511841 r77de429 105 105 ptr<Init> init; 106 106 ptr<Expr> bitfieldWidth; 107 bool enumInLine = false; // A flag vairable to tell the compile:108 // this is not a real object declaration. It is a place holder for109 // a set of enum value (ObjectDecl).107 bool enumInLine = false; // enum inline is not a real object declaration. 108 // It is a place holder for a set of enum value (ObjectDecl) 109 bool importValue = false; // if the value copied from somewhere else 110 110 111 111 ObjectDecl( const CodeLocation & loc, const std::string & name, const Type * type, -
src/Validate/LinkReferenceToTypes.cpp
r9511841 r77de429 209 209 if ( member->enumInLine ) { 210 210 auto targetEnum = symtab.lookupEnum( member->name ); 211 if ( targetEnum) {212 for ( auto singleMamber : targetEnum->members) {211 if ( targetEnum ) { 212 for ( auto singleMamber : targetEnum->members ) { 213 213 auto tm = singleMamber.as<ast::ObjectDecl>(); 214 214 auto t = new ast::ObjectDecl( … … 224 224 tm->funcSpec 225 225 ); 226 t->importValue = true; 226 227 buffer.push_back(t); 227 228 } 228 229 } 229 230 } else { 231 auto search_it = std::find_if( buffer.begin(), buffer.end(), [member](ast::ptr<ast::Decl> cur) { 232 auto curAsObjDecl = cur.as<ast::ObjectDecl>(); 233 return (curAsObjDecl->importValue) && (curAsObjDecl->name == member->name); 234 }); 235 if ( search_it != buffer.end() ) { 236 buffer.erase( search_it ); // Found an import enum value that has the same name 237 // override the imported value 238 } 230 239 buffer.push_back( *it ); 231 240 } -
tests/enum_tests/.expect/enumInlineValue.txt
r9511841 r77de429 1 1 enumB.A is 5 2 enumB.B is 62 enumB.B is 10 3 3 enumB.D is 11 4 4 enumB.E is 12 -
tests/enum_tests/enumInlineValue.cfa
r9511841 r77de429 6 6 enum enumB { 7 7 inline enumA, 8 E, F8 E, B=10 9 9 }; 10 10
Note: See TracChangeset
for help on using the changeset viewer.