Skip to content

Commit

Permalink
Add -Wmissing-noreturn, and add attributes
Browse files Browse the repository at this point in the history
Enable another useful compiler warning.  This one ensures that functions
which don't return are marked thus.

If found a couple of json-related error functions that ought to be
marked up.
  • Loading branch information
jbytheway committed Feb 15, 2020
1 parent e47abc7 commit c036d01
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,12 @@ ELSE()
SET(CATA_WARNINGS
"-Werror -Wall -Wextra \
-Wmissing-declarations \
-Wmissing-noreturn \
-Wold-style-cast \
-Woverloaded-virtual \
-Wsuggest-override \
-Wno-unknown-warning-option \
-Wpedantic")
-Wpedantic \
-Wno-unknown-warning-option")
# Compact the whitespace in the warning string
string(REGEX REPLACE "[\t ]+" " " CATA_WARNINGS "${CATA_WARNINGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CATA_WARNINGS}")
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@ RELEASE_FLAGS =
WARNINGS = \
-Werror -Wall -Wextra \
-Wmissing-declarations \
-Wmissing-noreturn \
-Wold-style-cast \
-Woverloaded-virtual \
-Wpedantic \
-Wsuggest-override \
-Wno-unknown-warning-option \
-Wpedantic
-Wno-unknown-warning-option
# Uncomment below to disable warnings
#WARNINGS = -w
DEBUGSYMS = -g
Expand Down
7 changes: 3 additions & 4 deletions src/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ class JsonIn
} catch( const io::InvalidEnumString & ) {
seek( old_offset ); // so the error message points to the correct place.
error( "invalid enumeration value" );
throw; // ^^ error already throws, but the compiler doesn't know that )-:
}
}

Expand Down Expand Up @@ -1013,8 +1012,8 @@ class JsonArray
size_t size() const;
bool empty();
std::string str(); // copy array json as string
void throw_error( std::string err );
void throw_error( std::string err, int idx );
[[noreturn]] void throw_error( std::string err );
[[noreturn]] void throw_error( std::string err, int idx );

// iterative access
bool next_bool();
Expand Down Expand Up @@ -1138,7 +1137,7 @@ class JsonValue
return seek().test_array();
}

void throw_error( const std::string &err ) const {
[[noreturn]] void throw_error( const std::string &err ) const {
seek().error( err );
}

Expand Down

0 comments on commit c036d01

Please sign in to comment.