aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-03-29 14:47:43 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-03-29 14:47:43 -0400
commit00a0d6f3590e0e9891fc01d21667de892d6a89c6 (patch)
treeea1426ddcfe08e8bf73ce3214a37e83090c61fe5
parent5c82436e4009c53b40616b83da778e3548a8a6af (diff)
downloadgcc-00a0d6f3590e0e9891fc01d21667de892d6a89c6.zip
gcc-00a0d6f3590e0e9891fc01d21667de892d6a89c6.tar.gz
gcc-00a0d6f3590e0e9891fc01d21667de892d6a89c6.tar.bz2
re PR c++/48089 ([C++0x] ICE on in(?)valid in constexpr constructors)
PR c++/48089 * semantics.c (potential_constant_expression_1): Change error about use of *this in constructor into sorry. From-SVN: r171687
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/semantics.c4
-rw-r--r--gcc/testsuite/ChangeLog2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-48089.C21
4 files changed, 26 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1ffe70b..3d0c02a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2011-03-29 Jason Merrill <jason@redhat.com>
+ PR c++/48089
+ * semantics.c (potential_constant_expression_1): Change error about
+ use of *this in constructor into sorry.
+
PR c++/48296
* decl.c (cp_finish_decl): Defer validation of constexpr member
functions.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index f1c3d9a..5a65943 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7495,8 +7495,8 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags)
if (DECL_CONSTRUCTOR_P (DECL_CONTEXT (x)) && want_rval)
{
if (flags & tf_error)
- error ("the value of the object being constructed is "
- "not a constant expression");
+ sorry ("use of the value of the object being constructed "
+ "in a constant expression");
return false;
}
return true;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5cb4f4e..fbd21e5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,7 @@
2011-03-29 Jason Merrill <jason@redhat.com>
+ * g++.dg/cpp0x/constexpr-48089.C: Adjust.
+
* g++.dg/cpp0x/constexpr-memfn1.C: New.
* g++.dg/cpp0x/constexpr-diag1.C: Adjust error locations.
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-48089.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-48089.C
index 88ef3d6..fc69cfe 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-48089.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-48089.C
@@ -1,9 +1,24 @@
// PR c++/48089
// { dg-options -std=c++0x }
+// bang is ill-formed (diagnostic required) because its initializer is
+// non-constant, because it uses the value of an uninitialized object.
+
+// s() is ill-formed (no diagnostic required) because there is no set of
+// arguments that would produce a constant expression.
+
+// R() is well-formed because i is initialized before j.
+
struct s {
- constexpr s() : v(v) { } // { dg-error "object being constructed" }
- char v;
+ constexpr s() : v(v) { } // { dg-message "" }
+ int v;
+};
+
+constexpr s bang; // { dg-error "" }
+
+struct R {
+ int i,j;
+ constexpr R() : i(42),j(i) { } // { dg-bogus "" "" { xfail *-*-* } }
};
-s bang;
+constexpr R r; // { dg-bogus "" "" { xfail *-*-* } }