+2015-10-01 Ville Voutilainen <ville.voutilainen@gmail.com>
+
+ PR c++/54430
+ * name-lookup.c (push_binding): Make non-static.
+ * name-lookup.h (push_binding): Declare it.
+ * parser.c (cp_parser_range_for): Use it, get the range
+ declaration away from the scope until the range expression
+ has been parsed, then restore the declaration.
+
2015-09-23 Ville Voutilainen <ville.voutilainen@gmail.com>
Fix small typos in the coding rule enforcement warnings.
/* Make DECL the innermost binding for ID. The LEVEL is the binding
level at which this declaration is being bound. */
-static void
+void
push_binding (tree id, tree decl, cp_binding_level* level)
{
cxx_binding *binding;
extern tree identifier_type_value (tree);
extern void set_identifier_type_value (tree, tree);
+extern void push_binding (tree, tree, cp_binding_level*);
extern void pop_binding (tree, tree);
extern void pop_bindings_and_leave_scope (void);
extern tree constructor_name (tree);
{
tree stmt, range_expr;
+ /* Get the range declaration momentarily out of the way so that
+ the range expression doesn't clash with it. */
+ if (range_decl != error_mark_node)
+ pop_binding (DECL_NAME (range_decl), range_decl);
+
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
{
bool expr_non_constant_p;
else
range_expr = cp_parser_expression (parser);
+ /* Put the range declaration back into scope. */
+ if (range_decl != error_mark_node)
+ push_binding (DECL_NAME (range_decl), range_decl, current_binding_level);
+
/* If in template, STMT is converted to a normal for-statement
at instantiation. If not, it is done just ahead. */
if (processing_template_decl)
+2015-10-01 Ville Voutilainen <ville.voutilainen@gmail.com>
+
+ PR c++/54430
+ * g++.dg/cpp0x/range-for30.C: New.
+
2015-10-01 Marek Polacek <polacek@redhat.com>
PR c/65345
--- /dev/null
+// PR c++/54430
+// { dg-require-effective-target c++11 }
+
+struct A
+{
+ A(int) {}
+ int* begin() {return nullptr;}
+ int* end() {return nullptr;}
+};
+
+int main()
+{
+ int i[] = { 1, 2, 3, 4 };
+ for (int i : i);
+ for (auto i : i);
+ for (A v : v); // { dg-error "not declared in this scope" }
+}