summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0023-PR-c-47504.patch
blob: 23aebda2c1f058ec720f8febdbddca770f501a54 (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
From 4ebec68ee3aee90ba13a4c4bc70afbb4a613468b Mon Sep 17 00:00:00 2001
From: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 29 Mar 2011 14:24:19 +0000
Subject: [PATCH 023/200] 	PR c++/47504
 	* semantics.c (cxx_eval_constant_expression) [NOP_EXPR]: Don't let
 	the conversion set TREE_OVERFLOW.

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

index d23effe..5fe1414 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7030,6 +7030,11 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t,
 	     conversion.  */
 	  return fold (t);
 	r = fold_build1 (TREE_CODE (t), to, op);
+	/* Conversion of an out-of-range value has implementation-defined
+	   behavior; the language considers it different from arithmetic
+	   overflow, which is undefined.  */
+	if (TREE_OVERFLOW_P (r) && !TREE_OVERFLOW_P (op))
+	  TREE_OVERFLOW (r) = false;
       }
       break;
 
index 598cae6..2d614ec 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-data2.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-data2.C
@@ -44,5 +44,4 @@ extern template struct A3<int, 510>;
 
 // Use.
 A3<int, 1111> a31;
-// FIXME should this be an error?
 A3<char, 9999> a32;		// { dg-warning "overflow" }
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow2.C
new file mode 100644
index 0000000..5d5749c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow2.C
@@ -0,0 +1,8 @@
+// PR c++/47504
+// { dg-options -std=c++0x }
+
+char constexpr sub(char arg)
+{ return char(arg - char(1)); }
+
+int main()
+{ static char constexpr m = sub(-1); }
-- 
1.7.0.4

OpenPOWER on IntegriCloud