From: Jacek Caban jacek@codeweavers.com
Fixes -Wincompatible-pointer-types clang warnings. --- dlls/msvcrt/tests/cpp.c | 49 ++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 23 deletions(-)
diff --git a/dlls/msvcrt/tests/cpp.c b/dlls/msvcrt/tests/cpp.c index e5fa652ede2..2dec315ba68 100644 --- a/dlls/msvcrt/tests/cpp.c +++ b/dlls/msvcrt/tests/cpp.c @@ -891,33 +891,36 @@ static void test_rtti(void) DEFINE_RTTI_REF(void, object_locator); } *obj_locator;
+ struct _rtti_base_descriptor + { + DEFINE_RTTI_REF(type_info, type_descriptor); + int num_base_classes; + struct { + int this_offset; + int vbase_descr; + int vbase_offset; + } this_ptr_offsets; + unsigned int attributes; + }; + + struct _rtti_base_array { + DEFINE_RTTI_REF(struct _rtti_base_descriptor, bases[4]); + }; + + struct _rtti_object_hierarchy { + unsigned int signature; + unsigned int attributes; + int array_len; + DEFINE_RTTI_REF(struct _rtti_base_array, base_classes); + }; + struct rtti_data { type_info type_info[4];
- struct _rtti_base_descriptor - { - DEFINE_RTTI_REF(type_info, type_descriptor); - int num_base_classes; - struct { - int this_offset; - int vbase_descr; - int vbase_offset; - } this_ptr_offsets; - unsigned int attributes; - } base_descriptor[4]; - - struct _rtti_base_array { - DEFINE_RTTI_REF(struct _rtti_base_descriptor, bases[4]); - } base_array; - - struct _rtti_object_hierarchy { - unsigned int signature; - unsigned int attributes; - int array_len; - DEFINE_RTTI_REF(struct _rtti_base_array, base_classes); - } object_hierarchy; - + struct _rtti_base_descriptor base_descriptor[4]; + struct _rtti_base_array base_array; + struct _rtti_object_hierarchy object_hierarchy; struct _object_locator object_locator; } simple_class_rtti = { { {NULL, NULL, "simple_class"} },
From: Jacek Caban jacek@codeweavers.com
Fixes clang warning: string.c:370:25: warning: implicit conversion from 'int' to 'char' changes value from 255 to -1 [-Wconstant-conversion] --- dlls/msvcp60/string.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/dlls/msvcp60/string.c b/dlls/msvcp60/string.c index 45b7a57f961..253b13b7dbe 100644 --- a/dlls/msvcp60/string.c +++ b/dlls/msvcp60/string.c @@ -27,7 +27,8 @@ #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
-#define FROZEN 255 +#define FROZEN '\xff' +#define FROZENW L'\xff'
/* _String_iterator<char> and _String_const_iterator<char> class */ typedef struct { @@ -282,7 +283,7 @@ void __thiscall basic_string_char__Tidy(basic_string_char *this, bool built) TRACE("(%p %d)\n", this, built);
if(!built || !this->ptr); - else if(!this->ptr[-1] || (unsigned char)this->ptr[-1]==FROZEN) + else if(!this->ptr[-1] || this->ptr[-1]==FROZEN) MSVCP_allocator_char_deallocate(NULL, this->ptr-1, this->res+2); else this->ptr[-1]--; @@ -301,7 +302,7 @@ bool __thiscall basic_string_char__Grow(basic_string_char *this, size_t new_size else if(this->ptr) basic_string_char__Eos(this, 0); } else if(this->res<new_size || trim || - (this->ptr && this->ptr[-1] && (unsigned char)this->ptr[-1]!=FROZEN)) { + (this->ptr && this->ptr[-1] && this->ptr[-1]!=FROZEN)) { size_t new_res = new_size, len = this->size; char *ptr;
@@ -346,7 +347,7 @@ void __thiscall basic_string_char__Split(basic_string_char *this)
TRACE("(%p)\n", this);
- if(!this->ptr || !this->ptr[-1] || (unsigned char)this->ptr[-1]==FROZEN) + if(!this->ptr || !this->ptr[-1] || this->ptr[-1]==FROZEN) return;
ptr = this->ptr; @@ -1814,7 +1815,7 @@ void __thiscall basic_string_wchar__Tidy(basic_string_wchar *this, bool built) TRACE("(%p %d)\n", this, built);
if(!built || !this->ptr); - else if(!this->ptr[-1] || (unsigned short)this->ptr[-1]==FROZEN) + else if(!this->ptr[-1] || this->ptr[-1]==FROZENW) MSVCP_allocator_wchar_deallocate(NULL, this->ptr-1, this->res+2); else this->ptr[-1]--; @@ -1833,7 +1834,7 @@ bool __thiscall basic_string_wchar__Grow(basic_string_wchar *this, size_t new_si else if(this->ptr) basic_string_wchar__Eos(this, 0); } else if(this->res<new_size || trim || - (this->ptr && this->ptr[-1] && (unsigned short)this->ptr[-1]!=FROZEN)) { + (this->ptr && this->ptr[-1] && this->ptr[-1]!=FROZENW)) { size_t new_res = new_size, len = this->size; wchar_t *ptr;
@@ -1878,7 +1879,7 @@ void __thiscall basic_string_wchar__Split(basic_string_wchar *this)
TRACE("(%p)\n", this);
- if(!this->ptr || !this->ptr[-1] || (unsigned short)this->ptr[-1]==FROZEN) + if(!this->ptr || !this->ptr[-1] || this->ptr[-1]==FROZENW) return;
ptr = this->ptr; @@ -1899,7 +1900,7 @@ void __thiscall basic_string_wchar__Freeze(basic_string_wchar *this) TRACE("(%p)\n", this); basic_string_wchar__Split(this); if(this->ptr) - this->ptr[-1] = FROZEN; + this->ptr[-1] = FROZENW; }
/* ?_Copy@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AAEXI@Z */
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=139706
Your paranoid android.
=== debian11b (64 bit WoW report) ===
dinput: device8.c:2238: Test failed: 0x700: got key_state[0] 0
This merge request was approved by Piotr Caban.
I'm curious, what's clang's problem with this?
On Thu Nov 9 22:19:55 2023 +0000, Zebediah Figura wrote:
I'm curious, what's clang's problem with this?
The warning looks like this: ``` cpp.c:927:58: warning: incompatible pointer types initializing 'struct _rtti_object_hierarchy *' with an expression of type 'struct _rtti_object_hierarchy *' [-Wincompatible-pointer-types] ```
I didn't confront it with the spec, but it apparently handles structs declared like that differently from GCC. Here is another example that shows a similar difference:
``` void test(void) { static struct t1 { struct str { char c; } *s; } s1; static struct t2 { struct str { int i; } *s; } s2; s1.s = s2.s; } ```
Clang will warn on incompatible types in assignment. GCC will error on type redefinition followed by the same warning. It seems like clang puts `struct str` differently into the (sub-)namespaces (if that makes sense in C, it would in C++...).