Changeset c7ebbec
- Timestamp:
- Dec 21, 2023, 10:21:28 AM (12 months ago)
- Branches:
- master
- Children:
- 116d7e2
- Parents:
- 523e300
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/LinkageSpec.cpp
r523e300 rc7ebbec 27 27 namespace Linkage { 28 28 29 Spec update( CodeLocationloc, Spec spec, const std::string * cmd ) {29 Spec update( const CodeLocation & loc, Spec spec, const std::string * cmd ) { 30 30 assert( cmd ); 31 31 std::unique_ptr<const std::string> guard( cmd ); // allocated by lexer 32 32 if ( *cmd == "\"Cforall\"" ) { 33 spec.is_mangled = true; 34 return spec; 33 spec.is_mangled = spec.is_overloadable = true; 35 34 } else if ( *cmd == "\"C\"" ) { 36 spec.is_mangled = false; 37 return spec; 35 spec.is_mangled = spec.is_overloadable = false; 38 36 } else { 39 37 SemanticError( loc, "Invalid linkage specifier %s", cmd->c_str() ); 40 38 } 39 return spec; 41 40 } 42 41 -
src/AST/LinkageSpec.hpp
r523e300 rc7ebbec 31 31 Overrideable = 1 << 2, 32 32 Builtin = 1 << 3, 33 GccBuiltin = 1 << 433 Overloadable = 1 << 4, 34 34 }; 35 35 … … 43 43 bool is_overrideable : 1; 44 44 bool is_builtin : 1; 45 bool is_ gcc_builtin: 1;45 bool is_overloadable : 1; 46 46 }; 47 47 }; … … 52 52 using Spec = bitfield<spec_flags>; 53 53 54 /// If `cmd` = "C" returns `spec` with `is_mangled = false`. 55 /// If `cmd` = "Cforall" returns `spec` with `is_mangled = true`. 56 Spec update( CodeLocation loc, Spec spec, const std::string * cmd ); 54 /// Updates `spec` based on `cmd` (should be "C" or "Cforall"). 55 Spec update( const CodeLocation & loc, Spec spec, const std::string * cmd ); 57 56 58 57 /// A human-readable name for this spec … … 62 61 63 62 /// C built-in defined in prelude 64 constexpr Spec Intrinsic = { Mangle | Generate | Overrideable | Builtin };63 constexpr Spec Intrinsic = { Mangle | Generate | Overrideable | Builtin | Overloadable }; 65 64 /// Ordinary Cforall 66 constexpr Spec Cforall = { Mangle | Generate };65 constexpr Spec Cforall = { Mangle | Generate | Overloadable }; 67 66 /// C code: not overloadable, not mangled 68 67 constexpr Spec C = { Generate }; 69 68 /// Built by translator (e.g. struct assignment) 70 constexpr Spec AutoGen = { Mangle | Generate | Overrideable };69 constexpr Spec AutoGen = { Mangle | Generate | Overrideable | Overloadable }; 71 70 /// GCC internal 72 constexpr Spec Compiler = { Mangle | Builtin | GccBuiltin};71 constexpr Spec Compiler = { Builtin | Overloadable }; 73 72 /// Mangled builtins 74 constexpr Spec BuiltinCFA = { Mangle | Generate | Builtin };73 constexpr Spec BuiltinCFA = { Mangle | Generate | Builtin | Overloadable }; 75 74 /// Non-mangled builtins 76 75 constexpr Spec BuiltinC = { Generate | Builtin }; -
src/AST/SymbolTable.cpp
r523e300 rc7ebbec 644 644 // new definition shadows the autogenerated one, even at the same scope 645 645 return false; 646 } else if ( existing.id->linkage.is_ mangled646 } else if ( existing.id->linkage.is_overloadable 647 647 || ResolvExpr::typesCompatible( 648 648 added->get_type(), existing.id->get_type() ) ) { … … 719 719 // this ensures that no two declarations with the same unmangled name at the same scope 720 720 // both have C linkage 721 if ( decl->linkage.is_ mangled) {721 if ( decl->linkage.is_overloadable ) { 722 722 // Check that a Cforall declaration doesn't override any C declaration 723 723 if ( hasCompatibleCDecl( name, mangleName ) ) { … … 812 812 if ( decl.second.scope != scope ) continue; 813 813 // check for C decl with compatible type (by mangleName) 814 if ( ! decl.second.id->linkage.is_mangled&& decl.first == mangleName ) return true;814 if ( !decl.second.id->linkage.is_overloadable && decl.first == mangleName ) return true; 815 815 } 816 816 … … 829 829 if ( decl.second.scope != scope ) continue; 830 830 // check for C decl with incompatible type (by manglename) 831 if ( ! decl.second.id->linkage.is_mangled&& decl.first != mangleName ) return true;831 if ( !decl.second.id->linkage.is_overloadable && decl.first != mangleName ) return true; 832 832 } 833 833 -
src/CodeGen/CodeGenerator.cpp
r523e300 rc7ebbec 102 102 103 103 std::string CodeGenerator::mangleName( ast::DeclWithType const * decl ) { 104 // GCC builtins should always be printed unmangled. 105 if ( options.pretty || decl->linkage.is_gcc_builtin ) { 106 return decl->name; 107 } else if ( decl->linkage.is_mangled && decl->mangleName != "" ) { 104 if ( !options.pretty && decl->linkage.is_mangled && decl->mangleName != "" ) { 108 105 return decl->scopedMangleName(); 109 106 } else {
Note: See TracChangeset
for help on using the changeset viewer.