[PATCH 0/3] MR10884: Use non-static objects in tests to avoid clang compilation errors
I was building wine with tests using clang-11 and discovered following errors: wine-iviv/dlls/winmm/tests/wave.c:2453:22: error: initializer element is not a compile-time constant .SubFormat = KSDATAFORMAT_SUBTYPE_PCM, wine-iviv/dlls/dmsynth/tests/dmsynth.c:1788:9: error: initializer element is not a compile-time constant default_note_on, wine-iviv/dlls/vccorlib140/tests/vccorlib.c:707:38: error: initializer element is not a compile-time constant static const GUID guids_src\[\] = {IID_IUnknown, IID_IInspectable, IID_IAgileObject, IID_IMarshal, guid_null}; wine-iviv/dlls/vccorlib140/tests/vccorlib.c:1378:34: error: initializer element is not a compile-time constant {TYPECODE_GUID, {.guid = IID_IInspectable}, PropertyType_Guid, sizeof(GUID), L"{af86e2e0-b12d-4c6a-9c5a-d7aa65101e90}"}, wine-iviv/dlls/vccorlib140/tests/vccorlib.c:2193:30: error: initializer element is not a compile-time constant static const GUID guid = IID_IInspectable; For newer clang versions (tested for clang-19) there is no problem, but older clang-11 does not recognize these objects as compile-time constants. So i removed "static" where needed, making it automatic/runtime initializations. These changes do not change tests behavior at all, tested for both 64-bit and 32-bit versions. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10884
From: Ivan Ivlev <iviv@etersoft.ru> Signed-off-by: Ivan Ivlev <iviv@etersoft.ru> --- dlls/winmm/tests/wave.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/winmm/tests/wave.c b/dlls/winmm/tests/wave.c index f6917799207..05c0e68de22 100644 --- a/dlls/winmm/tests/wave.c +++ b/dlls/winmm/tests/wave.c @@ -2439,7 +2439,7 @@ void fill_wave_formats(const WAVEFORMATEXTENSIBLE *base_fmt) static void test_formats(void) { - static const WAVEFORMATEXTENSIBLE base_fmt = + const WAVEFORMATEXTENSIBLE base_fmt = { .Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE, .Format.nChannels = 2, -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10884
From: Ivan Ivlev <iviv@etersoft.ru> Signed-off-by: Ivan Ivlev <iviv@etersoft.ru> --- dlls/vccorlib140/tests/vccorlib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/vccorlib140/tests/vccorlib.c b/dlls/vccorlib140/tests/vccorlib.c index 77838accedb..e6b39ac3716 100644 --- a/dlls/vccorlib140/tests/vccorlib.c +++ b/dlls/vccorlib140/tests/vccorlib.c @@ -704,7 +704,7 @@ static void test_GetActivationFactoryByPCWSTR(void) static void test_GetIidsFn(void) { - static const GUID guids_src[] = {IID_IUnknown, IID_IInspectable, IID_IAgileObject, IID_IMarshal, guid_null}; + const GUID guids_src[] = {IID_IUnknown, IID_IInspectable, IID_IAgileObject, IID_IMarshal, guid_null}; GUID *guids_dest; UINT32 copied; HRESULT hr; @@ -1351,7 +1351,7 @@ static void test_CreateValue(void) Size size; Rect rect; }; - static const struct { + const struct { int typecode; union value value; PropertyType exp_winrt_type; @@ -2190,7 +2190,7 @@ static void test_ToString(void) { static const UINT64 uint64 = 0xdeadbeefdeadbeef; static const INT64 int64 = 0xdeadbeefdeadbeef; - static const GUID guid = IID_IInspectable; + const GUID guid = IID_IInspectable; static const DOUBLE float64 = 2.71828182; static const FLOAT float32 = 2.71828182; static const UINT32 uint32 = 0xdeadbeef; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10884
From: Ivan Ivlev <iviv@etersoft.ru> Signed-off-by: Ivan Ivlev <iviv@etersoft.ru> --- dlls/dmsynth/tests/dmsynth.c | 45 +++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/dlls/dmsynth/tests/dmsynth.c b/dlls/dmsynth/tests/dmsynth.c index 0ad8de93492..067c1f6537f 100644 --- a/dlls/dmsynth/tests/dmsynth.c +++ b/dlls/dmsynth/tests/dmsynth.c @@ -1709,26 +1709,29 @@ struct DECLSPEC_ALIGN(8) midi_message DWORD message; }; -static const struct midi_message default_note_on = -{ - .header = - { - .cbEvent = 3, - .dwFlags = DMUS_EVENT_STRUCTURED, - }, - .message = 0x7f3c90, -}; +#define DEFAULT_NOTE_ON \ + { \ + .header = \ + { \ + .cbEvent = 3, \ + .dwFlags = DMUS_EVENT_STRUCTURED, \ + }, \ + .message = 0x7f3c90, \ + } -static const struct midi_message default_note_off = -{ - .header = - { - .cbEvent = 3, - .rtDelta = 10000000, - .dwFlags = DMUS_EVENT_STRUCTURED, - }, - .message = 0x7f3c80, -}; +#define DEFAULT_NOTE_OFF \ + { \ + .header = \ + { \ + .cbEvent = 3, \ + .rtDelta = 10000000, \ + .dwFlags = DMUS_EVENT_STRUCTURED, \ + }, \ + .message = 0x7f3c80, \ + } + +static const struct midi_message default_note_on = DEFAULT_NOTE_ON; +static const struct midi_message default_note_off = DEFAULT_NOTE_OFF; static struct midi_message make_midi_message(REFERENCE_TIME delta, DWORD message) { @@ -1785,8 +1788,8 @@ struct midi default_midi = { .messages = { - default_note_on, - default_note_off, + DEFAULT_NOTE_ON, + DEFAULT_NOTE_OFF, }, }; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10884
participants (2)
-
Ivan Ivlev -
Ivan Ivlev (@iviv)