Skip to content

Commit

Permalink
fix(preprocessor): header location error
Browse files Browse the repository at this point in the history
  • Loading branch information
xensik committed Feb 9, 2025
1 parent e90444f commit 86c4def
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gen/arc/parser.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ program
;

inline
: INLINE expr_path SEMICOLON { ppr.push_header($2->value); }
: INLINE expr_path SEMICOLON { ppr.push_header(@$, $2->value); }
;

include
Expand Down
2 changes: 1 addition & 1 deletion gen/gsc/parser.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ program
;

inline
: INLINE expr_path SEMICOLON { ppr.push_header($2->value); }
: INLINE expr_path SEMICOLON { ppr.push_header(@$, $2->value); }
;

include
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/arc/preprocessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct preprocessor
public:
preprocessor(context* ctx, std::string const& name, u8 const* data, usize size);
auto process() -> token;
auto push_header(std::string const& file) -> void;
auto push_header(location const& loc, std::string const& file) -> void;
auto pop_header() -> void;
auto ban_header(location const& loc) -> void;

Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/preprocessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct preprocessor
public:
preprocessor(context* ctx, std::string const& name, u8 const* data, usize size);
auto process() -> token;
auto push_header(std::string const& file) -> void;
auto push_header(location const& loc, std::string const& file) -> void;
auto pop_header() -> void;
auto ban_header(location const& loc) -> void;

Expand Down
2 changes: 1 addition & 1 deletion src/arc/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2385,7 +2385,7 @@ namespace xsk { namespace arc {

case 12: // inline: "#inline" expr_path ";"
#line 323 "parser.ypp"
{ ppr.push_header(yystack_[1].value.as < expr_path::ptr > ()->value); }
{ ppr.push_header(yylhs.location, yystack_[1].value.as < expr_path::ptr > ()->value); }
#line 2396 "parser.cpp"
break;

Expand Down
4 changes: 2 additions & 2 deletions src/arc/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ auto preprocessor::process() -> token
}
}

auto preprocessor::push_header(std::string const& file) -> void
auto preprocessor::push_header(location const& loc, std::string const& file) -> void
{
try
{
Expand All @@ -103,7 +103,7 @@ auto preprocessor::push_header(std::string const& file) -> void
for (auto& inc : includes_)
{
if (inc == name)
throw ppr_error(location{}, std::format("recursive header inclusion {} at {}", name, includes_.back()));
throw ppr_error(loc, std::format("recursive header inclusion {} at {}", name, includes_.back()));
}

auto data = ctx_->load_header(name);
Expand Down
2 changes: 1 addition & 1 deletion src/gsc/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2189,7 +2189,7 @@ namespace xsk { namespace gsc {

case 12: // inline: "#inline" expr_path ";"
#line 302 "parser.ypp"
{ ppr.push_header(yystack_[1].value.as < expr_path::ptr > ()->value); }
{ ppr.push_header(yylhs.location, yystack_[1].value.as < expr_path::ptr > ()->value); }
#line 2201 "parser.cpp"
break;

Expand Down
4 changes: 2 additions & 2 deletions src/gsc/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ auto preprocessor::process() -> token
}
}

auto preprocessor::push_header(std::string const& file) -> void
auto preprocessor::push_header(location const& loc, std::string const& file) -> void
{
try
{
Expand All @@ -103,7 +103,7 @@ auto preprocessor::push_header(std::string const& file) -> void
for (auto& inc : includes_)
{
if (inc == name)
throw ppr_error(location{}, std::format("recursive header inclusion {} at {}", name, includes_.back()));
throw ppr_error(loc, std::format("recursive header inclusion {} at {}", name, includes_.back()));
}

auto data = ctx_->load_header(name);
Expand Down

0 comments on commit 86c4def

Please sign in to comment.