mirror of
https://github.com/curl/curl.git
synced 2026-04-15 01:11:40 +03:00
Some GNU C version guards implicitly include the clang compiler, because clang reports itself as GCC 4.2.1. This implicit inclusion doesn't happen if the guard requires a GCC version above 4.2.1. Fix two such guards to explicitly include clang where it does support the guarded feature: - curl/curl.h: use `typecheck-gcc.h` with clang. llvm clang v14+ supports this. The corresponding Apple clang version is also v14. Ref: https://en.wikipedia.org/wiki/Xcode#Toolchain_versions Apple clang v14 tested OK in CI: https://github.com/curl/curl/actions/runs/16353901480/job/46207437204 - tool_urlglib: use `__builtin_mul_overflow()` with clang v8+. llvm clang v3.8+ supports this, but to accommodate for Apple clang, start with v8, the Apple version having the mainline v3.8 feature set. Also fix compile warnings triggered by the above: - lib1912: fix duplicate `;`: ``` tests/libtest/lib1912.c:44:57: error: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Werror,-Wextra-semi-stmt] 44 | print_err(o->name, "CURLOT_LONG or CURLOT_VALUES"); | ^ [...] ``` Ref: https://github.com/curl/curl/actions/runs/16351302841/job/46198524880?pr=17955#step:12:61 - lib2032: silence typcheck warning with a cast: ``` tests/libtest/lib2032.c:145:29: error: sizeof on pointer operation will return size of 'CURL **' (aka 'void **') instead of 'CURL *[3]' (aka 'void *[3]') [-Werror,-Wsizeof-array-decay] 145 | ntlm_easy + num_handles); | ~~~~~~~~~ ^ ``` Ref: https://github.com/curl/curl/actions/runs/16351302841/job/46198524880?pr=17955#step:12:86 Closes #17955
81 lines
2.9 KiB
C
81 lines
2.9 KiB
C
/***************************************************************************
|
|
* _ _ ____ _
|
|
* Project ___| | | | _ \| |
|
|
* / __| | | | |_) | |
|
|
* | (__| |_| | _ <| |___
|
|
* \___|\___/|_| \_\_____|
|
|
*
|
|
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
*
|
|
* This software is licensed as described in the file COPYING, which
|
|
* you should have received as part of this distribution. The terms
|
|
* are also available at https://curl.se/docs/copyright.html.
|
|
*
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
* SPDX-License-Identifier: curl
|
|
*
|
|
***************************************************************************/
|
|
#include "first.h"
|
|
|
|
#include "memdebug.h"
|
|
|
|
#define print_err(name, exp) \
|
|
curl_mfprintf(stderr, "Type mismatch for CURLOPT_%s (expected %s)\n", \
|
|
name, exp)
|
|
|
|
static CURLcode test_lib1912(char *URL)
|
|
{
|
|
/* Only test if GCC typechecking is available */
|
|
int error = 0;
|
|
#ifdef CURLINC_TYPECHECK_GCC_H
|
|
const struct curl_easyoption *o;
|
|
for(o = curl_easy_option_next(NULL);
|
|
o;
|
|
o = curl_easy_option_next(o)) {
|
|
/* Test for mismatch OR missing typecheck macros */
|
|
if(curlcheck_long_option(o->id) !=
|
|
(o->type == CURLOT_LONG || o->type == CURLOT_VALUES)) {
|
|
print_err(o->name, "CURLOT_LONG or CURLOT_VALUES");
|
|
error++;
|
|
}
|
|
if(curlcheck_off_t_option(o->id) != (o->type == CURLOT_OFF_T)) {
|
|
print_err(o->name, "CURLOT_OFF_T");
|
|
error++;
|
|
}
|
|
if(curlcheck_string_option(o->id) != (o->type == CURLOT_STRING)) {
|
|
print_err(o->name, "CURLOT_STRING");
|
|
error++;
|
|
}
|
|
if(curlcheck_slist_option(o->id) != (o->type == CURLOT_SLIST)) {
|
|
print_err(o->name, "CURLOT_SLIST");
|
|
error++;
|
|
}
|
|
if(curlcheck_cb_data_option(o->id) != (o->type == CURLOT_CBPTR)) {
|
|
print_err(o->name, "CURLOT_CBPTR");
|
|
error++;
|
|
}
|
|
/* From here: only test that the type matches if macro is known */
|
|
if(curlcheck_write_cb_option(o->id) && (o->type != CURLOT_FUNCTION)) {
|
|
print_err(o->name, "CURLOT_FUNCTION");
|
|
error++;
|
|
}
|
|
if(curlcheck_conv_cb_option(o->id) && (o->type != CURLOT_FUNCTION)) {
|
|
print_err(o->name, "CURLOT_FUNCTION");
|
|
error++;
|
|
}
|
|
if(curlcheck_postfields_option(o->id) && (o->type != CURLOT_OBJECT)) {
|
|
print_err(o->name, "CURLOT_OBJECT");
|
|
error++;
|
|
}
|
|
/* Todo: no gcc typecheck for CURLOPTTYPE_BLOB types? */
|
|
}
|
|
#endif
|
|
(void)URL;
|
|
return error == 0 ? CURLE_OK : TEST_ERR_FAILURE;
|
|
}
|