[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gomp-discuss] C parser patch for parsing omp pragmas
From: |
Kurochkin Dmitriy |
Subject: |
Re: [Gomp-discuss] C parser patch for parsing omp pragmas |
Date: |
Fri, 18 Feb 2005 22:05:05 +0300 |
User-agent: |
Mutt/1.5.6+20040523i |
Hello.
Here are some fixes to the patch.
- fixed logical error with c_parser_skip_until_found (), that didn't
allow multiple clauses to be parsed correctly
- now expression is handled and printed correctly for 'if' and
'schedule' clauses
Dmitriy
--- orig/gcc/c-parser.c
+++ mod/gcc/c-parser.c
@@ -5055,9 +5055,15 @@
if (c_parser_require (parser, CPP_OPEN_PAREN, "'(' expected"))
{
c_parser_pragma_omp_variable_list (parser);
- c_parser_require (parser, CPP_CLOSE_PAREN, "')' expected");
+ if (!c_parser_require (parser, CPP_CLOSE_PAREN, "')' expected"))
+ {
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
+ }
+ }
+ else
+ {
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
}
- c_parser_skip_until_found (parser, CPP_EOF, "EOF expected");
}
static void c_parser_pragma_omp_clause_default (c_parser *);
@@ -5085,15 +5091,22 @@
goto error;
}
c_parser_consume_token (parser);
- c_parser_require (parser, CPP_CLOSE_PAREN, "')' expected");
+ if (!c_parser_require (parser, CPP_CLOSE_PAREN, "')' expected"))
+ {
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
+ }
}
else
{
error:
c_parser_error (parser, "'none' or 'shared' expected");
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
}
}
- c_parser_skip_until_found (parser, CPP_EOF, "EOF expected");
+ else
+ {
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
+ }
}
static void c_parser_pragma_omp_clause_firstprivate (c_parser *);
@@ -5106,9 +5119,15 @@
if (c_parser_require (parser, CPP_OPEN_PAREN, "'(' expected"))
{
c_parser_pragma_omp_variable_list (parser);
- c_parser_require (parser, CPP_CLOSE_PAREN, "')' expected");
+ if (!c_parser_require (parser, CPP_CLOSE_PAREN, "')' expected"))
+ {
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
+ }
+ }
+ else
+ {
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
}
- c_parser_skip_until_found (parser, CPP_EOF, "EOF expected");
}
static void c_parser_pragma_omp_clause_if (c_parser *);
@@ -5116,13 +5135,19 @@
static void
c_parser_pragma_omp_clause_if (c_parser *parser)
{
- printf ("if, NOT working now\n");
+ printf ("if: ");
- if (c_parser_require (parser, CPP_OPEN_PAREN, "'(' expected"))
+ if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
{
- c_parser_require (parser, CPP_CLOSE_PAREN, "')' expected");
+ tree t = c_parser_paren_condition (parser);
+ print_generic_expr (stdout, t, 0);
+ printf ("\n");
+ }
+ else
+ {
+ c_parser_error (parser, "'(' expected");
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
}
- c_parser_skip_until_found (parser, CPP_EOF, "EOF expected");
}
static void c_parser_pragma_omp_clause_lastprivate (c_parser *);
@@ -5135,9 +5160,15 @@
if (c_parser_require (parser, CPP_OPEN_PAREN, "'(' expected"))
{
c_parser_pragma_omp_variable_list (parser);
- c_parser_require (parser, CPP_CLOSE_PAREN, "')' expected");
+ if (!c_parser_require (parser, CPP_CLOSE_PAREN, "')' expected"))
+ {
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
+ }
+ }
+ else
+ {
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
}
- c_parser_skip_until_found (parser, CPP_EOF, "EOF expected");
}
static inline void c_parser_pragma_omp_clause_nowait (c_parser *);
@@ -5166,9 +5197,15 @@
if (c_parser_require (parser, CPP_OPEN_PAREN, "'(' expected"))
{
c_parser_pragma_omp_variable_list (parser);
- c_parser_require (parser, CPP_CLOSE_PAREN, "')' expected");
+ if (!c_parser_require (parser, CPP_CLOSE_PAREN, "')' expected"))
+ {
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
+ }
+ }
+ else
+ {
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
}
- c_parser_skip_until_found (parser, CPP_EOF, "EOF expected");
}
static void c_parser_pragma_omp_clause_reduction (c_parser *);
@@ -5216,9 +5253,16 @@
c_parser_pragma_omp_variable_list (parser);
c_parser_require (parser, CPP_CLOSE_PAREN, "')' expected");
}
+ else
+ {
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
+ }
+ }
+ else
+ {
+ error:
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
}
- error:
- c_parser_skip_until_found (parser, CPP_EOF, "EOF expected");
}
static void c_parser_pragma_omp_clause_schedule (c_parser *);
@@ -5258,26 +5302,38 @@
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_COMMA))
{
+ /* Taken from c_parser_paren_condition (). */
+ location_t loc = c_parser_peek_token (parser)->location;
+ tree t;
+
c_parser_consume_token (parser);
- if (c_parser_next_token_is_not (parser, CPP_NAME))
- {
- c_parser_error (parser, "ONLY CPP_NAME accepted now");
- c_parser_skip_until_found (parser, CPP_EOF, 0);
- return;
- }
- printf (", %s\n", IDENTIFIER_POINTER (c_parser_peek_token
(parser)->value));
- c_parser_consume_token (parser);
+ printf (", ");
+
+ t = lang_hooks.truthvalue_conversion (c_parser_expression
(parser).value);
+ if (EXPR_P (t))
+ SET_EXPR_LOCATION (t, loc);
+
+ print_generic_expr (stdout, t, 0);
+ printf ("\n");
+
}
skip_chunk:
- c_parser_require (parser, CPP_CLOSE_PAREN, "')' expected");
+ if (!c_parser_require (parser, CPP_CLOSE_PAREN, "')' expected"))
+ {
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
+ }
}
else
{
error:
c_parser_error (parser, "unknown schedule kind");
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
}
}
- c_parser_skip_until_found (parser, CPP_EOF, "EOF expected");
+ else
+ {
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
+ }
}
static void c_parser_pragma_omp_clause_shared (c_parser *);
@@ -5290,9 +5346,15 @@
if (c_parser_require (parser, CPP_OPEN_PAREN, "'(' expected"))
{
c_parser_pragma_omp_variable_list (parser);
- c_parser_require (parser, CPP_CLOSE_PAREN, "')' expected");
+ if (!c_parser_require (parser, CPP_CLOSE_PAREN, "')' expected"))
+ {
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
+ }
+ }
+ else
+ {
+ c_parser_skip_until_found (parser, CPP_EOF, 0);
}
- c_parser_skip_until_found (parser, CPP_EOF, 0);
}
static inline void c_parser_pragma_omp_atomic (c_parser *);