diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3dd24908..61cd1f55 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -222,8 +222,17 @@ target_include_directories(jopa PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/codegen" "${CMAKE_BINARY_DIR}/generated" ) +# Silence third-party header warnings. +if(LIBZIP_INCLUDE_DIRS) + target_include_directories(jopa SYSTEM PRIVATE ${LIBZIP_INCLUDE_DIRS}) +endif() target_link_libraries(jopa PRIVATE ${JOPA_LIBS}) +# Suppress nullability extension noise from libzip headers when using Clang. +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options(jopa PRIVATE -Wno-nullability-extension) +endif() + # Depend on grammar generation if available if(TARGET generate_parser) add_dependencies(jopa generate_parser) diff --git a/src/error.cpp b/src/error.cpp index 3000ac04..96eba162 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -112,7 +112,7 @@ ErrorString& ErrorString::operator<<(const char* s) ErrorString& ErrorString::operator<<(int n) { char buf[64]; - sprintf(buf, "%d", n); + snprintf(buf, sizeof(buf), "%d", n); return (*this << buf); } diff --git a/src/platform.h b/src/platform.h index 5f4e9ff5..5b27c89c 100644 --- a/src/platform.h +++ b/src/platform.h @@ -98,15 +98,15 @@ # include STD_LIB_NAME(errno) #endif -#ifndef HAVE_WINT_T -/* On some systems the type wint_t is not defined in wchar.h */ -typedef unsigned int wint_t; -#endif - #ifdef HAVE_WCHAR_H # include STD_LIB_NAME(wchar) #endif +#if !defined(HAVE_WINT_T) && !defined(_WINT_T) +/* On some systems the type wint_t is not defined in wchar.h */ +typedef unsigned int wint_t; +#endif + #ifdef HAVE_CTYPE_H # include STD_LIB_NAME(ctype) #endif diff --git a/src/symbol.cpp b/src/symbol.cpp index f6f26430..1205d702 100644 --- a/src/symbol.cpp +++ b/src/symbol.cpp @@ -1037,8 +1037,8 @@ void DirectorySymbol::ReadDirectory() { int len = DirectoryNameLength() + strlen(entry -> d_name); char* filename = new char[len + 2]; // +2 for '/', NUL - sprintf(filename, "%s/%s", DirectoryName(), - entry -> d_name); + snprintf(filename, len + 2, "%s/%s", DirectoryName(), + entry -> d_name); struct stat status; if(JopaAPI::getInstance() -> stat(filename, &status) == 0) entries -> InsertEntry(this, entry -> d_name, length); diff --git a/src/zipfile.h b/src/zipfile.h index ee9ae686..c6464b92 100644 --- a/src/zipfile.h +++ b/src/zipfile.h @@ -2,7 +2,14 @@ #include "platform.h" #include "tuple.h" +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnullability-extension" +#endif #include +#if defined(__clang__) +#pragma clang diagnostic pop +#endif namespace Jopa { // Open namespace Jopa block diff --git a/vendor/jikespg/src/lpgparse.c b/vendor/jikespg/src/lpgparse.c index 7e19d4a4..082e1fd9 100644 --- a/vendor/jikespg/src/lpgparse.c +++ b/vendor/jikespg/src/lpgparse.c @@ -392,7 +392,8 @@ static void options(void) while (parm[i] != '\0') /* Repeat until parm line is exhausted */ { - strcpy(parm, parm + i); /* Remove garbage in front */ + /* Use memmove because source and destination overlap. */ + memmove(parm, parm + i, strlen(parm + i) + 1); /* Remove garbage in front */ i = 0; @@ -442,7 +443,8 @@ static void options(void) { /* prefix? */ flag = FALSE; len = len-2; - strcpy(token, token + 2); /* get rid of "NO" prefix */ + /* Overlapping copy; memmove keeps it defined. */ + memmove(token, token + 2, strlen(token + 2) + 1); /* get rid of "NO" prefix */ } else flag = TRUE;