On 06/01/2012 06:19 PM, Jason Merrill wrote:
On 06/01/2012 11:40 AM, Florian Weimer wrote:
I'm puzzled why build_new is even invoked after detecting that there is
a non-constant expression.

I'd accept a patch to change that.

I don't really now what I'm doing here. But I noticed that in cp_parser_constant_expression, a failure in require_potential_rvalue_constant_expression is not reported to the caller.

This changes error reporting, and a few test cases need adjustment. In some, reporting is better, in others, it's slightly worse. I need to make a second pass over the changes to make sure that they are alright.

Does this change make any sense at all?

Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c     (revision 188104)
+++ gcc/cp/parser.c     (working copy)
@@ -7701,8 +7701,9 @@ cp_parser_constant_expression (cp_parser* parser,
         separately in e.g. cp_parser_template_argument.  */
       bool is_const = potential_rvalue_constant_expression (expression);
       parser->non_integral_constant_expression_p = !is_const;
-      if (!is_const && !allow_non_constant_p)
-       require_potential_rvalue_constant_expression (expression);
+      if (!is_const && !allow_non_constant_p
+         && !require_potential_rvalue_constant_expression (expression))
+       expression = error_mark_node;
     }
   if (allow_non_constant_p)
     *non_constant_p = parser->non_integral_constant_expression_p;


--
Florian Weimer / Red Hat Product Security Team

Reply via email to