Skip to content

Commit 9ca5f97

Browse files
committed
Make cpp2util.h warning-clean too, on all major compilers (/W4, -Wall -Wextra)
And increase MSVC warning-clean level to /W4 for everything
1 parent b74a336 commit 9ca5f97

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

include/cpp2util.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ struct {
351351
}
352352
} unique;
353353

354-
struct {
354+
[[maybe_unused]] struct {
355355
template<typename T>
356356
[[nodiscard]] auto cpp2_new(auto&& ...args) const -> std::shared_ptr<T> {
357357
return std::make_shared<T>(std::forward<decltype(args)>(args)...);
@@ -1123,7 +1123,19 @@ class c_raii {
11231123
};
11241124

11251125
inline auto fopen( const char* filename, const char* mode ) {
1126+
1127+
// Suppress annoying deprecation warning about fopen
1128+
#ifdef _MSC_VER
1129+
#pragma warning( push )
1130+
#pragma warning( disable : 4996 )
1131+
#endif
1132+
11261133
auto x = std::fopen(filename, mode);
1134+
1135+
#ifdef _MSC_VER
1136+
#pragma warning( pop )
1137+
#endif
1138+
11271139
if (!x) {
11281140
throw std::make_error_condition(std::errc::no_such_file_or_directory);
11291141
}

source/parse.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3287,9 +3287,9 @@ class parser
32873287

32883288
if (body->statements.empty() || body->statements.back()->statement.index() != statement_node::return_)
32893289
{
3290-
auto pos = body->statements.back()->position();
3291-
++pos.lineno;
3292-
generated_tokens_->emplace_back( "return", pos, lexeme::Keyword);
3290+
auto last_pos = body->statements.back()->position();
3291+
++last_pos.lineno;
3292+
generated_tokens_->emplace_back( "return", last_pos, lexeme::Keyword);
32933293

32943294
auto ret = std::make_unique<return_statement_node>();
32953295
ret->identifier = &generated_tokens_->back();

0 commit comments

Comments
 (0)