parser.c (cp_parser_late_parsing_default_args): Fix overeager assert in previous...
authorNathan Sidwell <nathan@codesourcery.com>
Tue, 7 Jun 2005 08:45:32 +0000 (08:45 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 7 Jun 2005 08:45:32 +0000 (08:45 +0000)
cp:
* parser.c (cp_parser_late_parsing_default_args): Fix overeager
assert in previous patch.
testsuite:
* g++.dg/parse/defarg10.C: New.

From-SVN: r100702

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/defarg10.C [new file with mode: 0644]

index cbfe764..9979978 100644 (file)
@@ -1,3 +1,8 @@
+2005-06-07  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * parser.c (cp_parser_late_parsing_default_args): Fix overeager
+       assert in previous patch.
+
 2005-06-06  Jakub Jelinek  <jakub@redhat.com>
 
        * error.c (locate_error): Use gmsgid instead of msgid for argument
index c0059d0..23c1621 100644 (file)
@@ -15599,7 +15599,10 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn)
       if (!default_arg)
        continue;
 
-      gcc_assert (TREE_CODE (default_arg) == DEFAULT_ARG);
+      if (TREE_CODE (default_arg) != DEFAULT_ARG)
+       /* This can happen for a friend declaration for a function
+          already declared with default arguments.  */
+       continue;
 
        /* Push the saved tokens for the default argument onto the parser's
          lexer stack.  */
index 65f2435..a6edac7 100644 (file)
@@ -1,3 +1,7 @@
+2005-06-07  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * g++.dg/parse/defarg10.C: New.
+
 2005-06-06  Jakub Jelinek  <jakub@redhat.com>
 
        PR regression/21897
diff --git a/gcc/testsuite/g++.dg/parse/defarg10.C b/gcc/testsuite/g++.dg/parse/defarg10.C
new file mode 100644 (file)
index 0000000..ca228ac
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright (C) 2005 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 7 Jun 2005 <nathan@codesourcery.com>
+
+// From java library.
+
+void  Foo (int = 0);
+
+class Class
+{
+  friend void Foo (int);
+};