re PR c++/12167 (ICE on default argument of class member function if non-simple)
authorNathan Sidwell <nathan@codesourcery.com>
Sat, 6 Sep 2003 11:29:17 +0000 (11:29 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Sat, 6 Sep 2003 11:29:17 +0000 (11:29 +0000)
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

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/defarg5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/non-type-template-argument-1.C

index 7840de47bf7b73fd34aa388266b299ff1f8559c5..4926d58349f47bb015531a861962d82a919871cf 100644 (file)
@@ -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
index 786e1ee4bd58c2bb946568e2a2b10a01ba0c609f..dffddabdb4c7d5f851a38f6f0938c62f105ffef9 100644 (file)
@@ -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
index 724bdef2112119d361fdbb385fd121cb4c6f1f92..d28f2d11645a5fda6efa1f01413e2336f72d6c87 100644 (file)
@@ -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 (file)
index 0000000..01a67ed
--- /dev/null
@@ -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));
+};
index fbe5f3f456bf7e633861c62588e4cbdbd4ff131e..273017635c3f2097f43d0368a9cf40fe98d1967f 100644 (file)
@@ -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 "" }