===================================================================
@@ -0,0 +1,4 @@
+// PR c++/51404
+// { dg-options -std=c++0x }
+
+int i = auto().x; // { dg-error "invalid use of" }
===================================================================
@@ -1653,7 +1653,7 @@ build_functional_cast (tree exp, tree parms, tsubs
{
if (complain & tf_error)
error ("invalid use of %<auto%>");
- type = error_mark_node;
+ return error_mark_node;
}
if (processing_template_decl)
===================================================================
@@ -16055,23 +16055,26 @@ cp_parser_direct_declarator (cp_parser* parser,
&non_constant_p);
if (!non_constant_p)
/* OK */;
- /* Normally, the array bound must be an integral constant
- expression. However, as an extension, we allow VLAs
- in function scopes as long as they aren't part of a
- parameter declaration. */
- else if (!parser->in_function_body
- || current_binding_level->kind == sk_function_parms)
+ else if (!error_operand_p (bounds))
{
- cp_parser_error (parser,
- "array bound is not an integer constant");
- bounds = error_mark_node;
+ /* Normally, the array bound must be an integral constant
+ expression. However, as an extension, we allow VLAs
+ in function scopes as long as they aren't part of a
+ parameter declaration. */
+ if (!parser->in_function_body
+ || current_binding_level->kind == sk_function_parms)
+ {
+ cp_parser_error (parser, "array bound is not an "
+ "integer constant");
+ bounds = error_mark_node;
+ }
+ else if (processing_template_decl)
+ {
+ /* Remember this wasn't a constant-expression. */
+ bounds = build_nop (TREE_TYPE (bounds), bounds);
+ TREE_SIDE_EFFECTS (bounds) = 1;
+ }
}
- else if (processing_template_decl && !error_operand_p (bounds))
- {
- /* Remember this wasn't a constant-expression. */
- bounds = build_nop (TREE_TYPE (bounds), bounds);
- TREE_SIDE_EFFECTS (bounds) = 1;
- }
}
else
bounds = NULL_TREE;