Skip to content

Commit 839c5e8

Browse files
thom311eli-schwartz
authored andcommitted
compilers: avoid -Wunused-value compiler warning in CLikeCompiler.has_members()
Otherwise, `CFLAGS='-Wall -Werror' meson build` can fail detection: void bar(void) { struct stat foo; foo.st_mtim.tv_nsec; } ----------- Command line: `cc ./project/build/meson-private/tmpqz_gi65d/testfile.c -o ./project/build/meson-private/tmpqz_gi65d/output.obj -c -O3 -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1 stderr: ./project/build/meson-private/tmpqz_gi65d/testfile.c: In function 'bar': ./project/build/meson-private/tmpqz_gi65d/testfile.c:45:24: error: statement with no effect [-Werror=unused-value] 45 | foo.st_mtim.tv_nsec; | ~~~~~~~~~~~^~~~~~~~ cc1: all warnings being treated as errors (cherry picked from commit a22a50a)
1 parent 47c44dc commit 839c5e8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mesonbuild/compilers/mixins/clike.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,11 +870,12 @@ def has_members(self, typename: str, membernames: T.List[str],
870870
if extra_args is None:
871871
extra_args = []
872872
# Create code that accesses all members
873-
members = ''.join(f'foo.{member};\n' for member in membernames)
873+
members = ''.join(f'(void) ( foo.{member} );\n' for member in membernames)
874874
t = f'''{prefix}
875875
void bar(void) {{
876876
{typename} foo;
877877
{members}
878+
(void) foo;
878879
}}'''
879880
return self.compiles(t, env, extra_args=extra_args,
880881
dependencies=dependencies)

0 commit comments

Comments
 (0)