Commit dadb19e0 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/35078 (ICE with reference in parallel for loop)

	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.

	* g++.dg/gomp/pr35078.C: New test.

From-SVN: r132424
parent de82c453
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> 2008-02-15 Douglas Gregor <doug.gregor@gmail.com>
PR c++/35023 PR c++/35023
......
...@@ -20074,8 +20074,11 @@ cp_parser_omp_for_loop (cp_parser *parser) ...@@ -20074,8 +20074,11 @@ cp_parser_omp_for_loop (cp_parser *parser)
init = cp_parser_assignment_expression (parser, false); init = cp_parser_assignment_expression (parser, false);
cp_finish_decl (decl, NULL_TREE, /*init_const_expr_p=*/false, if (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE)
asm_specification, LOOKUP_ONLYCONVERTING); init = error_mark_node;
else
cp_finish_decl (decl, NULL_TREE, /*init_const_expr_p=*/false,
asm_specification, LOOKUP_ONLYCONVERTING);
if (pushed_scope) if (pushed_scope)
pop_scope (pushed_scope); pop_scope (pushed_scope);
......
...@@ -3903,6 +3903,16 @@ finish_omp_for (location_t locus, tree decl, tree init, tree cond, ...@@ -3903,6 +3903,16 @@ finish_omp_for (location_t locus, tree decl, tree init, tree cond,
return NULL; 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)) if (pre_body == NULL || IS_EMPTY_STMT (pre_body))
pre_body = NULL; pre_body = NULL;
else if (! processing_template_decl) 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> 2008-02-19 Christian Bruel <christian.bruel@st.com>
* gcc.dg/packed-array.c: New testcase. * gcc.dg/packed-array.c: New testcase.
// 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" }
;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment