This file is indexed.

/usr/src/gcc-4.7/debian/patches/pr50043.diff is in gcc-4.7-source 4.7.3-12ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# DP: Backport PR c++/50043 from the 4.8 branch.

gcc/cp/

2012-04-01  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/50043
	* class.c (deduce_noexcept_on_destructor,
	deduce_noexcept_on_destructors): New.
	(check_bases_and_members): Call the latter.
	* decl.c (grokfndecl): Call the former.
	* method.c (implicitly_declare_fn): Not static.
	* cp-tree.h (deduce_noexcept_on_destructor, implicitly_declare_fn):
	Declare

gcc/testsuite/

2012-04-01  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/50043
	* g++.dg/cpp0x/noexcept17.C: New.
	* g++.old-deja/g++.eh/cleanup1.C: Adjust.
	* g++.dg/tree-ssa/ehcleanup-1.C: Likewise.
	* g++.dg/cpp0x/noexcept01.C: Likewise.
	* g++.dg/eh/init-temp1.C: Likewise.
	* g++.dg/eh/ctor1.C: Likwise.

--- a/src/gcc/cp/decl.c
+++ b/src/gcc/cp/decl.c
@@ -7439,6 +7439,13 @@
   if (ctype != NULL_TREE)
     grokclassfn (ctype, decl, flags);
 
+  /* 12.4/3  */
+  if (cxx_dialect >= cxx0x
+      && DECL_DESTRUCTOR_P (decl)
+      && !TYPE_BEING_DEFINED (DECL_CONTEXT (decl))
+      && !processing_template_decl)
+    deduce_noexcept_on_destructor (decl);
+
   decl = check_explicit_specialization (orig_declarator, decl,
 					template_count,
 					2 * funcdef_flag +
--- a/src/gcc/cp/class.c
+++ b/src/gcc/cp/class.c
@@ -4334,6 +4334,41 @@
     clone_function_decl (OVL_CURRENT (fns), /*update_method_vec_p=*/1);
 }
 
+/* Deduce noexcept for a destructor DTOR.  */
+
+void
+deduce_noexcept_on_destructor (tree dtor)
+{
+  if (!TYPE_RAISES_EXCEPTIONS (TREE_TYPE (dtor)))
+    {
+      tree ctx = DECL_CONTEXT (dtor);
+      tree implicit_fn = implicitly_declare_fn (sfk_destructor, ctx,
+						/*const_p=*/false);
+      tree eh_spec = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (implicit_fn));
+      TREE_TYPE (dtor) = build_exception_variant (TREE_TYPE (dtor), eh_spec);
+    }
+}
+
+/* For each destructor in T, deduce noexcept:
+
+   12.4/3: A declaration of a destructor that does not have an
+   exception-specification is implicitly considered to have the
+   same exception-specification as an implicit declaration (15.4).  */
+
+static void
+deduce_noexcept_on_destructors (tree t)
+{
+  tree fns;
+
+  /* If for some reason we don't have a CLASSTYPE_METHOD_VEC, we bail
+     out now.  */
+  if (!CLASSTYPE_METHOD_VEC (t))
+    return;
+
+  for (fns = CLASSTYPE_DESTRUCTORS (t); fns; fns = OVL_NEXT (fns))
+    deduce_noexcept_on_destructor (OVL_CURRENT (fns));
+}
+
 /* Subroutine of set_one_vmethod_tm_attributes.  Search base classes
    of TYPE for virtual functions which FNDECL overrides.  Return a
    mask of the tm attributes found therein.  */
@@ -5007,6 +5042,10 @@
   cant_have_const_ctor = 0;
   no_const_asn_ref = 0;
 
+  /* Deduce noexcept on destructors.  */
+  if (cxx_dialect >= cxx0x)
+    deduce_noexcept_on_destructors (t);
+
   /* Check all the base-classes.  */
   check_bases (t, &cant_have_const_ctor,
 	       &no_const_asn_ref);
--- a/src/gcc/cp/cp-tree.h
+++ b/src/gcc/cp/cp-tree.h
@@ -4977,6 +4977,7 @@
 extern tree* decl_cloned_function_p		(const_tree, bool);
 extern void clone_function_decl			(tree, int);
 extern void adjust_clone_args			(tree);
+extern void deduce_noexcept_on_destructor       (tree);
 extern void insert_late_enum_def_into_classtype_sorted_fields (tree, tree);
 
 /* in cvt.c */
@@ -5265,6 +5266,8 @@
 extern tree get_default_ctor			(tree);
 extern tree get_dtor				(tree, tsubst_flags_t);
 extern tree locate_ctor				(tree);
+extern tree implicitly_declare_fn               (special_function_kind, tree,
+						 bool);
 
 /* In optimize.c */
 extern bool maybe_clone_body			(tree);
--- a/src/gcc/cp/method.c
+++ b/src/gcc/cp/method.c
@@ -1448,7 +1448,7 @@
    reference argument or a non-const reference.  Returns the
    FUNCTION_DECL for the implicitly declared function.  */
 
-static tree
+tree
 implicitly_declare_fn (special_function_kind kind, tree type, bool const_p)
 {
   tree fn;
--- a/src/gcc/testsuite/g++.old-deja/g++.eh/cleanup1.C
+++ b/src/gcc/testsuite/g++.old-deja/g++.eh/cleanup1.C
@@ -2,6 +2,12 @@
 // Bug: obj gets destroyed twice because the fixups for the return are
 // inside its cleanup region.
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+#define NOEXCEPT_FALSE noexcept (false)
+#else
+#define NOEXCEPT_FALSE
+#endif
+
 extern "C" int printf (const char *, ...);
 
 int d;
@@ -9,7 +15,7 @@
 struct myExc { };
 
 struct myExcRaiser {
-  ~myExcRaiser() { throw myExc(); }
+  ~myExcRaiser() NOEXCEPT_FALSE { throw myExc(); }
 };
 
 struct stackObj {
--- a/src/gcc/testsuite/g++.dg/eh/init-temp1.C
+++ b/src/gcc/testsuite/g++.dg/eh/init-temp1.C
@@ -1,6 +1,12 @@
 // PR c++/15764
 // { dg-do run }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+#define NOEXCEPT_FALSE noexcept (false)
+#else
+#define NOEXCEPT_FALSE
+#endif
+
 extern "C" void abort (); 
  
 int thrown; 
@@ -8,7 +14,7 @@
 int as;
 struct a {
   a () { ++as; }
-  ~a () { --as; if (thrown++ == 0) throw 42; }
+  ~a () NOEXCEPT_FALSE { --as; if (thrown++ == 0) throw 42; }
 }; 
  
 int f (a const&) { return 1; } 
--- a/src/gcc/testsuite/g++.dg/eh/ctor1.C
+++ b/src/gcc/testsuite/g++.dg/eh/ctor1.C
@@ -5,6 +5,12 @@
 
 // PR 411
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+#define NOEXCEPT_FALSE noexcept (false)
+#else
+#define NOEXCEPT_FALSE
+#endif
+
 bool was_f_in_Bar_destroyed=false;
 
 struct Foo
@@ -17,7 +23,7 @@
 
 struct Bar
 {
-  ~Bar()
+  ~Bar() NOEXCEPT_FALSE
   {
     throw 1;
   }
--- a/src/gcc/testsuite/g++.dg/cpp0x/noexcept01.C
+++ b/src/gcc/testsuite/g++.dg/cpp0x/noexcept01.C
@@ -50,7 +50,7 @@
   ~E();
 };
 
-SA (!noexcept (E()));
+SA (noexcept (E()));
 
 struct F
 {
@@ -74,7 +74,7 @@
 }
 
 template void tf<int,true>();
-template void tf<E, false>();
+template void tf<E, true>();
 
 // Make sure that noexcept uses the declared exception-specification, not
 // any knowledge we might have about whether or not the function really
--- a/src/gcc/testsuite/g++.dg/cpp0x/noexcept17.C
+++ b/src/gcc/testsuite/g++.dg/cpp0x/noexcept17.C
@@ -0,0 +1,54 @@
+// PR c++/50043
+// { dg-options -std=c++11 }
+
+struct True1 {};
+struct True2 { ~True2(); };
+struct True3 { ~True3(){ throw 0; } };
+struct False { ~False() noexcept(false); };
+
+template <typename Base>
+struct A : Base
+{
+};
+
+template <typename Member>
+struct B
+{
+    Member mem;
+};
+
+template <typename Base, typename Member>
+struct C : Base
+{
+    Member mem;
+};
+
+#define SA(X) static_assert(X, #X)
+
+SA( noexcept(True1()));
+SA( noexcept(True2()));
+SA( noexcept(True3()));
+SA(!noexcept(False()));
+
+SA( noexcept(A<True1>()));
+SA( noexcept(A<True2>()));
+SA( noexcept(A<True3>()));
+SA(!noexcept(A<False>()));
+
+SA( noexcept(B<True1>()));
+SA( noexcept(B<True2>()));
+SA( noexcept(B<True3>()));
+SA(!noexcept(B<False>()));
+
+SA( noexcept(C<True1, True2>()));
+SA( noexcept(C<True1, True3>()));
+SA( noexcept(C<True2, True3>()));
+SA( noexcept(C<True2, True1>()));
+SA( noexcept(C<True3, True1>()));
+SA( noexcept(C<True3, True2>()));
+SA(!noexcept(C<False, True1>()));
+SA(!noexcept(C<False, True2>()));
+SA(!noexcept(C<False, True3>()));
+SA(!noexcept(C<True1, False>()));
+SA(!noexcept(C<True2, False>()));
+SA(!noexcept(C<True3, False>()));
--- a/src/gcc/testsuite/g++.dg/tree-ssa/ehcleanup-1.C
+++ b/src/gcc/testsuite/g++.dg/tree-ssa/ehcleanup-1.C
@@ -1,9 +1,16 @@
 // { dg-options "-O2 -fdump-tree-ehcleanup1-details" }
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+#define NOEXCEPT_FALSE noexcept (false)
+#else
+#define NOEXCEPT_FALSE
+#endif
+
 extern void can_throw ();
 class a
 {
 public:
-  ~a ()
+  ~a () NOEXCEPT_FALSE
   {
     if (0)
       can_throw ();