aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2003-09-06 11:29:17 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2003-09-06 11:29:17 +0000
commitb92bc2a028982a808589a187381095c158182446 (patch)
tree73b60b4f2fc5d263fe54ad0e1c85ed387bcbc5d5
parent13f7d3a1c0fea5ef96f2c89ec96dad1f2e59b330 (diff)
downloadgcc-b92bc2a028982a808589a187381095c158182446.zip
gcc-b92bc2a028982a808589a187381095c158182446.tar.gz
gcc-b92bc2a028982a808589a187381095c158182446.tar.bz2
re PR c++/12167 (ICE on default argument of class member function if non-simple)
cp: PR c++/12167 * parser.c (cp_parser_late_parsing_default_args): Push & pop the unparsed functions queue. testsuite: PR c++/12167 * g++.dg/parse/defarg5.C: New test. * g++.dg/template/non-type-template-argument-1.C: Tweak expected error. From-SVN: r71133
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c11
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/g++.dg/parse/defarg5.C15
-rw-r--r--gcc/testsuite/g++.dg/template/non-type-template-argument-1.C2
5 files changed, 40 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7840de4..4926d58 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2003-09-06 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/12167
+ * parser.c (cp_parser_late_parsing_default_args): Push & pop the
+ unparsed functions queue.
+
2003-09-05 Mark Mitchell <mark@codesourcery.com>
PR c++/12163
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 786e1ee..dffddab 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -13883,6 +13883,13 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn)
bool saved_local_variables_forbidden_p;
tree parameters;
+ /* While we're parsing the default args, we might (due to the
+ statement expression extension) encounter more classes. We want
+ to handle them right away, but we don't want them getting mixed
+ up with default args that are currently in the queue. */
+ parser->unparsed_functions_queues
+ = tree_cons (NULL_TREE, NULL_TREE, parser->unparsed_functions_queues);
+
for (parameters = TYPE_ARG_TYPES (TREE_TYPE (fn));
parameters;
parameters = TREE_CHAIN (parameters))
@@ -13916,6 +13923,10 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn)
parser->lexer = saved_lexer;
parser->local_variables_forbidden_p = saved_local_variables_forbidden_p;
}
+
+ /* Restore the queue. */
+ parser->unparsed_functions_queues
+ = TREE_CHAIN (parser->unparsed_functions_queues);
}
/* Parse the operand of `sizeof' (or a similar operator). Returns
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 724bdef..d28f2d1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2003-09-06 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/12167
+ * g++.dg/parse/defarg5.C: New test.
+
+ * g++.dg/template/non-type-template-argument-1.C: Tweak expected error.
+
2003-09-05 Mark Mitchell <mark@codesourcery.com>
PR c++/12163
diff --git a/gcc/testsuite/g++.dg/parse/defarg5.C b/gcc/testsuite/g++.dg/parse/defarg5.C
new file mode 100644
index 0000000..01a67ed
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/defarg5.C
@@ -0,0 +1,15 @@
+// { dg-do compile }
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 5 Sep 2003 <nathan@codesourcery.com>
+// Origin:Wolfgang Bangerth bangerth@dealii.org
+
+// PR c++/12167 - infinite recursion
+
+class A {
+ void report(int d
+ // the default arg is what NAN etc can expand to, but
+ // with the floatiness removed.
+ = (__extension__ ((union { unsigned l; int d; })
+ { l: 0x7fc00000U }).d));
+};
diff --git a/gcc/testsuite/g++.dg/template/non-type-template-argument-1.C b/gcc/testsuite/g++.dg/template/non-type-template-argument-1.C
index fbe5f3f..2730176 100644
--- a/gcc/testsuite/g++.dg/template/non-type-template-argument-1.C
+++ b/gcc/testsuite/g++.dg/template/non-type-template-argument-1.C
@@ -6,7 +6,7 @@ template <bool> struct C {};
template <typename T> struct D
{
- C<T::X> c; // { dg-error "invalid use" }
+ C<T::X> c; // { dg-error "names a type" }
};
D<B> d; // { dg-error "" }