Skip to content

Enable -Wundef compiler warning #5526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/actions/configure-x64/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,4 @@ runs:
--with-config-file-scan-dir=/etc/php.d \
--with-pdo-firebird \
--with-pdo-dblib \
--enable-werror \
${{ inputs.configurationParameters }}
2 changes: 1 addition & 1 deletion Zend/Zend.m4
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ else
AC_DEFINE(ZEND_DEBUG,0,[ ])
fi

test -n "$GCC" && CFLAGS="-Wall -Wextra -Wno-strict-aliasing -Wno-unused-parameter -Wno-sign-compare $CFLAGS"
test -n "$GCC" && CFLAGS="-Wall -Wextra -Wundef -Wno-strict-aliasing -Wno-unused-parameter -Wno-sign-compare $CFLAGS"
dnl Check if compiler supports -Wno-clobbered (only GCC)
AX_CHECK_COMPILE_FLAG([-Wno-clobbered], CFLAGS="-Wno-clobbered $CFLAGS", , [-Werror])
dnl Check for support for implicit fallthrough level 1, also add after previous CFLAGS as level 3 is enabled in -Wextra
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -3010,7 +3010,7 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
{
zval *ptr;
zend_object *zobj;
zend_string *name, *tmp_name;
zend_string *name, *tmp_name = NULL;

if (container_op_type != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) {
do {
Expand Down
4 changes: 0 additions & 4 deletions Zend/zend_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@
#include "zend_API.h"
#include "zend_fibers.h"

#ifndef GC_BENCH
# define GC_BENCH 0
#endif

#ifndef ZEND_GC_DEBUG
# define ZEND_GC_DEBUG 0
#endif
Expand Down
4 changes: 4 additions & 0 deletions Zend/zend_gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

BEGIN_EXTERN_C()

#ifndef GC_BENCH
# define GC_BENCH 0
#endif

typedef struct _zend_gc_status {
uint32_t runs;
uint32_t collected;
Expand Down
1 change: 0 additions & 1 deletion azure/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ steps:
--with-pdo-dblib \
--with-pdo-oci=shared,instantclient,/opt/oracle/instantclient \
--with-oci8=shared,instantclient,/opt/oracle/instantclient \
--enable-werror \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d
displayName: 'Configure Build'
2 changes: 1 addition & 1 deletion ext/date/config0.m4
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ AC_CHECK_HEADERS([io.h])
dnl Check for strtoll, atoll
AC_CHECK_FUNCS(strtoll atoll)

PHP_DATE_CFLAGS="-Wno-implicit-fallthrough -I@ext_builddir@/lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DHAVE_TIMELIB_CONFIG_H=1"
PHP_DATE_CFLAGS="-Wno-implicit-fallthrough -Wno-undef -I@ext_builddir@/lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DHAVE_TIMELIB_CONFIG_H=1"
timelib_sources="lib/astro.c lib/dow.c lib/parse_date.c lib/parse_tz.c lib/parse_posix.c
lib/timelib.c lib/tm2unixtime.c lib/unixtime2tm.c lib/parse_iso_intervals.c lib/interval.c"

Expand Down
3 changes: 2 additions & 1 deletion ext/fileinfo/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ int main(void)
libmagic_sources="$libmagic_sources libmagic/strcasestr.c"
],[AC_MSG_RESULT([skipped, cross-compiling])])

PHP_NEW_EXTENSION(fileinfo, fileinfo.c $libmagic_sources, $ext_shared,,-I@ext_srcdir@/libmagic)
PHP_FILEINFO_CFLAGS="-Wno-undef -I@ext_srcdir@/libmagic"
PHP_NEW_EXTENSION(fileinfo, fileinfo.c $libmagic_sources, $ext_shared,,$PHP_FILEINFO_CFLAGS)
PHP_ADD_BUILD_DIR($ext_builddir/libmagic)

AC_CHECK_FUNCS([utimes strndup])
Expand Down
6 changes: 3 additions & 3 deletions ext/hash/hash_crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ PHP_HASH_API void PHP_CRC32Update(PHP_CRC32_CTX *context, const unsigned char *i
{
size_t i = 0;

#if ZEND_INTRIN_SSE4_2_PCLMUL_NATIVE || ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER
#if defined(ZEND_INTRIN_SSE4_2_PCLMUL_NATIVE) || defined(ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER)
i += crc32_x86_simd_update(X86_CRC32, &context->state, input, len);
#endif

Expand All @@ -42,7 +42,7 @@ PHP_HASH_API void PHP_CRC32BUpdate(PHP_CRC32_CTX *context, const unsigned char *
{
size_t i = 0;

#if ZEND_INTRIN_SSE4_2_PCLMUL_NATIVE || ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER
#if defined(ZEND_INTRIN_SSE4_2_PCLMUL_NATIVE) || defined(ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER)
i += crc32_x86_simd_update(X86_CRC32B, &context->state, input, len);
#endif

Expand All @@ -55,7 +55,7 @@ PHP_HASH_API void PHP_CRC32CUpdate(PHP_CRC32_CTX *context, const unsigned char *
{
size_t i = 0;

#if ZEND_INTRIN_SSE4_2_PCLMUL_NATIVE || ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER
#if defined(ZEND_INTRIN_SSE4_2_PCLMUL_NATIVE) || defined(ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER)
i += crc32_x86_simd_update(X86_CRC32C, &context->state, input, len);
#endif

Expand Down
2 changes: 1 addition & 1 deletion ext/mysqlnd/mysqlnd_result.c
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ MYSQLND_METHOD(mysqlnd_res, fetch_into)(MYSQLND_RES * result, const unsigned int
static MYSQLND_ROW_C
MYSQLND_METHOD(mysqlnd_res, fetch_row_c)(MYSQLND_RES * result)
{
bool fetched_anything;
bool fetched_anything = false;
zval *row_data;
MYSQLND_ROW_C ret = NULL;
DBG_ENTER("mysqlnd_res::fetch_row_c");
Expand Down
4 changes: 2 additions & 2 deletions ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ static int zend_get_stream_timestamp(const char *filename, zend_stat_t *statbuf)
return SUCCESS;
}

#if ZEND_WIN32
#ifdef ZEND_WIN32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to commit the obvious fixes (like this) separately.

static accel_time_t zend_get_file_handle_timestamp_win(zend_file_handle *file_handle, size_t *size)
{
static unsigned __int64 utc_base = 0;
Expand Down Expand Up @@ -2176,7 +2176,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
HANDLE_UNBLOCK_INTERRUPTIONS();
} else {

#if !ZEND_WIN32
#ifndef ZEND_WIN32
ZCSG(hits)++; /* TBFixed: may lose one hit */
persistent_script->dynamic_members.hits++; /* see above */
#else
Expand Down
4 changes: 2 additions & 2 deletions ext/opcache/ZendAccelerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
/* 8 - Standalone Open Source Zend OPcache */
#define ACCELERATOR_API_NO 8

#if ZEND_WIN32
#ifdef ZEND_WIN32
# include "zend_config.w32.h"
#else
#include "zend_config.h"
Expand Down Expand Up @@ -97,7 +97,7 @@ extern int lock_file;
# define ENABLE_FILE_CACHE_FALLBACK 0
#endif

#if ZEND_WIN32
#ifdef ZEND_WIN32
typedef unsigned __int64 accel_time_t;
#else
typedef time_t accel_time_t;
Expand Down
2 changes: 1 addition & 1 deletion ext/opcache/jit/vtune/ittnotify_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ ITT_INLINE long __itt_interlocked_increment(volatile long* ptr)
#define __itt_fstrdup(s) strdup(s)
#define __itt_thread_id() pthread_self()
#define __itt_thread_yield() sched_yield()
#if ITT_ARCH==ITT_ARCH_IA64
#if defined(ITT_ARCH_IA64) && ITT_ARCH==ITT_ARCH_IA64
#ifdef __INTEL_COMPILER
#define __TBB_machine_fetchadd4(addr, val) __fetchadd4_acq((void *)addr, val)
#else /* __INTEL_COMPILER */
Expand Down
14 changes: 7 additions & 7 deletions ext/opcache/jit/zend_jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ static int sp_adj[SP_ADJ_LAST];
# pragma clang diagnostic pop
#endif

#if _WIN32
#ifdef _WIN32
# include <Windows.h>
#else
# include <sys/mman.h>
Expand Down Expand Up @@ -4616,7 +4616,7 @@ ZEND_EXT_API void zend_jit_unprotect(void)
fprintf(stderr, "mprotect() failed [%d] %s\n", errno, strerror(errno));
}
}
#elif _WIN32
#elif defined(_WIN32)
if (!(JIT_G(debug) & (ZEND_JIT_DEBUG_GDB|ZEND_JIT_DEBUG_PERF_DUMP))) {
DWORD old, new;
#ifdef ZTS
Expand All @@ -4642,7 +4642,7 @@ ZEND_EXT_API void zend_jit_protect(void)
fprintf(stderr, "mprotect() failed [%d] %s\n", errno, strerror(errno));
}
}
#elif _WIN32
#elif defined(_WIN32)
if (!(JIT_G(debug) & (ZEND_JIT_DEBUG_GDB|ZEND_JIT_DEBUG_PERF_DUMP))) {
DWORD old;

Expand Down Expand Up @@ -4907,7 +4907,7 @@ ZEND_EXT_API int zend_jit_startup(void *buf, size_t size, bool reattached)
fprintf(stderr, "mprotect() failed [%d] %s\n", errno, strerror(errno));
}
}
#elif _WIN32
#elif defined(_WIN32)
if (JIT_G(debug) & (ZEND_JIT_DEBUG_GDB|ZEND_JIT_DEBUG_PERF_DUMP)) {
DWORD old;

Expand All @@ -4933,7 +4933,7 @@ ZEND_EXT_API int zend_jit_startup(void *buf, size_t size, bool reattached)
if (!reattached) {
zend_jit_unprotect();
*dasm_ptr = dasm_buf;
#if _WIN32
#ifdef _WIN32
/* reserve space for global labels */
*dasm_ptr = (void**)*dasm_ptr + zend_lb_MAX;
#endif
Expand All @@ -4958,7 +4958,7 @@ ZEND_EXT_API int zend_jit_startup(void *buf, size_t size, bool reattached)
if (!reattached) {
zend_jit_unprotect();
ret = zend_jit_make_stubs();
#if _WIN32
#ifdef _WIN32
/* save global labels */
memcpy(dasm_buf, dasm_labels, sizeof(void*) * zend_lb_MAX);
#endif
Expand All @@ -4968,7 +4968,7 @@ ZEND_EXT_API int zend_jit_startup(void *buf, size_t size, bool reattached)
return FAILURE;
}
} else {
#if _WIN32
#ifdef _WIN32
/* restore global labels */
memcpy(dasm_labels, dasm_buf, sizeof(void*) * zend_lb_MAX);
zend_jit_init_handlers();
Expand Down
18 changes: 9 additions & 9 deletions ext/opcache/jit/zend_jit_x86.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const char* zend_reg_name[] = {

static void* dasm_labels[zend_lb_MAX];

#if ZTS
#ifdef ZTS
static size_t tsrm_ls_cache_tcb_offset = 0;
static size_t tsrm_tls_index;
static size_t tsrm_tls_offset;
Expand Down Expand Up @@ -2831,7 +2831,7 @@ static const zend_jit_stub zend_jit_stubs[] = {
#endif
};

#if ZTS && defined(ZEND_WIN32)
#if defined(ZTS) && defined(ZEND_WIN32)
extern uint32_t _tls_index;
extern char *_tls_start;
extern char *_tls_end;
Expand Down Expand Up @@ -2894,7 +2894,7 @@ static int zend_jit_setup(void)
allowed_opt_flags |= ZEND_JIT_CPU_AVX;
}

#if ZTS
#ifdef ZTS
# ifdef _WIN64
tsrm_tls_index = _tls_index * sizeof(void*);

Expand All @@ -2919,7 +2919,7 @@ static int zend_jit_setup(void)
return FAILURE;
}
} while(0);
# elif ZEND_WIN32
# elif defined(ZEND_WIN32)
tsrm_tls_index = _tls_index * sizeof(void*);

/* To find offset of "_tsrm_ls_cache" in TLS segment we perform a linear scan of local TLS memory */
Expand Down Expand Up @@ -3192,7 +3192,7 @@ static int zend_jit_trace_begin(dasm_State **Dst, uint32_t trace_num, zend_jit_t
{
zend_regset regset = ZEND_REGSET_SCRATCH;

#if ZTS
#ifdef ZTS
if (1) {
#else
if ((sizeof(void*) == 8 && !IS_SIGNED_32BIT(&EG(jit_trace_num)))) {
Expand Down Expand Up @@ -7997,15 +7997,15 @@ static int zend_jit_cmp(dasm_State **Dst,
}
| mov eax, dword T1 // restore
} else if (may_throw) {
#if ZTS
#ifdef ZTS
| mov dword T1, eax // save
#else
if ((sizeof(void*) == 8 && !IS_SIGNED_32BIT(&EG(exception)))) {
| mov dword T1, eax // save
}
#endif
zend_jit_check_exception_undef_result(Dst, opline);
#if ZTS
#ifdef ZTS
| mov eax, dword T1 // restore
#else
if ((sizeof(void*) == 8 && !IS_SIGNED_32BIT(&EG(exception)))) {
Expand Down Expand Up @@ -16233,7 +16233,7 @@ bw_op:
if (ssa_op == ssa->ops
&& (JIT_G(current_trace)->stop == ZEND_JIT_TRACE_STOP_LOOP ||
JIT_G(current_trace)->stop == ZEND_JIT_TRACE_STOP_RECURSIVE_CALL)) {
#if ZTS
#ifdef ZTS
ZEND_REGSET_INCL(regset, ZREG_R0);
#else
if ((sizeof(void*) == 8 && !IS_SIGNED_32BIT(&EG(vm_interrupt)))) {
Expand All @@ -16246,7 +16246,7 @@ bw_op:

if ((ssa->cfg.blocks[b].flags & ZEND_BB_LOOP_HEADER) != 0
&& ssa->cfg.blocks[b].start == ssa_op - ssa->ops) {
#if ZTS
#ifdef ZTS
ZEND_REGSET_INCL(regset, ZREG_R0);
#else
if ((sizeof(void*) == 8 && !IS_SIGNED_32BIT(&EG(vm_interrupt)))) {
Expand Down
10 changes: 5 additions & 5 deletions ext/opcache/zend_accelerator_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "ext/standard/php_filestat.h"
#include "opcache_arginfo.h"

#if HAVE_JIT
#ifdef HAVE_JIT
#include "jit/zend_jit.h"
#endif

Expand Down Expand Up @@ -280,7 +280,7 @@ ZEND_INI_BEGIN()
#ifndef ZEND_WIN32
STD_PHP_INI_ENTRY("opcache.preload_user" , "" , PHP_INI_SYSTEM, OnUpdateStringUnempty, accel_directives.preload_user, zend_accel_globals, accel_globals)
#endif
#if ZEND_WIN32
#ifdef ZEND_WIN32
STD_PHP_INI_ENTRY("opcache.cache_id" , "" , PHP_INI_SYSTEM, OnUpdateString, accel_directives.cache_id, zend_accel_globals, accel_globals)
#endif
#ifdef HAVE_JIT
Expand Down Expand Up @@ -436,7 +436,7 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS)
} else {
php_info_print_table_row(2, "File Cache", "Disabled");
}
#if HAVE_JIT
#ifdef HAVE_JIT
if (JIT_G(enabled)) {
if (JIT_G(on)) {
php_info_print_table_row(2, "JIT", "On");
Expand Down Expand Up @@ -689,7 +689,7 @@ ZEND_FUNCTION(opcache_get_status)
add_assoc_zval(return_value, "scripts", &scripts);
}
}
#if HAVE_JIT
#ifdef HAVE_JIT
zend_jit_status(return_value);
#endif
}
Expand Down Expand Up @@ -770,7 +770,7 @@ ZEND_FUNCTION(opcache_get_configuration)
#ifndef ZEND_WIN32
add_assoc_string(&directives, "opcache.preload_user", STRING_NOT_NULL(ZCG(accel_directives).preload_user));
#endif
#if ZEND_WIN32
#ifdef ZEND_WIN32
add_assoc_string(&directives, "opcache.cache_id", STRING_NOT_NULL(ZCG(accel_directives).cache_id));
#endif
#ifdef HAVE_JIT
Expand Down
2 changes: 1 addition & 1 deletion ext/opcache/zend_file_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include <sys/stat.h>
#include <fcntl.h>

#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion ext/readline/php_readline.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef PHP_READLINE_H
#define PHP_READLINE_H

#if HAVE_LIBREADLINE || HAVE_LIBEDIT
#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)

extern zend_module_entry readline_module_entry;
#define phpext_readline_ptr &readline_module_entry
Expand Down
Loading