summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0343-gcc-cp-ChangeLog.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0343-gcc-cp-ChangeLog.patch')
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0343-gcc-cp-ChangeLog.patch207
1 files changed, 207 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0343-gcc-cp-ChangeLog.patch b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0343-gcc-cp-ChangeLog.patch
new file mode 100644
index 0000000000..364dfa8b56
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0343-gcc-cp-ChangeLog.patch
@@ -0,0 +1,207 @@
1From 2cf0a578b9883daa7f515380736d29b537a21ef7 Mon Sep 17 00:00:00 2001
2From: fabien <fabien@138bc75d-0d04-0410-961f-82ee72b054a4>
3Date: Wed, 25 May 2011 20:52:15 +0000
4Subject: [PATCH] gcc/cp/ChangeLog:
5
62011-05-25 Fabien Chene <fabien@gcc.gnu.org>
7 * init.c (diagnose_uninitialized_cst_or_ref_member_1): Use
8 permerror instead of error, adjust the error count.
9
10gcc/testsuite/ChangeLog:
11
122011-05-25 Fabien Chene <fabien@gcc.gnu.org>
13 * g++.dg/init/pr25811-2.C: New.
14 * g++.dg/init/pr25811-3.C: New.
15 * g++.dg/init/pr25811-4.C: New.
16
17
18git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@174239 138bc75d-0d04-0410-961f-82ee72b054a4
19
20index 172a71a..ef9e20e 100644
21--- a/gcc/cp/init.c
22+++ b/gcc/cp/init.c
23@@ -1893,6 +1893,7 @@ diagnose_uninitialized_cst_or_ref_member_1 (tree type, tree origin,
24 {
25 tree field;
26 int error_count = 0;
27+ bool permissive = global_dc->permissive;
28
29 if (type_has_user_provided_constructor (type))
30 return 0;
31@@ -1911,32 +1912,45 @@ diagnose_uninitialized_cst_or_ref_member_1 (tree type, tree origin,
32
33 if (TREE_CODE (field_type) == REFERENCE_TYPE)
34 {
35- ++ error_count;
36 if (complain)
37 {
38+ if (!permissive || !using_new)
39+ ++ error_count;
40+
41 if (using_new)
42- error ("uninitialized reference member in %q#T "
43- "using %<new%> without new-initializer", origin);
44+ permerror (input_location,
45+ "uninitialized reference member in %q#T "
46+ "using %<new%> without new-initializer", origin);
47 else
48- error ("uninitialized reference member in %q#T", origin);
49+ error ("uninitialized reference member in %q#T", origin);
50+
51 inform (DECL_SOURCE_LOCATION (field),
52 "%qD should be initialized", field);
53 }
54+ else
55+ ++ error_count;
56 }
57
58 if (CP_TYPE_CONST_P (field_type))
59 {
60- ++ error_count;
61 if (complain)
62 {
63+ if (!permissive)
64+ ++ error_count;
65+
66 if (using_new)
67- error ("uninitialized const member in %q#T "
68- "using %<new%> without new-initializer", origin);
69- else
70- error ("uninitialized const member in %q#T", origin);
71+ permerror (input_location,
72+ "uninitialized const member in %q#T "
73+ "using %<new%> without new-initializer", origin);
74+ else
75+ permerror (input_location,
76+ "uninitialized const member in %q#T", origin);
77+
78 inform (DECL_SOURCE_LOCATION (field),
79 "%qD should be initialized", field);
80 }
81+ else
82+ ++ error_count;
83 }
84
85 if (CLASS_TYPE_P (field_type))
86new file mode 100644
87index 0000000..3a36dd4
88--- /dev/null
89+++ b/gcc/testsuite/g++.dg/init/pr25811-2.C
90@@ -0,0 +1,26 @@
91+// { dg-do compile }
92+// { dg-options -fpermissive }
93+
94+struct A
95+{
96+ int const i; // { dg-message "should be initialized" }
97+};
98+
99+struct B
100+{
101+ int& r; // { dg-message "should be initialized" }
102+};
103+
104+struct C
105+{
106+ int const i : 1; // { dg-message "should be initialized" }
107+};
108+
109+void f()
110+{
111+ new A; // { dg-warning "uninitialized" }
112+ new B; // { dg-warning "uninitialized" }
113+ new C; // { dg-warning "uninitialized" }
114+ C c; // { dg-warning "uninitialized" }
115+ A a[1]; // { dg-warning "uninitialized" }
116+}
117diff --git a/gcc/testsuite/g++.dg/init/pr25811-3.C b/gcc/testsuite/g++.dg/init/pr25811-3.C
118new file mode 100644
119index 0000000..631da5b
120--- /dev/null
121+++ b/gcc/testsuite/g++.dg/init/pr25811-3.C
122@@ -0,0 +1,38 @@
123+// { dg-do compile }
124+
125+struct A { int const i; };
126+struct B { int& i; };
127+struct C { int i; };
128+
129+template< class T >
130+class is_constructible_via_new_without_initializer
131+{
132+ template<int> class size {};
133+
134+ typedef char yes_type;
135+ struct no_type { char data[2]; };
136+
137+ template <class U>
138+ static yes_type sfinae (size< sizeof (new U) >*);
139+
140+ template <class U>
141+ static no_type sfinae (...);
142+
143+public:
144+ static const bool value = sizeof (sfinae<T>(0)) == sizeof (yes_type);
145+};
146+
147+#define JOIN( X, Y ) DO_JOIN( X, Y )
148+#define DO_JOIN( X, Y ) DO_JOIN2(X,Y)
149+#define DO_JOIN2( X, Y ) X##Y
150+
151+#ifdef __GXX_EXPERIMENTAL_CXX0X__
152+# define STATIC_ASSERT(Expr) static_assert(Expr, #Expr)
153+#else
154+# define STATIC_ASSERT(Expr) int JOIN(a,__LINE__)[Expr? 1 : -1]
155+#endif
156+
157+STATIC_ASSERT (!is_constructible_via_new_without_initializer<A>::value);
158+STATIC_ASSERT (!is_constructible_via_new_without_initializer<B>::value);
159+STATIC_ASSERT (is_constructible_via_new_without_initializer<C>::value);
160+
161diff --git a/gcc/testsuite/g++.dg/init/pr25811-4.C b/gcc/testsuite/g++.dg/init/pr25811-4.C
162new file mode 100644
163index 0000000..abfb3d9
164--- /dev/null
165+++ b/gcc/testsuite/g++.dg/init/pr25811-4.C
166@@ -0,0 +1,38 @@
167+// { dg-do compile }
168+// { dg-options "-fpermissive" }
169+
170+struct A { int const i; };
171+struct B { int& i; };
172+struct C { int i; };
173+
174+template< class T >
175+class is_constructible_via_new_without_initializer
176+{
177+ template<int> class size {};
178+
179+ typedef char yes_type;
180+ struct no_type { char data[2]; };
181+
182+ template <class U>
183+ static yes_type sfinae (size< sizeof (new U) >*);
184+
185+ template <class U>
186+ static no_type sfinae (...);
187+
188+public:
189+ static const bool value = sizeof (sfinae<T>(0)) == sizeof (yes_type);
190+};
191+
192+#define JOIN( X, Y ) DO_JOIN( X, Y )
193+#define DO_JOIN( X, Y ) DO_JOIN2(X,Y)
194+#define DO_JOIN2( X, Y ) X##Y
195+
196+#ifdef __GXX_EXPERIMENTAL_CXX0X__
197+# define STATIC_ASSERT(Expr) static_assert(Expr, #Expr)
198+#else
199+# define STATIC_ASSERT(Expr) int JOIN(a,__LINE__)[Expr? 1 : -1]
200+#endif
201+
202+STATIC_ASSERT (!is_constructible_via_new_without_initializer<A>::value);
203+STATIC_ASSERT (!is_constructible_via_new_without_initializer<B>::value);
204+STATIC_ASSERT (is_constructible_via_new_without_initializer<C>::value);
205--
2061.7.0.4
207