summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0358-PR-c-49165.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0358-PR-c-49165.patch')
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0358-PR-c-49165.patch89
1 files changed, 89 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0358-PR-c-49165.patch b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0358-PR-c-49165.patch
new file mode 100644
index 0000000000..cbe05a533d
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0358-PR-c-49165.patch
@@ -0,0 +1,89 @@
1From 0a0395125e1f619c73c0d0c754c630cd92cc4aa7 Mon Sep 17 00:00:00 2001
2From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
3Date: Fri, 27 May 2011 19:23:46 +0000
4Subject: [PATCH] PR c++/49165
5 * c-common.c (c_common_truthvalue_conversion) <case COND_EXPR>: For
6 C++ don't call c_common_truthvalue_conversion on void type arms.
7
8 * g++.dg/eh/cond6.C: New test.
9
10
11git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@174351 138bc75d-0d04-0410-961f-82ee72b054a4
12
13index 0be3996..ea5a196 100644
14--- a/gcc/c-family/c-common.c
15+++ b/gcc/c-family/c-common.c
16@@ -3915,14 +3915,15 @@ c_common_truthvalue_conversion (location_t location, tree expr)
17 /* Distribute the conversion into the arms of a COND_EXPR. */
18 if (c_dialect_cxx ())
19 {
20+ tree op1 = TREE_OPERAND (expr, 1);
21+ tree op2 = TREE_OPERAND (expr, 2);
22+ /* In C++ one of the arms might have void type if it is throw. */
23+ if (!VOID_TYPE_P (TREE_TYPE (op1)))
24+ op1 = c_common_truthvalue_conversion (location, op1);
25+ if (!VOID_TYPE_P (TREE_TYPE (op2)))
26+ op2 = c_common_truthvalue_conversion (location, op2);
27 expr = fold_build3_loc (location, COND_EXPR, truthvalue_type_node,
28- TREE_OPERAND (expr, 0),
29- c_common_truthvalue_conversion (location,
30- TREE_OPERAND (expr,
31- 1)),
32- c_common_truthvalue_conversion (location,
33- TREE_OPERAND (expr,
34- 2)));
35+ TREE_OPERAND (expr, 0), op1, op2);
36 goto ret;
37 }
38 else
39new file mode 100644
40index 0000000..1eed63e
41--- /dev/null
42+++ b/gcc/testsuite/g++.dg/eh/cond6.C
43@@ -0,0 +1,43 @@
44+// PR c++/49165
45+// { dg-do run }
46+
47+extern "C" void abort ();
48+
49+int
50+foo (bool x, int y)
51+{
52+ if (y < 10 && (x ? 1 : throw 1))
53+ y++;
54+ if (y > 20 || (x ? 1 : throw 2))
55+ y++;
56+ return y;
57+}
58+
59+int
60+main ()
61+{
62+ if (foo (true, 0) != 2
63+ || foo (true, 10) != 11
64+ || foo (false, 30) != 31)
65+ abort ();
66+ try
67+ {
68+ foo (false, 0);
69+ abort ();
70+ }
71+ catch (int i)
72+ {
73+ if (i != 1)
74+ abort ();
75+ }
76+ try
77+ {
78+ foo (false, 10);
79+ abort ();
80+ }
81+ catch (int i)
82+ {
83+ if (i != 2)
84+ abort ();
85+ }
86+}
87--
881.7.0.4
89