diff --git a/m-core.h b/m-core.h index 20c63faa..730cb30b 100644 --- a/m-core.h +++ b/m-core.h @@ -107,29 +107,34 @@ /* Ignore some warnings detected by some compilers in the library. * Whatever we do, there is some warnings that cannot be fixed. * So they are ignored in order to avoid polluting the user with - * theses warnings. - * They are: + * theses warnings. They are: + * * * If we build in C++ mode, they are warnings about using the C * dialect. It is expected as M*LIB is a C library. * - * * For clang, additional warnings are ignored since their detection are broken - * in the context of M*LIB: - * - unused generated inline functions - * https://bugs.llvm.org//show_bug.cgi?id=22712 + * * For clang, the generated functions may not be always used, + * and CLANG failed to relalize it. + * See https://bugs.llvm.org//show_bug.cgi?id=22712 + * + * * A manualy created buffer is given to fscanf. It is needed + * to give the size of the array of char to fscanf (this is the safe way). */ #if defined(__clang__) && defined(__cplusplus) +/* Warnings disabled for CLANG in C++ mode */ #if __clang_major__ >= 6 #define M_BEGIN_PROTECTED_CODE \ _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \ _Pragma("clang diagnostic ignored \"-Wzero-as-null-pointer-constant\"") \ - _Pragma("clang diagnostic ignored \"-Wunused-function\"") + _Pragma("clang diagnostic ignored \"-Wunused-function\"") \ + _Pragma("clang diagnostic ignored \"-Wformat-nonliteral\"") #else #define M_BEGIN_PROTECTED_CODE \ _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \ - _Pragma("clang diagnostic ignored \"-Wunused-function\"") + _Pragma("clang diagnostic ignored \"-Wunused-function\"") \ + _Pragma("clang diagnostic ignored \"-Wformat-nonliteral\"") #endif #define M_END_PROTECTED_CODE \ @@ -137,28 +142,43 @@ #elif defined(__GNUC__) && defined(__cplusplus) -/* G++ doesn't support well disabling temporary warnings. +/* Warnings disabled for GNU C in C++ mode + * However, G++ doesn't support well disabling temporary warnings. * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431 */ #define M_BEGIN_PROTECTED_CODE \ _Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic ignored \"-Wold-style-cast\"") \ - _Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"") + _Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"") \ + _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"") #define M_END_PROTECTED_CODE \ _Pragma("GCC diagnostic pop") #elif defined(__clang__) +/* Warnings disabled for CLANG in C mode */ #define M_BEGIN_PROTECTED_CODE \ _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Wunused-function\"") + _Pragma("clang diagnostic ignored \"-Wunused-function\"") \ + _Pragma("clang diagnostic ignored \"-Wformat-nonliteral\"") #define M_END_PROTECTED_CODE \ _Pragma("clang diagnostic pop") +#elif defined(__GNUC__) + +/* Warnings disabled for GNU C in C mode */ +#define M_BEGIN_PROTECTED_CODE \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"") + +#define M_END_PROTECTED_CODE \ + _Pragma("GCC diagnostic pop") + #else +/* No warnings disabled */ #define M_BEGIN_PROTECTED_CODE #define M_END_PROTECTED_CODE diff --git a/tests/Makefile b/tests/Makefile index 2751fd44..0c649a31 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -21,7 +21,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. CC=cc -std=c99 -WCFLAGS_GCC=-Wall -W -pedantic -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith -Wbad-function-cast -Wstrict-overflow=5 -Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wunreachable-code -Wlogical-op -Wstrict-aliasing=2 -Wredundant-decls -Wold-style-definition -Wunused-function -ftrapv -Wsign-conversion -Wdate-time -Wconversion -Wformat=2 -Winit-self -Wjump-misses-init -Wstack-protector -Wtrampolines -Wwrite-strings -Wformat-security -Wno-float-conversion -Wno-format-nonliteral +WCFLAGS_GCC=-Wall -W -pedantic -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith -Wbad-function-cast -Wstrict-overflow=5 -Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wunreachable-code -Wlogical-op -Wstrict-aliasing=2 -Wredundant-decls -Wold-style-definition -Wunused-function -ftrapv -Wsign-conversion -Wdate-time -Wconversion -Wformat=2 -Winit-self -Wjump-misses-init -Wstack-protector -Wtrampolines -Wwrite-strings -Wformat-security -Wno-float-conversion WCFLAGS_CLANG=-Wall -W -pedantic -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith -Wbad-function-cast -Wstrict-overflow=5 -Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wunreachable-code -Wstrict-aliasing=2 -Wredundant-decls -Wold-style-definition -Wunused-function -ftrapv -Wsign-conversion WCFLAGS_CPP=-Wall -W -pedantic -Wshadow -Wpointer-arith -Wcast-qual -Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith -Wstrict-overflow=5 -Winline -Wundef -Wcast-qual -Wshadow -Wunreachable-code -Wstrict-aliasing=2 -Wredundant-decls -Wunused-function -ftrapv -Wsign-conversion XCFLAGS=