Skip to content

Commit

Permalink
fixes to error reporting string formats (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
sylefeb committed Aug 24, 2023
1 parent 10c3060 commit 3d12246
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND
message(FATAL_ERROR "Silice requires g++ 8 at least")
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=format -Werror=format-security")
endif()


set(STD_FS_LIB "")
# ==== The test below is based on https://github.com/pybind/pybind11/blob/master/tests/CMakeLists.txt
# It is under a BSD-style license, see https://github.com/pybind/pybind11/blob/master/LICENSE
Expand Down
4 changes: 2 additions & 2 deletions src/Algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6295,7 +6295,7 @@ void Algorithm::checkExpressions(const t_instantiation_context &ictx,antlr4::tre
if (A != m_InstancedBlueprints.end()) { // algorithm?
Algorithm *alg = dynamic_cast<Algorithm*>(A->second.blueprint.raw());
if (alg == nullptr) {
reportError(sourceloc(async), "called instance '%s' is not an algorithm", async->IDENTIFIER()->getText().c_str());
reportError(sourceloc(sync), "called instance '%s' is not an algorithm", sync->joinExec()->IDENTIFIER()->getText().c_str());
} else {
// if parameters are given, check, otherwise we allow call without parameters (bindings may exist)
if (!sync->callParamList()->expression_0().empty()) {
Expand Down Expand Up @@ -6333,7 +6333,7 @@ void Algorithm::checkExpressions(const t_instantiation_context &ictx,antlr4::tre
if (A != m_InstancedBlueprints.end()) { // algorithm?
Algorithm *alg = dynamic_cast<Algorithm*>(A->second.blueprint.raw());
if (alg == nullptr) {
reportError(sourceloc(async), "joined instance '%s' is not an algorithm", async->IDENTIFIER()->getText().c_str());
reportError(sourceloc(join), "joined instance '%s' is not an algorithm", join->IDENTIFIER()->getText().c_str());
} else {
// if parameters are given, check, otherwise we allow call without parameters (bindings may exist)
if (!join->callParamList()->expression_0().empty()) {
Expand Down
2 changes: 1 addition & 1 deletion src/LuaPreProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ void LuaPreProcessor::decomposeSource(
if (w == "unit" || w == "algorithm" || w == "algorithm#" || w == "circuitry") {
std::string name = parser.readString("( \t\r");
if (name.empty()) {
throw Fatal((w + " has no name").c_str()); // TODO: improve error report (line)
throw Fatal("%s",(w + " has no name").c_str()); // TODO: improve error report (line)
}
cerr << "functionalizing " << w << ' ' << name << '\n';
if (w == "algorithm#") {
Expand Down

0 comments on commit 3d12246

Please sign in to comment.