Make quickjs.h -Wall -Wextra -pedantic clean (#628)

Fixes: https://github.com/quickjs-ng/quickjs/issues/585
This commit is contained in:
Ben Noordhuis 2024-10-26 17:10:18 +02:00 committed by GitHub
parent 89883ae657
commit d2bca87c64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 33 additions and 21 deletions

View file

@ -83,8 +83,14 @@ distclean:
stats: $(QJS) stats: $(QJS)
$(QJS) -qd $(QJS) -qd
# implicitly .PHONY because it doesn't generate output # effectively .PHONY because it doesn't generate output
cxxtest: CXXFLAGS+=-std=c++11 -fsyntax-only -Wall -Wextra -Werror -Wno-unused-parameter ctest: CFLAGS=-std=c11 -fsyntax-only -Wall -Wextra -Werror -pedantic
ctest: ctest.c quickjs.h
$(CC) $(CFLAGS) -DJS_NAN_BOXING=0 $<
$(CC) $(CFLAGS) -DJS_NAN_BOXING=1 $<
# effectively .PHONY because it doesn't generate output
cxxtest: CXXFLAGS=-std=c++11 -fsyntax-only -Wall -Wextra -Werror -pedantic
cxxtest: cxxtest.cc quickjs.h cxxtest: cxxtest.cc quickjs.h
$(CXX) $(CXXFLAGS) -DJS_NAN_BOXING=0 $< $(CXX) $(CXXFLAGS) -DJS_NAN_BOXING=0 $<
$(CXX) $(CXXFLAGS) -DJS_NAN_BOXING=1 $< $(CXX) $(CXXFLAGS) -DJS_NAN_BOXING=1 $<
@ -116,4 +122,4 @@ unicode_gen: $(BUILD_DIR)
libunicode-table.h: unicode_gen libunicode-table.h: unicode_gen
$(BUILD_DIR)/unicode_gen unicode $@ $(BUILD_DIR)/unicode_gen unicode $@
.PHONY: all cxxtest debug fuzz install clean codegen distclean stats test test262 test262-update test262-check microbench unicode_gen $(QJS) $(QJSC) .PHONY: all ctest cxxtest debug fuzz install clean codegen distclean stats test test262 test262-update test262-check microbench unicode_gen $(QJS) $(QJSC)

17
ctest.c Normal file
View file

@ -0,0 +1,17 @@
// note: file is not actually compiled, only checked for C syntax errors
#include "quickjs.h"
int main(void)
{
JSRuntime *rt = JS_NewRuntime();
JSContext *ctx = JS_NewContext(rt);
JS_FreeValue(ctx, JS_NAN);
JS_FreeValue(ctx, JS_UNDEFINED);
JS_FreeValue(ctx, JS_NewFloat64(ctx, 42));
// not a legal way of using JS_MKPTR but this is here
// to have the compiler syntax-check its definition
JS_FreeValue(ctx, JS_MKPTR(JS_TAG_UNINITIALIZED, 0));
JS_FreeContext(ctx);
JS_FreeRuntime(rt);
return 0;
}

View file

@ -1,17 +1,2 @@
// note: file is not actually compiled, only checked for C++ syntax errors // note: file is not actually compiled, only checked for C++ syntax errors
#include "quickjs.h" #include "ctest.c"
int main(void)
{
JSRuntime *rt = JS_NewRuntime();
JSContext *ctx = JS_NewContext(rt);
JS_FreeValue(ctx, JS_NAN);
JS_FreeValue(ctx, JS_UNDEFINED);
JS_FreeValue(ctx, JS_NewFloat64(ctx, 42));
// not a legal way of using JS_MKPTR but this is here
// to have the compiler syntax-check its definition
JS_FreeValue(ctx, JS_MKPTR(JS_TAG_UNINITIALIZED, 0));
JS_FreeContext(ctx);
JS_FreeRuntime(rt);
return 0;
}

View file

@ -514,21 +514,25 @@ JS_EXTERN int JS_IsRegisteredClass(JSRuntime *rt, JSClassID class_id);
static js_force_inline JSValue JS_NewBool(JSContext *ctx, JS_BOOL val) static js_force_inline JSValue JS_NewBool(JSContext *ctx, JS_BOOL val)
{ {
(void)&ctx;
return JS_MKVAL(JS_TAG_BOOL, (val != 0)); return JS_MKVAL(JS_TAG_BOOL, (val != 0));
} }
static js_force_inline JSValue JS_NewInt32(JSContext *ctx, int32_t val) static js_force_inline JSValue JS_NewInt32(JSContext *ctx, int32_t val)
{ {
(void)&ctx;
return JS_MKVAL(JS_TAG_INT, val); return JS_MKVAL(JS_TAG_INT, val);
} }
static js_force_inline JSValue JS_NewFloat64(JSContext *ctx, double val) static js_force_inline JSValue JS_NewFloat64(JSContext *ctx, double val)
{ {
(void)&ctx;
return __JS_NewFloat64(val); return __JS_NewFloat64(val);
} }
static js_force_inline JSValue JS_NewCatchOffset(JSContext *ctx, int32_t val) static js_force_inline JSValue JS_NewCatchOffset(JSContext *ctx, int32_t val)
{ {
(void)&ctx;
return JS_MKVAL(JS_TAG_CATCH_OFFSET, val); return JS_MKVAL(JS_TAG_CATCH_OFFSET, val);
} }
@ -566,8 +570,8 @@ static inline JS_BOOL JS_IsNumber(JSValue v)
static inline JS_BOOL JS_IsBigInt(JSContext *ctx, JSValue v) static inline JS_BOOL JS_IsBigInt(JSContext *ctx, JSValue v)
{ {
int tag = JS_VALUE_GET_TAG(v); (void)&ctx;
return tag == JS_TAG_BIG_INT; return JS_VALUE_GET_TAG(v) == JS_TAG_BIG_INT;
} }
static inline JS_BOOL JS_IsBool(JSValue v) static inline JS_BOOL JS_IsBool(JSValue v)