summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-core/glibc/glibc/0029-assert-Support-types-without-operator-int-BZ-21972.patch194
-rw-r--r--meta/recipes-core/glibc/glibc_2.26.bb1
2 files changed, 195 insertions, 0 deletions
diff --git a/meta/recipes-core/glibc/glibc/0029-assert-Support-types-without-operator-int-BZ-21972.patch b/meta/recipes-core/glibc/glibc/0029-assert-Support-types-without-operator-int-BZ-21972.patch
new file mode 100644
index 0000000000..3c7050f078
--- /dev/null
+++ b/meta/recipes-core/glibc/glibc/0029-assert-Support-types-without-operator-int-BZ-21972.patch
@@ -0,0 +1,194 @@
1Upstream-Status: Backport
2
3* fixes "lambda-expression in unevaluated context" compile failures such as
4 https://github.com/nlohmann/json/issues/705
5
6* fixes "no match for 'operator==" compile failures such as
7 https://bugzilla.redhat.com/show_bug.cgi?id=1482990
8
9* Changelog edit was removed from upstream commit because it caused conflict
10
11Signed-off-by: S. Lockwood-Childs <sjl@vctlabs.com>
12
13From b5889d25e9bf944a89fdd7bcabf3b6c6f6bb6f7c Mon Sep 17 00:00:00 2001
14From: Florian Weimer <fweimer@redhat.com>
15Date: Mon, 21 Aug 2017 13:03:29 +0200
16Subject: [PATCH] assert: Support types without operator== (int) [BZ #21972]
17
18---
19 assert/Makefile | 11 ++++++-
20 assert/assert.h | 16 ++++++----
21 assert/tst-assert-c++.cc | 78 ++++++++++++++++++++++++++++++++++++++++++++++++
22 assert/tst-assert-g++.cc | 19 ++++++++++++
23 4 files changed, 128 insertions(+), 7 deletions(-)
24 create mode 100644 assert/tst-assert-c++.cc
25 create mode 100644 assert/tst-assert-g++.cc
26
27diff --git a/assert/Makefile b/assert/Makefile
28index 1c3be9b..9ec1be8 100644
29--- a/assert/Makefile
30+++ b/assert/Makefile
31@@ -25,6 +25,15 @@ include ../Makeconfig
32 headers := assert.h
33
34 routines := assert assert-perr __assert
35-tests := test-assert test-assert-perr
36+tests := test-assert test-assert-perr tst-assert-c++ tst-assert-g++
37
38 include ../Rules
39+
40+ifeq ($(have-cxx-thread_local),yes)
41+CFLAGS-tst-assert-c++.o = -std=c++11
42+LDLIBS-tst-assert-c++ = -lstdc++
43+CFLAGS-tst-assert-g++.o = -std=gnu++11
44+LDLIBS-tst-assert-g++ = -lstdc++
45+else
46+tests-unsupported += tst-assert-c++ tst-assert-g++
47+endif
48diff --git a/assert/assert.h b/assert/assert.h
49index 6801cfe..640c95c 100644
50--- a/assert/assert.h
51+++ b/assert/assert.h
52@@ -85,7 +85,12 @@ __END_DECLS
53 /* When possible, define assert so that it does not add extra
54 parentheses around EXPR. Otherwise, those added parentheses would
55 suppress warnings we'd expect to be detected by gcc's -Wparentheses. */
56-# if !defined __GNUC__ || defined __STRICT_ANSI__
57+# if defined __cplusplus
58+# define assert(expr) \
59+ (static_cast <bool> (expr) \
60+ ? void (0) \
61+ : __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION))
62+# elif !defined __GNUC__ || defined __STRICT_ANSI__
63 # define assert(expr) \
64 ((expr) \
65 ? __ASSERT_VOID_CAST (0) \
66@@ -93,12 +98,11 @@ __END_DECLS
67 # else
68 /* The first occurrence of EXPR is not evaluated due to the sizeof,
69 but will trigger any pedantic warnings masked by the __extension__
70- for the second occurrence. The explicit comparison against zero is
71- required to support function pointers and bit fields in this
72- context, and to suppress the evaluation of variable length
73- arrays. */
74+ for the second occurrence. The ternary operator is required to
75+ support function pointers and bit fields in this context, and to
76+ suppress the evaluation of variable length arrays. */
77 # define assert(expr) \
78- ((void) sizeof ((expr) == 0), __extension__ ({ \
79+ ((void) sizeof ((expr) ? 1 : 0), __extension__ ({ \
80 if (expr) \
81 ; /* empty */ \
82 else \
83diff --git a/assert/tst-assert-c++.cc b/assert/tst-assert-c++.cc
84new file mode 100644
85index 0000000..12a5e69
86--- /dev/null
87+++ b/assert/tst-assert-c++.cc
88@@ -0,0 +1,78 @@
89+/* Tests for interactions between C++ and assert.
90+ Copyright (C) 2017 Free Software Foundation, Inc.
91+ This file is part of the GNU C Library.
92+
93+ The GNU C Library is free software; you can redistribute it and/or
94+ modify it under the terms of the GNU Lesser General Public
95+ License as published by the Free Software Foundation; either
96+ version 2.1 of the License, or (at your option) any later version.
97+
98+ The GNU C Library is distributed in the hope that it will be useful,
99+ but WITHOUT ANY WARRANTY; without even the implied warranty of
100+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
101+ Lesser General Public License for more details.
102+
103+ You should have received a copy of the GNU Lesser General Public
104+ License along with the GNU C Library; if not, see
105+ <http://www.gnu.org/licenses/>. */
106+
107+#include <assert.h>
108+
109+/* The C++ standard requires that if the assert argument is a constant
110+ subexpression, then the assert itself is one, too. */
111+constexpr int
112+check_constexpr ()
113+{
114+ return (assert (true), 1);
115+}
116+
117+/* Objects of this class can be contextually converted to bool, but
118+ cannot be compared to int. */
119+struct no_int
120+{
121+ no_int () = default;
122+ no_int (const no_int &) = delete;
123+
124+ explicit operator bool () const
125+ {
126+ return true;
127+ }
128+
129+ bool operator! () const; /* No definition. */
130+ template <class T> bool operator== (T) const; /* No definition. */
131+ template <class T> bool operator!= (T) const; /* No definition. */
132+};
133+
134+/* This class tests that operator== is not used by assert. */
135+struct bool_and_int
136+{
137+ bool_and_int () = default;
138+ bool_and_int (const no_int &) = delete;
139+
140+ explicit operator bool () const
141+ {
142+ return true;
143+ }
144+
145+ bool operator! () const; /* No definition. */
146+ template <class T> bool operator== (T) const; /* No definition. */
147+ template <class T> bool operator!= (T) const; /* No definition. */
148+};
149+
150+static int
151+do_test ()
152+{
153+ {
154+ no_int value;
155+ assert (value);
156+ }
157+
158+ {
159+ bool_and_int value;
160+ assert (value);
161+ }
162+
163+ return 0;
164+}
165+
166+#include <support/test-driver.c>
167diff --git a/assert/tst-assert-g++.cc b/assert/tst-assert-g++.cc
168new file mode 100644
169index 0000000..8c06402
170--- /dev/null
171+++ b/assert/tst-assert-g++.cc
172@@ -0,0 +1,19 @@
173+/* Tests for interactions between C++ and assert. GNU C++11 version.
174+ Copyright (C) 2017 Free Software Foundation, Inc.
175+ This file is part of the GNU C Library.
176+
177+ The GNU C Library is free software; you can redistribute it and/or
178+ modify it under the terms of the GNU Lesser General Public
179+ License as published by the Free Software Foundation; either
180+ version 2.1 of the License, or (at your option) any later version.
181+
182+ The GNU C Library is distributed in the hope that it will be useful,
183+ but WITHOUT ANY WARRANTY; without even the implied warranty of
184+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
185+ Lesser General Public License for more details.
186+
187+ You should have received a copy of the GNU Lesser General Public
188+ License along with the GNU C Library; if not, see
189+ <http://www.gnu.org/licenses/>. */
190+
191+#include <tst-assert-c++.cc>
192--
1931.9.4
194
diff --git a/meta/recipes-core/glibc/glibc_2.26.bb b/meta/recipes-core/glibc/glibc_2.26.bb
index 135ec4fb16..7dd025ae68 100644
--- a/meta/recipes-core/glibc/glibc_2.26.bb
+++ b/meta/recipes-core/glibc/glibc_2.26.bb
@@ -43,6 +43,7 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \
43 file://0026-assert-Suppress-pedantic-warning-caused-by-statement.patch \ 43 file://0026-assert-Suppress-pedantic-warning-caused-by-statement.patch \
44 file://0027-glibc-reset-dl-load-write-lock-after-forking.patch \ 44 file://0027-glibc-reset-dl-load-write-lock-after-forking.patch \
45 file://0028-Bug-4578-add-ld.so-lock-while-fork.patch \ 45 file://0028-Bug-4578-add-ld.so-lock-while-fork.patch \
46 file://0029-assert-Support-types-without-operator-int-BZ-21972.patch \
46" 47"
47 48
48NATIVESDKFIXES ?= "" 49NATIVESDKFIXES ?= ""