diff options
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0296-DR-1073.patch')
-rw-r--r-- | meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0296-DR-1073.patch | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0296-DR-1073.patch b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0296-DR-1073.patch new file mode 100644 index 0000000000..e69c862a77 --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0296-DR-1073.patch | |||
@@ -0,0 +1,156 @@ | |||
1 | From 64f447779f7ce0ace5543bbb6a5d334ac3aef501 Mon Sep 17 00:00:00 2001 | ||
2 | From: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | ||
3 | Date: Fri, 20 May 2011 21:29:14 +0000 | ||
4 | Subject: [PATCH] DR 1073 | ||
5 | PR c++/49082 | ||
6 | * typeck.c (comp_except_specs): noexcept(false) is not compatible | ||
7 | with throw(type-list). | ||
8 | * typeck2.c (merge_exception_specifiers): noexcept(false) | ||
9 | beats any more limited specification. | ||
10 | |||
11 | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173984 138bc75d-0d04-0410-961f-82ee72b054a4 | ||
12 | |||
13 | index dec0680..59bf3ab 100644 | ||
14 | --- a/gcc/cp/typeck.c | ||
15 | +++ b/gcc/cp/typeck.c | ||
16 | @@ -986,14 +986,14 @@ comp_except_specs (const_tree t1, const_tree t2, int exact) | ||
17 | /* First handle noexcept. */ | ||
18 | if (exact < ce_exact) | ||
19 | { | ||
20 | - /* noexcept(false) is compatible with any throwing dynamic-exc-spec | ||
21 | + /* noexcept(false) is compatible with no exception-specification, | ||
22 | and stricter than any spec. */ | ||
23 | if (t1 == noexcept_false_spec) | ||
24 | - return !nothrow_spec_p (t2) || exact == ce_derived; | ||
25 | - /* Even a derived noexcept(false) is compatible with a throwing | ||
26 | - dynamic spec. */ | ||
27 | + return t2 == NULL_TREE || exact == ce_derived; | ||
28 | + /* Even a derived noexcept(false) is compatible with no | ||
29 | + exception-specification. */ | ||
30 | if (t2 == noexcept_false_spec) | ||
31 | - return !nothrow_spec_p (t1); | ||
32 | + return t1 == NULL_TREE; | ||
33 | |||
34 | /* Otherwise, if we aren't looking for an exact match, noexcept is | ||
35 | equivalent to throw(). */ | ||
36 | diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c | ||
37 | index 82218f0..8d9c53e 100644 | ||
38 | --- a/gcc/cp/typeck2.c | ||
39 | +++ b/gcc/cp/typeck2.c | ||
40 | @@ -1672,10 +1672,13 @@ add_exception_specifier (tree list, tree spec, int complain) | ||
41 | tree | ||
42 | merge_exception_specifiers (tree list, tree add) | ||
43 | { | ||
44 | - if (!list || !add) | ||
45 | - return NULL_TREE; | ||
46 | + /* No exception-specifier or noexcept(false) are less strict than | ||
47 | + anything else. Prefer the newer variant (LIST). */ | ||
48 | + if (!list || list == noexcept_false_spec) | ||
49 | + return list; | ||
50 | + else if (!add || add == noexcept_false_spec) | ||
51 | + return add; | ||
52 | /* For merging noexcept(true) and throw(), take the more recent one (LIST). | ||
53 | - A throw(type-list) spec takes precedence over a noexcept(false) spec. | ||
54 | Any other noexcept-spec should only be merged with an equivalent one. | ||
55 | So the !TREE_VALUE code below is correct for all cases. */ | ||
56 | else if (!TREE_VALUE (add)) | ||
57 | index 60015e7..ffbb091 100644 | ||
58 | --- a/gcc/testsuite/g++.dg/cpp0x/noexcept02.C | ||
59 | +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept02.C | ||
60 | @@ -10,9 +10,9 @@ void f(); | ||
61 | |||
62 | SA(!noexcept(f())); | ||
63 | |||
64 | -void g() throw (int); | ||
65 | -void g() noexcept(false); // { dg-error "previous declaration" } | ||
66 | -void g(); // { dg-error "different exception" } | ||
67 | +void g() throw (int); // { dg-error "previous declaration" } | ||
68 | +void g() noexcept(false); // { dg-error "different exception" } | ||
69 | +void g(); | ||
70 | |||
71 | void h() throw(); | ||
72 | void h() noexcept; | ||
73 | diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept03.C b/gcc/testsuite/g++.dg/cpp0x/noexcept03.C | ||
74 | index c759f6f..54e04f3 100644 | ||
75 | --- a/gcc/testsuite/g++.dg/cpp0x/noexcept03.C | ||
76 | +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept03.C | ||
77 | @@ -36,19 +36,6 @@ void f2(T a) noexcept (noexcept (f (a))) | ||
78 | |||
79 | struct A { A() { } }; // { dg-warning "does not throw" } | ||
80 | |||
81 | -// throw(int) overrides noexcept(false) in either order. | ||
82 | -void h() throw (int, std::bad_exception); | ||
83 | -void h() noexcept (false) | ||
84 | -{ | ||
85 | - throw 1.0; | ||
86 | -} | ||
87 | - | ||
88 | -void i() noexcept (false); | ||
89 | -void i() throw (int, std::bad_exception) | ||
90 | -{ | ||
91 | - throw 1.0; | ||
92 | -} | ||
93 | - | ||
94 | int main() | ||
95 | { | ||
96 | // noexcept(false) allows throw. | ||
97 | @@ -57,10 +44,6 @@ int main() | ||
98 | try { f(A()); } catch (int) { } | ||
99 | try { f2(A()); } catch (int) { } | ||
100 | |||
101 | - std::set_unexpected (my_unexpected); | ||
102 | - try { h(); } catch (std::bad_exception) { } | ||
103 | - try { i(); } catch (std::bad_exception) { } | ||
104 | - | ||
105 | std::set_terminate (my_terminate); | ||
106 | // noexcept(noexcept(int())) == noexcept(true). | ||
107 | try { f2(1); } catch (...) { } | ||
108 | diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept08.C b/gcc/testsuite/g++.dg/cpp0x/noexcept08.C | ||
109 | index c450332..1df85ef 100644 | ||
110 | --- a/gcc/testsuite/g++.dg/cpp0x/noexcept08.C | ||
111 | +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept08.C | ||
112 | @@ -34,7 +34,7 @@ struct D: A | ||
113 | void g() noexcept(false); // { dg-error "looser" } | ||
114 | void h() noexcept(false); // { dg-error "looser" } | ||
115 | void i() noexcept(false); | ||
116 | - void j() noexcept(false); // compatible; treated as throw(int) | ||
117 | + void j() noexcept(false); // { dg-error "looser" } | ||
118 | }; | ||
119 | |||
120 | struct E: A | ||
121 | diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept10.C b/gcc/testsuite/g++.dg/cpp0x/noexcept10.C | ||
122 | new file mode 100644 | ||
123 | index 0000000..058a387 | ||
124 | --- /dev/null | ||
125 | +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept10.C | ||
126 | @@ -0,0 +1,27 @@ | ||
127 | +// PR c++/49082 | ||
128 | +// { dg-options -std=c++0x } | ||
129 | + | ||
130 | +namespace std { template <class T> T&& declval() noexcept; } | ||
131 | + | ||
132 | +struct Base | ||
133 | +{ | ||
134 | + Base(const Base&) noexcept(false); | ||
135 | + Base(Base&&) noexcept(false); | ||
136 | + ~Base() noexcept(false); | ||
137 | +}; | ||
138 | + | ||
139 | +struct Derived | ||
140 | +: Base | ||
141 | +{ | ||
142 | + // Derived(const Derived&) = default; | ||
143 | + // Derived(Derived&&) = default; | ||
144 | +}; | ||
145 | + | ||
146 | +static_assert(!noexcept(Base(std::declval<const Base&>())), "Error"); | ||
147 | +static_assert(!noexcept(Derived(std::declval<const Derived&>())), "Error"); // Error | ||
148 | + | ||
149 | +static_assert(!noexcept(Base(std::declval<Base&&>())), "Error"); | ||
150 | +static_assert(!noexcept(Derived(std::declval<Derived&&>())), "Error"); // Error | ||
151 | + | ||
152 | +static_assert(!noexcept(std::declval<Base&>().~Base()), "Error"); // OK | ||
153 | +static_assert(!noexcept(std::declval<Derived&>().~Derived()), "Error"); // Error | ||
154 | -- | ||
155 | 1.7.0.4 | ||
156 | |||