summaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2008-02-19 10:14:57 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2008-02-19 10:14:57 +0000
commita46a7e429e2bd775f1eb8c34bf7d6ccd58eafdfa (patch)
tree011f8a2c3a3f10a1cf3a25db7411a0fe6059d700 /gcc/cp
parent34c7f5685eaa3df5087e7bb89897b02f12b59fb4 (diff)
downloadgcc-a46a7e429e2bd775f1eb8c34bf7d6ccd58eafdfa.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132424 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/parser.c7
-rw-r--r--gcc/cp/semantics.c10
3 files changed, 23 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6789236c031..79ecec280d7 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+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
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 5f215742d49..a5bd05519b4 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -20074,8 +20074,11 @@ cp_parser_omp_for_loop (cp_parser *parser)
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);
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 49dd80e1785..44c1e3f319b 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -3903,6 +3903,16 @@ finish_omp_for (location_t locus, tree decl, tree init, tree cond,
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)