aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2011-12-15 21:45:53 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2011-12-15 21:45:53 +0100
commite1b750d87ff09d884637a654624422bd2f249fbc (patch)
treef79e3741ce00ddee62d30f489f085e67f8c86985
parent666b67b1b98d4587c6f687b246109117b1fe5ebc (diff)
downloadgcc-e1b750d87ff09d884637a654624422bd2f249fbc.zip
gcc-e1b750d87ff09d884637a654624422bd2f249fbc.tar.gz
gcc-e1b750d87ff09d884637a654624422bd2f249fbc.tar.bz2
re PR c++/51463 ([c++0x] [4.7 Regression] ICE declaring a member function virtual and static)
PR c++/51463 * decl.c (grokdeclarator): Set DECL_INITIAL of decl to error_mark_node to disallow NSDMI if declspecs->storage_class is sc_static. * parser.c (cp_parser_late_parse_one_default_arg): Return early if default_arg is error_mark_node. * g++.dg/cpp0x/pr51463.C: New test. From-SVN: r182387
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/decl.c14
-rw-r--r--gcc/cp/parser.c3
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/pr51463.C8
5 files changed, 33 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3975b6b..c9ada9a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,12 @@
2011-12-15 Jakub Jelinek <jakub@redhat.com>
+ PR c++/51463
+ * decl.c (grokdeclarator): Set DECL_INITIAL of decl
+ to error_mark_node to disallow NSDMI if declspecs->storage_class
+ is sc_static.
+ * parser.c (cp_parser_late_parse_one_default_arg): Return early
+ if default_arg is error_mark_node.
+
PR c/51360
* semantics.c (finish_omp_clauses): For OMP_CLAUSE_NUM_THREADS_EXPR
and OMP_CLAUSE_SCHEDULE_CHUNK_EXPR call mark_rvalue_use.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 1fe63bb..1239535 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10220,9 +10220,17 @@ grokdeclarator (const cp_declarator *declarator,
}
if (initialized)
- /* An attempt is being made to initialize a non-static
- member. This is new in C++11. */
- maybe_warn_cpp0x (CPP0X_NSDMI);
+ {
+ /* An attempt is being made to initialize a non-static
+ member. This is new in C++11. */
+ maybe_warn_cpp0x (CPP0X_NSDMI);
+
+ /* If this has been parsed with static storage class, but
+ errors forced staticp to be cleared, ensure NSDMI is
+ not present. */
+ if (declspecs->storage_class == sc_static)
+ DECL_INITIAL (decl) = error_mark_node;
+ }
}
bad_specifiers (decl, BSP_FIELD, virtualp,
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 9301e53..30c7745 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -21853,6 +21853,9 @@ cp_parser_late_parse_one_default_arg (cp_parser *parser, tree decl,
tree parsed_arg;
bool dummy;
+ if (default_arg == error_mark_node)
+ return error_mark_node;
+
/* Push the saved tokens for the default argument onto the parser's
lexer stack. */
tokens = DEFARG_TOKENS (default_arg);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 67d91ba..1b84ff9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,11 +1,14 @@
2011-12-15 Jakub Jelinek <jakub@redhat.com>
+ PR c++/51463
+ * g++.dg/cpp0x/pr51463.C: New test.
+
PR c/51360
* c-c++-common/gomp/pr51360.c: New test.
* g++.dg/gomp/pr51360.C: New test.
PR middle-end/49806
- * gcc.dg/tree-ssa-vrp47.c: Add -fdump-tree-dom2 to dg-options.
+ * gcc.dg/tree-ssa/vrp47.c: Add -fdump-tree-dom2 to dg-options.
Check for x_? & y in dom2 dump and xfail the check in dom1 dump.
PR tree-optimization/51117
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr51463.C b/gcc/testsuite/g++.dg/cpp0x/pr51463.C
new file mode 100644
index 0000000..1e8be3b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr51463.C
@@ -0,0 +1,8 @@
+// PR c++/51463
+// { dg-do compile }
+// { dg-options "-std=c++11" }
+
+struct A
+{
+ static virtual int i = 0; // { dg-error "both virtual and static|declared as" }
+};