+2008-02-19 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/35078
+ * parser.c (cp_parser_omp_for_loop): If DECL has REFERENCE_TYPE, don't
+ call cp_finish_decl.
+ * semantics.c (finish_omp_for): Fail if DECL doesn't have integral type
+ early.
+
2008-02-15 Douglas Gregor <doug.gregor@gmail.com>
PR c++/35023
init = cp_parser_assignment_expression (parser, false);
- cp_finish_decl (decl, NULL_TREE, /*init_const_expr_p=*/false,
- asm_specification, LOOKUP_ONLYCONVERTING);
+ if (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE)
+ init = error_mark_node;
+ else
+ cp_finish_decl (decl, NULL_TREE, /*init_const_expr_p=*/false,
+ asm_specification, LOOKUP_ONLYCONVERTING);
if (pushed_scope)
pop_scope (pushed_scope);
return NULL;
}
+ if (!INTEGRAL_TYPE_P (TREE_TYPE (decl)))
+ {
+ location_t elocus = locus;
+
+ if (EXPR_HAS_LOCATION (init))
+ elocus = EXPR_LOCATION (init);
+ error ("%Hinvalid type for iteration variable %qE", &elocus, decl);
+ return NULL;
+ }
+
if (pre_body == NULL || IS_EMPTY_STMT (pre_body))
pre_body = NULL;
else if (! processing_template_decl)
+2008-02-19 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/35078
+ * g++.dg/gomp/pr35078.C: New test.
+
2008-02-19 Christian Bruel <christian.bruel@st.com>
* gcc.dg/packed-array.c: New testcase.
--- /dev/null
+// PR c++/35078
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+template<int> void
+foo ()
+{
+#pragma omp parallel for
+ for (int& i = 0; i < 10; ++i) // { dg-error "invalid type for iteration variable" }
+ ;
+}
+
+void
+bar ()
+{
+ int j = 0;
+#pragma omp parallel for
+ for (int& i = j; i < 10; ++i) // { dg-error "invalid type for iteration variable" }
+ ;
+}