This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH,committed] Fix ICE in PR13166 regression (default arg infriend decl)
- From: Kriang Lerdsuwanakij <lerdsuwa at users dot sourceforge dot net>
- To: <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 5 Dec 2003 21:44:44 +0700 (ICT)
- Subject: [C++ PATCH,committed] Fix ICE in PR13166 regression (default arg infriend decl)
- Reply-to: <lerdsuwa at users dot sourceforge dot net>
Hi
This obvious patch fix the ICE reported in PR13166 which is a regression in
GCC 3.4. In the case where FN is a friend declaration, its DECL_CONTEXT
may be a NAMESPACE_DECL node. This confuses push/pop_nested_class and
triggers ICE. Fixed by the patch below. However full DR136 conformance,
i.e. rejecting codes not allowed by DR136, will be handled separately but
the chuck of code below is still required.
Committed to trunk. Tested on i686-pc-linux-gnu.
--Kriang
2003-12-05 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/13166
* parser.c (cp_parser_late_parsing_default_args): Make sure the
context is a class before calling push_nested_class and
pop_nested_class.
2003-12-05 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/13166
* g++.dg/parse/defarg6.C: New test.
diff -cprN gcc-main-save/gcc/cp/parser.c gcc-main-new/gcc/cp/parser.c
*** gcc-main-save/gcc/cp/parser.c Sat Nov 15 18:18:59 2003
--- gcc-main-new/gcc/cp/parser.c Fri Dec 5 17:57:05 2003
*************** cp_parser_late_parsing_default_args (cp_
*** 14031,14040 ****
saved_local_variables_forbidden_p = parser->local_variables_forbidden_p;
parser->local_variables_forbidden_p = true;
/* Parse the assignment-expression. */
! if (DECL_CONTEXT (fn))
push_nested_class (DECL_CONTEXT (fn));
TREE_PURPOSE (parameters) = cp_parser_assignment_expression (parser);
! if (DECL_CONTEXT (fn))
pop_nested_class ();
/* Restore saved state. */
--- 14031,14040 ----
saved_local_variables_forbidden_p = parser->local_variables_forbidden_p;
parser->local_variables_forbidden_p = true;
/* Parse the assignment-expression. */
! if (DECL_CLASS_SCOPE_P (fn))
push_nested_class (DECL_CONTEXT (fn));
TREE_PURPOSE (parameters) = cp_parser_assignment_expression (parser);
! if (DECL_CLASS_SCOPE_P (fn))
pop_nested_class ();
/* Restore saved state. */
diff -cprN gcc-main-save/gcc/testsuite/g++.dg/parse/defarg6.C gcc-main-new/gcc/testsuite/g++.dg/parse/defarg6.C
*** gcc-main-save/gcc/testsuite/g++.dg/parse/defarg6.C Thu Jan 1 07:00:00 1970
--- gcc-main-new/gcc/testsuite/g++.dg/parse/defarg6.C Fri Dec 5 18:02:17 2003
***************
*** 0 ****
--- 1,11 ----
+ // { dg-do compile }
+
+ // Origin: Falk Hueffner <falk@debian.org>
+
+ // PR c++/13166: ICE default function argument for friend declaration.
+
+ namespace sc_dt {
+ class sc_length_param {
+ friend int compare_unsigned(int if_v_signed = 0) {}
+ };
+ }