summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0232-PR-c-48089.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0232-PR-c-48089.patch')
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0232-PR-c-48089.patch77
1 files changed, 77 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0232-PR-c-48089.patch b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0232-PR-c-48089.patch
new file mode 100644
index 0000000000..300b4e143e
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0232-PR-c-48089.patch
@@ -0,0 +1,77 @@
1From 3db4aa63d6850f44758d06d5f075c76de6d4c1e9 Mon Sep 17 00:00:00 2001
2From: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
3Date: Fri, 6 May 2011 21:58:22 +0000
4Subject: [PATCH] PR c++/48089
5 * semantics.c (potential_constant_expression_1): Don't allow *this
6 in a constructor.
7 (register_constexpr_fundef): Use potential_rvalue_constant_expression.
8
9git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173513 138bc75d-0d04-0410-961f-82ee72b054a4
10
11index f43649e..8f621b9 100644
12--- a/gcc/cp/semantics.c
13+++ b/gcc/cp/semantics.c
14@@ -5704,11 +5704,11 @@ register_constexpr_fundef (tree fun, tree body)
15 body = unshare_expr (TREE_OPERAND (body, 0));
16 }
17
18- if (!potential_constant_expression (body))
19+ if (!potential_rvalue_constant_expression (body))
20 {
21 DECL_DECLARED_CONSTEXPR_P (fun) = false;
22 if (!DECL_TEMPLATE_INSTANTIATION (fun))
23- require_potential_constant_expression (body);
24+ require_potential_rvalue_constant_expression (body);
25 return NULL;
26 }
27 fundef->body = body;
28@@ -7560,7 +7560,16 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags)
29 tree x = TREE_OPERAND (t, 0);
30 STRIP_NOPS (x);
31 if (is_this_parameter (x))
32- return true;
33+ {
34+ if (DECL_CONSTRUCTOR_P (DECL_CONTEXT (x)) && want_rval)
35+ {
36+ if (flags & tf_error)
37+ sorry ("use of the value of the object being constructed "
38+ "in a constant expression");
39+ return false;
40+ }
41+ return true;
42+ }
43 return potential_constant_expression_1 (x, rval, flags);
44 }
45
46new file mode 100644
47index 0000000..fc69cfe
48--- /dev/null
49+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-48089.C
50@@ -0,0 +1,24 @@
51+// PR c++/48089
52+// { dg-options -std=c++0x }
53+
54+// bang is ill-formed (diagnostic required) because its initializer is
55+// non-constant, because it uses the value of an uninitialized object.
56+
57+// s() is ill-formed (no diagnostic required) because there is no set of
58+// arguments that would produce a constant expression.
59+
60+// R() is well-formed because i is initialized before j.
61+
62+struct s {
63+ constexpr s() : v(v) { } // { dg-message "" }
64+ int v;
65+};
66+
67+constexpr s bang; // { dg-error "" }
68+
69+struct R {
70+ int i,j;
71+ constexpr R() : i(42),j(i) { } // { dg-bogus "" "" { xfail *-*-* } }
72+};
73+
74+constexpr R r; // { dg-bogus "" "" { xfail *-*-* } }
75--
761.7.0.4
77