Mark Mitchell <mark@codesourcery.com>
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 10 Oct 2005 22:30:17 +0000 (22:30 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 10 Oct 2005 22:30:17 +0000 (22:30 +0000)
        PR c++/23437
* parser.c (cp_parser_template_argument_list): Do not treat
contents of argument list as part of a constant expression.
PR c++/23437
* g++.dg/template/arg4.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105199 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 87d5299..390384b 100644 (file)
@@ -1,3 +1,10 @@
+2005-10-10  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
+           Mark Mitchell  <mark@codesourcery.com>
+
+        PR c++/23437
+       * parser.c (cp_parser_template_argument_list): Do not treat
+       contents of argument list as part of a constant expression.
+
 2005-10-10  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/24139
index a4eedc1..e5a03fc 100644 (file)
@@ -8904,9 +8904,18 @@ cp_parser_template_argument_list (cp_parser* parser)
   tree *arg_ary = fixed_args;
   tree vec;
   bool saved_in_template_argument_list_p;
+  bool saved_ice_p;
+  bool saved_non_ice_p;
 
   saved_in_template_argument_list_p = parser->in_template_argument_list_p;
   parser->in_template_argument_list_p = true;
+  /* Even if the template-id appears in an integral
+     constant-expression, the contents of the argument list do 
+     not.  */ 
+  saved_ice_p = parser->integral_constant_expression_p;
+  parser->integral_constant_expression_p = false;
+  saved_non_ice_p = parser->non_integral_constant_expression_p;
+  parser->non_integral_constant_expression_p = false;
   do
     {
       tree argument;
@@ -8940,6 +8949,8 @@ cp_parser_template_argument_list (cp_parser* parser)
 
   if (arg_ary != fixed_args)
     free (arg_ary);
+  parser->non_integral_constant_expression_p = saved_non_ice_p;
+  parser->integral_constant_expression_p = saved_ice_p;
   parser->in_template_argument_list_p = saved_in_template_argument_list_p;
   return vec;
 }
index c8514a8..9e9dc6e 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-10  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/23437
+       * g++.dg/template/arg4.C: New test.
+
 2005-10-10  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * gcc.dg/ucnid-2.c: XFAIL on Solaris.
diff --git a/gcc/testsuite/g++.dg/template/arg4.C b/gcc/testsuite/g++.dg/template/arg4.C
new file mode 100644 (file)
index 0000000..9c9d9ea
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/23437
+
+template <void (*p)()> struct S {
+  static const int i = 10;
+};
+
+void g();
+
+int a[S<g>::i];