summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0235-PR-c-48909.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0235-PR-c-48909.patch')
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0235-PR-c-48909.patch73
1 files changed, 73 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0235-PR-c-48909.patch b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0235-PR-c-48909.patch
new file mode 100644
index 0000000000..0b96bd32cf
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0235-PR-c-48909.patch
@@ -0,0 +1,73 @@
1From 011e03ba93f21bead8eae267c82423d5893bf2f3 Mon Sep 17 00:00:00 2001
2From: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
3Date: Fri, 6 May 2011 21:58:44 +0000
4Subject: [PATCH] PR c++/48909
5 * semantics.c (cxx_eval_conditional_expression): Check
6 integer_zerop/onep instead.
7
8git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173516 138bc75d-0d04-0410-961f-82ee72b054a4
9
10index 8fd1820..6b7ec39 100644
11--- a/gcc/cp/semantics.c
12+++ b/gcc/cp/semantics.c
13@@ -6255,13 +6255,12 @@ cxx_eval_conditional_expression (const constexpr_call *call, tree t,
14 allow_non_constant, addr,
15 non_constant_p);
16 VERIFY_CONSTANT (val);
17- if (val == boolean_true_node)
18- return cxx_eval_constant_expression (call, TREE_OPERAND (t, 1),
19+ /* Don't VERIFY_CONSTANT the other operands. */
20+ if (integer_zerop (val))
21+ return cxx_eval_constant_expression (call, TREE_OPERAND (t, 2),
22 allow_non_constant, addr,
23 non_constant_p);
24- gcc_assert (val == boolean_false_node);
25- /* Don't VERIFY_CONSTANT here. */
26- return cxx_eval_constant_expression (call, TREE_OPERAND (t, 2),
27+ return cxx_eval_constant_expression (call, TREE_OPERAND (t, 1),
28 allow_non_constant, addr,
29 non_constant_p);
30 }
31@@ -7828,12 +7827,12 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags)
32 tmp = TREE_OPERAND (t, 0);
33 if (!potential_constant_expression_1 (tmp, rval, flags))
34 return false;
35- else if (tmp == boolean_true_node)
36- return potential_constant_expression_1 (TREE_OPERAND (t, 1),
37- want_rval, flags);
38- else if (tmp == boolean_false_node)
39+ else if (integer_zerop (tmp))
40 return potential_constant_expression_1 (TREE_OPERAND (t, 2),
41 want_rval, flags);
42+ else if (TREE_CODE (tmp) == INTEGER_CST)
43+ return potential_constant_expression_1 (TREE_OPERAND (t, 1),
44+ want_rval, flags);
45 for (i = 1; i < 3; ++i)
46 if (potential_constant_expression_1 (TREE_OPERAND (t, i),
47 want_rval, tf_none))
48new file mode 100644
49index 0000000..2434096
50--- /dev/null
51+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-condition2.C
52@@ -0,0 +1,18 @@
53+// PR c++/48909
54+// { dg-options -std=c++0x }
55+
56+#define SA(X) static_assert((X),#X)
57+
58+constexpr int const * is_sorted_until(int const * first, int const * last)
59+{
60+ return first == last || first + 1 == last ? last
61+ : (*(first + 1) < *first) != false ? first + 1
62+ : is_sorted_until(first + 1, last);
63+}
64+
65+int main()
66+{
67+ static constexpr int array[2] = {0, 1};
68+ constexpr int const * last = is_sorted_until(array, array + 2);
69+ SA(last==array+2);
70+}
71--
721.7.0.4
73