aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2008-12-01 16:27:12 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2008-12-01 16:27:12 +0100
commita2d4cdc96a585c0b863226b2f142445538674127 (patch)
treeecc36046a609da5f002a051ee7dfcc4183fc8c30 /gcc/cp/parser.c
parent9b10560935521f81f26a4f1fe12d7b4bb1de33d0 (diff)
downloadgcc-a2d4cdc96a585c0b863226b2f142445538674127.zip
gcc-a2d4cdc96a585c0b863226b2f142445538674127.tar.gz
gcc-a2d4cdc96a585c0b863226b2f142445538674127.tar.bz2
re PR c++/38257 (ICE with auto and #pragma omp parallel)
PR c++/38257 * parser.c (cp_parser_omp_for_loop): Handle auto. * pt.c (tsubst_omp_for_iterator): Likewise. * testsuite/libgomp.c++/for-7.C: New test. From-SVN: r142320
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 6870037..275a7f3 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -21118,13 +21118,14 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
else
{
- tree pushed_scope;
+ tree pushed_scope, auto_node;
decl = start_decl (declarator, &type_specifiers,
- /*initialized_p=*/false, attributes,
+ SD_INITIALIZED, attributes,
/*prefix_attributes=*/NULL_TREE,
&pushed_scope);
+ auto_node = type_uses_auto (TREE_TYPE (decl));
if (cp_lexer_next_token_is_not (parser->lexer, CPP_EQ))
{
if (cp_lexer_next_token_is (parser->lexer,
@@ -21139,7 +21140,8 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
cp_parser_skip_to_end_of_statement (parser);
}
else if (CLASS_TYPE_P (TREE_TYPE (decl))
- || type_dependent_expression_p (decl))
+ || type_dependent_expression_p (decl)
+ || auto_node)
{
bool is_direct_init, is_non_constant_init;
@@ -21147,6 +21149,17 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
&is_direct_init,
&is_non_constant_init);
+ if (auto_node && !type_dependent_expression_p (init))
+ {
+ TREE_TYPE (decl)
+ = do_auto_deduction (TREE_TYPE (decl), init,
+ auto_node);
+
+ if (!CLASS_TYPE_P (TREE_TYPE (decl))
+ && !type_dependent_expression_p (decl))
+ goto non_class;
+ }
+
cp_finish_decl (decl, init, !is_non_constant_init,
asm_specification,
LOOKUP_ONLYCONVERTING);
@@ -21166,6 +21179,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
cp_lexer_consume_token (parser->lexer);
init = cp_parser_assignment_expression (parser, false);
+ non_class:
if (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE)
init = error_mark_node;
else