Changeset 95e5018


Ignore:
Timestamp:
Sep 15, 2022, 11:28:46 AM (19 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, master, pthread-emulation
Children:
747d0fa, a2fd937
Parents:
25793da
Message:

Changed ast::pass::make_location_guard so it should work with C++14.

Location:
src/AST
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.impl.hpp

    r25793da r95e5018  
    2626        using namespace ast; \
    2727        /* back-up the last known code location */ \
    28         __attribute__((unused)) auto loc_guard = ast::__pass::make_location_guard( core, node ); \
     28        __attribute__((unused)) auto loc_guard = ast::__pass::make_location_guard( core, node, 0 ); \
    2929        /* back-up the visit children */ \
    3030        __attribute__((unused)) ast::__pass::visit_children_guard guard1( ast::__pass::visit_children(core, 0) ); \
  • src/AST/Pass.proto.hpp

    r25793da r95e5018  
    295295        FIELD_PTR( at_cleanup, __pass::at_cleanup_t )
    296296        FIELD_PTR( visitor, ast::Pass<core_t> * const )
    297         FIELD_PTR( location, const CodeLocation * )
    298297
    299298        // Remove the macro to make sure we don't clash
     
    328327
    329328        template< typename core_t, typename node_t >
    330         static auto make_location_guard(core_t & core, node_t * node) -> ValueGuardPtr<const CodeLocation *> {
    331                 if constexpr (std::is_base_of<ParseNode, node_t>::value) {
    332                         const CodeLocation ** p = location(core, 0);
    333                         if(p) {
    334                                 ValueGuardPtr<const CodeLocation *> g = { p };
    335                                 *p = &node->location;
    336                                 return g;
    337                         }
    338                 }
    339                 (void)node;
    340                 return { nullptr };
     329        static auto make_location_guard( core_t & core, node_t * node, int )
     330                        -> decltype( node->location, ValueGuardPtr<const CodeLocation *>( &core.location ) ) {
     331                ValueGuardPtr<const CodeLocation *> guard( &core.location );
     332                core.location = &node->location;
     333                return guard;
     334        }
     335
     336        template< typename core_t, typename node_t >
     337        static auto make_location_guard( core_t &, node_t *, long ) -> int {
     338                return 0;
    341339        }
    342340
Note: See TracChangeset for help on using the changeset viewer.