aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2012-01-12 23:28:46 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2012-01-13 00:28:46 +0100
commit1cef710256a340b7a13e00f8a088b5709569e0c6 (patch)
tree20aed99bf958983ce825e6124ec717166396a71a /gcc
parent639d4bb87cd62a6b136ba653cc3e8fddec4f0fd6 (diff)
downloadgcc-1cef710256a340b7a13e00f8a088b5709569e0c6.zip
gcc-1cef710256a340b7a13e00f8a088b5709569e0c6.tar.gz
gcc-1cef710256a340b7a13e00f8a088b5709569e0c6.tar.bz2
PR c++/51633 - ICEs with constexpr constructor
gcc/cp/ PR c++/51633 * semantics.c (cp_parser_ctor_initializer_opt_and_function_body): Set the pointer to the last block of the constructor to the current statement. (build_constexpr_constructor_member_initializers): Get build_data_member_initialization a chance to deal with more statements before we choke. gcc/testsuite/ PR c++/51633 * g++.dg/cpp0x/constexpr-diag4.C: New test. From-SVN: r183144
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/parser.c7
-rw-r--r--gcc/cp/semantics.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-diag4.C25
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-diag5.C48
6 files changed, 92 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6047df3..63d8f2f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,13 @@
+2012-01-13 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/51633
+ * semantics.c (cp_parser_ctor_initializer_opt_and_function_body):
+ Set the pointer to the last block of the constructor to the
+ current statement.
+ (build_constexpr_constructor_member_initializers): Get
+ build_data_member_initialization a chance to deal with more
+ statements before we choke.
+
2012-01-12 Jason Merrill <jason@redhat.com>
PR c++/48051
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 4c85355..c4c3ef4 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -17424,11 +17424,8 @@ cp_parser_ctor_initializer_opt_and_function_body (cp_parser *parser)
cp_parser_function_body changed its state. */
if (check_body_p)
{
- list = body;
- if (TREE_CODE (list) == BIND_EXPR)
- list = BIND_EXPR_BODY (list);
- if (TREE_CODE (list) == STATEMENT_LIST
- && STATEMENT_LIST_TAIL (list) != NULL)
+ list = cur_stmt_list;
+ if (STATEMENT_LIST_TAIL (list))
last = STATEMENT_LIST_TAIL (list)->stmt;
}
/* Parse the function-body. */
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 2c351be..6f6f0ac 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -5930,6 +5930,8 @@ build_constexpr_constructor_member_initializers (tree type, tree body)
break;
}
}
+ else if (EXPR_P (body))
+ ok = build_data_member_initialization (body, &vec);
else
gcc_assert (errorcount > 0);
if (ok)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 224f98f..a4b09ea 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-01-13 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/51633
+ * g++.dg/cpp0x/constexpr-diag4.C: New test.
+
2012-01-12 Jason Merrill <jason@redhat.com>
PR c++/48051
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag4.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag4.C
new file mode 100644
index 0000000..371190e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag4.C
@@ -0,0 +1,25 @@
+// Origin: PR c++/51633
+// { dg-options "-std=c++11" }
+
+struct A
+{
+ ~A();
+};
+
+struct B
+{
+ A a;
+ constexpr B() {}
+};
+
+struct A1
+{
+ int a;
+ ~A1();
+};
+
+struct B1
+{
+ A1 a1;
+ constexpr B1() {} // { dg-error "uninitialized member" }
+};
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag5.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag5.C
new file mode 100644
index 0000000..c0cbfdd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag5.C
@@ -0,0 +1,48 @@
+// Origin: PR c++/51633
+// { dg-options "-std=c++11" }
+
+struct A
+{
+ constexpr A() {}
+ ~A();
+};
+
+struct B
+{
+ A a;
+ A b;
+ A c;
+ constexpr B() {}
+};
+
+struct C
+{
+ A a;
+ constexpr C() {}
+};
+
+struct D
+{
+ constexpr D() { return;} // { dg-error "does not have empty body" }
+};
+
+struct D1
+{
+ A a;
+ constexpr D1() { return;} // { dg-error "does not have empty body" }
+};
+
+struct D2
+{
+ A a;
+ A b;
+ constexpr D2() { return;} // { dg-error "does not have empty body" }
+};
+
+struct D3
+{
+ A a;
+ A b;
+ A c;
+ constexpr D3() { return;} // { dg-error "does not have empty body" }
+};