summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/meson/meson/0001-Fix-missing-return-statements-that-are-seen-with-Wer.patch
blob: 16c6d90761d665b1a0ea52f590bab902dcbe548a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
From 15f44be1c7f71cb0a8c6863917acbbc301c621fe Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Mon, 15 Jul 2019 10:06:17 +0200
Subject: [PATCH] Fix missing return statements that are seen with
 -Werror=return-type.

Error example:

Code:

        #include <locale.h>
        int main () {
            /* If it's not defined as a macro, try to use as a symbol */
            #ifndef LC_MESSAGES
                LC_MESSAGES;
            #endif
        }
Compiler stdout:

Compiler stderr:
 In file included from /usr/include/locale.h:25,
                 from /tmp/tmpep_i4iwg/testfile.c:2:
/usr/include/features.h:382:4: warning: #warning _FORTIFY_SOURCE
requires compiling with optimization (-O) [-Wcpp]
  382 | #  warning _FORTIFY_SOURCE requires compiling with optimization
(-O)
      |    ^~~~~~~
/tmp/tmpep_i4iwg/testfile.c: In function 'main':
/tmp/tmpep_i4iwg/testfile.c:8:9: error: control reaches end of non-void
function [-Werror=return-type]
    8 |         }
      |         ^
cc1: some warnings being treated as errors

Upstream-Status: Backport
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 mesonbuild/compilers/c.py     | 1 +
 mesonbuild/compilers/clike.py | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 3b58a076..9ef92077 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -70,6 +70,7 @@ class CCompiler(CLikeCompiler, Compiler):
             #ifndef {symbol}
                 {symbol};
             #endif
+            return 0;
         }}'''
         return self.compiles(t.format(**fargs), env, extra_args=extra_args,
                              dependencies=dependencies)
diff --git a/mesonbuild/compilers/clike.py b/mesonbuild/compilers/clike.py
index 83f67591..f9cbeabd 100644
--- a/mesonbuild/compilers/clike.py
+++ b/mesonbuild/compilers/clike.py
@@ -375,6 +375,7 @@ class CLikeCompiler:
             #ifndef {symbol}
                 {symbol};
             #endif
+            return 0;
         }}'''
         return self.compiles(t.format(**fargs), env, extra_args=extra_args,
                              dependencies=dependencies)
@@ -554,6 +555,7 @@ class CLikeCompiler:
         {prefix}
         int main(int argc, char **argv) {{
             {type} something;
+            return 0;
         }}'''
         if not self.compiles(t.format(**fargs), env, extra_args=extra_args,
                              dependencies=dependencies)[0]:
@@ -589,6 +591,7 @@ class CLikeCompiler:
         {prefix}
         int main(int argc, char **argv) {{
             {type} something;
+            return 0;
         }}'''
         if not self.compiles(t.format(**fargs), env, extra_args=extra_args,
                              dependencies=dependencies)[0]:
@@ -667,6 +670,7 @@ class CLikeCompiler:
         #include <stdio.h>
         int main(int argc, char *argv[]) {{
             printf ("{fmt}", {cast} {f}());
+            return 0;
         }}'''.format(**fargs)
         res = self.run(code, env, extra_args=extra_args, dependencies=dependencies)
         if not res.compiled:
@@ -819,6 +823,7 @@ class CLikeCompiler:
                 #error "No definition for __builtin_{func} found in the prefix"
             #endif
         #endif
+        return 0;
         }}'''
         return self.links(t.format(**fargs), env, extra_args=extra_args,
                           dependencies=dependencies)
-- 
2.17.1