summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0022-PR-c-47570.patch
blob: 7f2e35ad51bf69057147d8678867504227a5ecae (plain)
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
Upstream-Status: Inappropriate [Backport]
From 1d1e50e7f9e7511a01ee95d7cffd8311c9b84d8b Mon Sep 17 00:00:00 2001
From: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 29 Mar 2011 14:24:09 +0000
Subject: [PATCH 022/200] 	PR c++/47570
 	* semantics.c (cxx_eval_constant_expression) [COMPOUND_EXPR]: Don't
 	use the generic binary expression handling.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@171663 138bc75d-0d04-0410-961f-82ee72b054a4

index a0f48c0..d23effe 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -6896,7 +6896,13 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t,
 	  r = cxx_eval_constant_expression (call, op0, allow_non_constant,
 					    addr, non_constant_p);
 	else
-	  goto binary;
+	  {
+	    /* Check that the LHS is constant and then discard it.  */
+	    cxx_eval_constant_expression (call, op0, allow_non_constant,
+					  false, non_constant_p);
+	    r = cxx_eval_constant_expression (call, op1, allow_non_constant,
+					      addr, non_constant_p);
+	  }
       }
       break;
 
@@ -6938,7 +6944,6 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t,
     case UNEQ_EXPR:
     case RANGE_EXPR:
     case COMPLEX_EXPR:
-    binary:
       r = cxx_eval_binary_expression (call, t, allow_non_constant, addr,
 				      non_constant_p);
       break;
new file mode 100644
index 0000000..c60ba86
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-47570.C
@@ -0,0 +1,25 @@
+// PR c++/47570
+// { dg-options -std=c++0x }
+
+unsigned int constexpr one()
+{ return 1; }
+
+int constexpr one_B()
+{ return 1; }
+
+int main()
+{
+  // FAIL TO COMPILE:
+  static bool constexpr SC_huh1 = ((unsigned int)one()) >= ((unsigned int)0);
+  static bool constexpr SC_huh2 = one() >= ((unsigned int)0);
+  static bool constexpr SC_huh3 = one() >= 0;
+
+  // COMPILE OK:
+  static bool constexpr SC_huh4 = ((one() == 0) || (one() > 0));
+  static bool constexpr SC_huh5 = one() == 0;
+  static bool constexpr SC_huh6 = one() > 0;
+  static bool constexpr SC_huh7 = one_B() >= 0;
+  static bool constexpr SC_huh8 = one() >= 1;
+
+  return SC_huh3;
+}
-- 
1.7.0.4

OpenPOWER on IntegriCloud