From: Nathan Sidwell Date: Sat, 6 Sep 2003 11:29:17 +0000 (+0000) Subject: re PR c++/12167 (ICE on default argument of class member function if non-simple) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b92bc2a028982a808589a187381095c158182446;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7840de47bf7..4926d58349f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-09-06 Nathan Sidwell + + PR c++/12167 + * parser.c (cp_parser_late_parsing_default_args): Push & pop the + unparsed functions queue. + 2003-09-05 Mark Mitchell PR c++/12163 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 786e1ee4bd5..dffddabdb4c 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 724bdef2112..d28f2d11645 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2003-09-06 Nathan Sidwell + + 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 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 00000000000..01a67ed5915 --- /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 +// 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 fbe5f3f456b..273017635c3 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 struct C {}; template struct D { - C c; // { dg-error "invalid use" } + C c; // { dg-error "names a type" } }; D d; // { dg-error "" }