/* Parser for C and Objective-C.
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
Parser actions based on the old Bison parser; structure somewhat
influenced by and fragments based on the C++ parser.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
+Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
for more details.
You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING. If not, write to the Free
-Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA. */
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
/* TODO:
#include "cgraph.h"
\f
-/* Miscellaneous data and functions needed for the parser. */
-
-int yydebug;
-
-/* Objective-C specific parser/lexer information. */
-
-static int objc_pq_context = 0;
-
-/* The following flag is needed to contextualize Objective-C lexical
- analysis. In some cases (e.g., 'int NSObject;'), it is undesirable
- to bind an identifier to an Objective-C class, even if a class with
- that name exists. */
-static int objc_need_raw_identifier = 0;
-#define OBJC_NEED_RAW_IDENTIFIER(VAL) \
- do { \
- if (c_dialect_objc ()) \
- objc_need_raw_identifier = VAL; \
- } while (0)
-
/* The reserved keyword table. */
struct resword
{
{ "_Decimal32", RID_DFLOAT32, D_EXT },
{ "_Decimal64", RID_DFLOAT64, D_EXT },
{ "_Decimal128", RID_DFLOAT128, D_EXT },
+ { "_Fract", RID_FRACT, D_EXT },
+ { "_Accum", RID_ACCUM, D_EXT },
+ { "_Sat", RID_SAT, D_EXT },
{ "__FUNCTION__", RID_FUNCTION_NAME, 0 },
{ "__PRETTY_FUNCTION__", RID_PRETTY_FUNCTION_NAME, 0 },
{ "__alignof", RID_ALIGNOF, 0 },
};
#define N_reswords (sizeof reswords / sizeof (struct resword))
-/* All OpenMP clauses. OpenMP 2.5. */
-typedef enum pragma_omp_clause {
- PRAGMA_OMP_CLAUSE_NONE = 0,
-
- PRAGMA_OMP_CLAUSE_COPYIN,
- PRAGMA_OMP_CLAUSE_COPYPRIVATE,
- PRAGMA_OMP_CLAUSE_DEFAULT,
- PRAGMA_OMP_CLAUSE_FIRSTPRIVATE,
- PRAGMA_OMP_CLAUSE_IF,
- PRAGMA_OMP_CLAUSE_LASTPRIVATE,
- PRAGMA_OMP_CLAUSE_NOWAIT,
- PRAGMA_OMP_CLAUSE_NUM_THREADS,
- PRAGMA_OMP_CLAUSE_ORDERED,
- PRAGMA_OMP_CLAUSE_PRIVATE,
- PRAGMA_OMP_CLAUSE_REDUCTION,
- PRAGMA_OMP_CLAUSE_SCHEDULE,
- PRAGMA_OMP_CLAUSE_SHARED
-} pragma_omp_clause;
-
-
/* Initialization routine for this file. */
void
/* True if we're processing a pragma, and shouldn't automatically
consume CPP_PRAGMA_EOL. */
BOOL_BITFIELD in_pragma : 1;
+ /* True if we want to lex an untranslated string. */
+ BOOL_BITFIELD lex_untranslated_string : 1;
+ /* Objective-C specific parser/lexer information. */
+ BOOL_BITFIELD objc_pq_context : 1;
+ /* The following flag is needed to contextualize Objective-C lexical
+ analysis. In some cases (e.g., 'int NSObject;'), it is
+ undesirable to bind an identifier to an Objective-C class, even
+ if a class with that name exists. */
+ BOOL_BITFIELD objc_need_raw_identifier : 1;
} c_parser;
/* Read in and lex a single token, storing it in *TOKEN. */
static void
-c_lex_one_token (c_token *token)
+c_lex_one_token (c_parser *parser, c_token *token)
{
timevar_push (TV_LEX);
- token->type = c_lex_with_flags (&token->value, &token->location, NULL);
+ token->type = c_lex_with_flags (&token->value, &token->location, NULL,
+ (parser->lex_untranslated_string
+ ? C_LEX_STRING_NO_TRANSLATE : 0));
token->id_kind = C_ID_NONE;
token->keyword = RID_MAX;
token->pragma_kind = PRAGMA_NONE;
{
tree decl;
- int objc_force_identifier = objc_need_raw_identifier;
- OBJC_NEED_RAW_IDENTIFIER (0);
+ bool objc_force_identifier = parser->objc_need_raw_identifier;
+ if (c_dialect_objc ())
+ parser->objc_need_raw_identifier = false;
if (C_IS_RESERVED_WORD (token->value))
{
if (c_dialect_objc ())
{
if (!OBJC_IS_AT_KEYWORD (rid_code)
- && (!OBJC_IS_PQ_KEYWORD (rid_code) || objc_pq_context))
+ && (!OBJC_IS_PQ_KEYWORD (rid_code)
+ || parser->objc_pq_context))
{
/* Return the canonical spelling for this keyword. */
token->value = ridpointers[(int) rid_code];
case CPP_SEMICOLON:
/* These tokens may affect the interpretation of any identifiers
following, if doing Objective-C. */
- OBJC_NEED_RAW_IDENTIFIER (0);
+ if (c_dialect_objc ())
+ parser->objc_need_raw_identifier = false;
break;
case CPP_PRAGMA:
/* We smuggled the cpp_token->u.pragma value in an INTEGER_CST. */
{
if (parser->tokens_avail == 0)
{
- c_lex_one_token (&parser->tokens[0]);
+ c_lex_one_token (parser, &parser->tokens[0]);
parser->tokens_avail = 1;
}
return &parser->tokens[0];
case RID_VOLATILE:
case RID_RESTRICT:
case RID_ATTRIBUTE:
+ case RID_FRACT:
+ case RID_ACCUM:
+ case RID_SAT:
return true;
default:
return false;
case RID_VOLATILE:
case RID_RESTRICT:
case RID_ATTRIBUTE:
+ case RID_FRACT:
+ case RID_ACCUM:
+ case RID_SAT:
return true;
default:
return false;
gcc_assert (parser->tokens_avail == 1);
gcc_assert (parser->tokens[0].type != CPP_EOF);
gcc_assert (parser->tokens[0].type != CPP_PRAGMA_EOL);
- c_lex_one_token (&parser->tokens[1]);
+ c_lex_one_token (parser, &parser->tokens[1]);
parser->tokens_avail = 2;
return &parser->tokens[1];
}
c_parser_skip_to_pragma_eol (parser);
parser->error = save_error;
continue;
+
+ default:
+ break;
}
c_parser_consume_token (parser);
_Decimal32
_Decimal64
_Decimal128
+ _Fract
+ _Accum
+ _Sat
+
+ (_Fract, _Accum, and _Sat are new from ISO/IEC DTR 18037:
+ http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf)
Objective-C:
case RID_DFLOAT64:
case RID_DFLOAT128:
case RID_BOOL:
+ case RID_FRACT:
+ case RID_ACCUM:
+ case RID_SAT:
if (!typespec_ok)
goto out;
attrs_ok = true;
seen_type = true;
- OBJC_NEED_RAW_IDENTIFIER (1);
+ if (c_dialect_objc ())
+ parser->objc_need_raw_identifier = true;
t.kind = ctsk_resword;
t.spec = c_parser_peek_token (parser)->value;
declspecs_add_type (specs, t);
gcc_assert (c_parser_next_token_is_keyword (parser, RID_ENUM));
c_parser_consume_token (parser);
attrs = c_parser_attributes (parser);
+ /* Set the location in case we create a decl now. */
+ c_parser_set_source_position_from_token (c_parser_peek_token (parser));
if (c_parser_next_token_is (parser, CPP_NAME))
{
ident = c_parser_peek_token (parser)->value;
if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
{
/* Parse an enum definition. */
- tree type = start_enum (ident);
+ struct c_enum_contents the_enum;
+ tree type = start_enum (&the_enum, ident);
tree postfix_attrs;
/* We chain the enumerators in reverse order, then put them in
forward order at the end. */
tree enum_value;
tree enum_decl;
bool seen_comma;
+ c_token *token;
if (c_parser_next_token_is_not (parser, CPP_NAME))
{
c_parser_error (parser, "expected identifier");
values = error_mark_node;
break;
}
- enum_id = c_parser_peek_token (parser)->value;
+ token = c_parser_peek_token (parser);
+ enum_id = token->value;
+ /* Set the location in case we create a decl now. */
+ c_parser_set_source_position_from_token (token);
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_EQ))
{
}
else
enum_value = NULL_TREE;
- enum_decl = build_enumerator (enum_id, enum_value);
+ enum_decl = build_enumerator (&the_enum, enum_id, enum_value);
TREE_CHAIN (enum_decl) = values;
values = enum_decl;
seen_comma = false;
}
c_parser_consume_token (parser);
attrs = c_parser_attributes (parser);
+ /* Set the location in case we create a decl now. */
+ c_parser_set_source_position_from_token (c_parser_peek_token (parser));
if (c_parser_next_token_is (parser, CPP_NAME))
{
ident = c_parser_peek_token (parser)->value;
/* Support for unnamed structs or unions as members of
structs or unions (which is [a] useful and [b] supports
MS P-SDK). */
- ret = grokfield (build_id_declarator (NULL_TREE), specs, NULL_TREE);
+ tree attrs = NULL;
+ ret = grokfield (build_id_declarator (NULL_TREE), specs,
+ NULL_TREE, &attrs);
+ if (ret)
+ decl_attributes (&ret, attrs, 0);
}
return ret;
}
}
if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
postfix_attrs = c_parser_attributes (parser);
- d = grokfield (declarator, specs, width);
+ d = grokfield (declarator, specs, width, &all_prefix_attrs);
decl_attributes (&d, chainon (postfix_attrs,
all_prefix_attrs), 0);
TREE_CHAIN (d) = decls;
}
else
{
+ bool was_vm;
struct c_expr expr = c_parser_expression (parser);
skip_evaluation--;
in_typeof--;
&& DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
error ("%<typeof%> applied to a bit-field");
ret.spec = TREE_TYPE (expr.value);
- pop_maybe_used (variably_modified_type_p (ret.spec, NULL_TREE));
+ was_vm = variably_modified_type_p (ret.spec, NULL_TREE);
+ /* This should be returned with the type so that when the type
+ is evaluated, this can be evaluated. For now, we avoid
+ evaluation when the context might. */
+ if (!skip_evaluation && was_vm)
+ {
+ tree e = expr.value;
+
+ /* If the expression is not of a type to which we cannot assign a line
+ number, wrap the thing in a no-op NOP_EXPR. */
+ if (DECL_P (e) || CONSTANT_CLASS_P (e))
+ e = build1 (NOP_EXPR, void_type_node, e);
+
+ if (CAN_HAVE_LOCATION_P (e))
+ SET_EXPR_LOCATION (e, input_location);
+
+ add_stmt (e);
+ }
+ pop_maybe_used (was_vm);
}
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
return ret;
parameter-type-list[opt] )
direct-abstract-declarator:
- direct-abstract-declarator[opt] ( parameter-forward-declarations
+ direct-abstract-declarator[opt] ( parameter-forward-declarations
parameter-type-list[opt] )
parameter-forward-declarations:
}
declarator = build_array_declarator (dimen, quals_attrs, static_seen,
star_seen);
+ if (declarator == NULL)
+ return NULL;
inner = set_array_declarator_inner (declarator, inner, !id_present);
return c_parser_direct_declarator_inner (parser, id_present, inner);
}
ret->tags = 0;
ret->types = list;
ret->others = 0;
+ ret->pending_sizes = 0;
+ ret->had_vla_unspec = 0;
c_parser_consume_token (parser);
pop_scope ();
return ret;
ret->tags = 0;
ret->types = 0;
ret->others = 0;
+ ret->pending_sizes = 0;
+ ret->had_vla_unspec = 0;
c_parser_consume_token (parser);
return ret;
}
ret->parms = 0;
ret->tags = 0;
ret->others = 0;
+ ret->pending_sizes = 0;
+ ret->had_vla_unspec = 0;
/* Suppress -Wold-style-definition for this case. */
ret->types = error_mark_node;
error ("ISO C requires a named argument before %<...%>");
ret->tags = 0;
ret->types = 0;
ret->others = 0;
+ ret->pending_sizes = 0;
+ ret->had_vla_unspec = 0;
return ret;
}
}
ret->tags = 0;
ret->types = 0;
ret->others = 0;
+ ret->pending_sizes = 0;
+ ret->had_vla_unspec = 0;
return ret;
}
}
string-literal
??? At present, following the old parser, the caller needs to have
- set c_lex_string_translate to 0. It would be better to follow the
- C++ parser rather than using the c_lex_string_translate kludge. */
+ set lex_untranslated_string to 1. It would be better to follow the
+ C++ parser rather than using this kludge. */
static tree
c_parser_asm_string_literal (c_parser *parser)
tree str;
gcc_assert (c_parser_next_token_is_keyword (parser, RID_ASM));
/* ??? Follow the C++ parser rather than using the
- c_lex_string_translate kludge. */
- c_lex_string_translate = 0;
+ lex_untranslated_string kludge. */
+ parser->lex_untranslated_string = true;
c_parser_consume_token (parser);
if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
{
- c_lex_string_translate = 1;
+ parser->lex_untranslated_string = false;
return NULL_TREE;
}
str = c_parser_asm_string_literal (parser);
- c_lex_string_translate = 1;
+ parser->lex_untranslated_string = false;
if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
{
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
while (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
{
/* ??? Follow the C++ parser rather than using the
- c_lex_string_translate kludge. */
- c_lex_string_translate = 0;
+ lex_untranslated_string kludge. */
+ parser->lex_untranslated_string = true;
c_parser_consume_token (parser);
if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
{
- c_lex_string_translate = 1;
+ parser->lex_untranslated_string = false;
return attrs;
}
if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
{
- c_lex_string_translate = 1;
+ parser->lex_untranslated_string = false;
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
return attrs;
}
case RID_DFLOAT64:
case RID_DFLOAT128:
case RID_BOOL:
+ case RID_FRACT:
+ case RID_ACCUM:
+ case RID_SAT:
ok = true;
break;
default:
c_parser_consume_token (parser);
else
{
- c_lex_string_translate = 1;
+ parser->lex_untranslated_string = false;
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
"expected %<)%>");
return attrs;
c_parser_consume_token (parser);
else
{
- c_lex_string_translate = 1;
+ parser->lex_untranslated_string = false;
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
"expected %<)%>");
return attrs;
c_parser_consume_token (parser);
else
{
- c_lex_string_translate = 1;
+ parser->lex_untranslated_string = false;
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
"expected %<)%>");
return attrs;
}
- c_lex_string_translate = 1;
+ parser->lex_untranslated_string = false;
}
return attrs;
}
last_stmt = true;
c_parser_statement_after_labels (parser);
}
+
+ parser->error = false;
}
if (last_label)
error ("label at end of compound statement");
(recursively) all of the component statements should already have
line numbers assigned. ??? Can we discard no-op statements
earlier? */
- if (stmt && EXPR_P (stmt))
+ if (stmt && CAN_HAVE_LOCATION_P (stmt))
SET_EXPR_LOCATION (stmt, loc);
}
loc = c_parser_peek_token (parser)->location;
cond = c_objc_common_truthvalue_conversion
(c_parser_expression_conv (parser).value);
- if (EXPR_P (cond))
+ if (CAN_HAVE_LOCATION_P (cond))
SET_EXPR_LOCATION (cond, loc);
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
return cond;
is just parsing a statement but (a) it is a block in C99, (b) we
track whether the body is an if statement for the sake of
-Wparentheses warnings, (c) we handle an empty body specially for
- the sake of -Wextra warnings. */
+ the sake of -Wempty-body warnings. */
static tree
c_parser_if_body (c_parser *parser, bool *if_p)
&& c_parser_peek_2nd_token (parser)->type == CPP_COLON))
c_parser_label (parser);
*if_p = c_parser_next_token_is_keyword (parser, RID_IF);
- if (extra_warnings && c_parser_next_token_is (parser, CPP_SEMICOLON))
+ if (c_parser_next_token_is (parser, CPP_SEMICOLON))
add_stmt (build_empty_stmt ());
c_parser_statement_after_labels (parser);
return c_end_compound_stmt (block, flag_isoc99);
location_t loc;
gcc_assert (c_parser_next_token_is_keyword (parser, RID_DO));
c_parser_consume_token (parser);
+ if (c_parser_next_token_is (parser, CPP_SEMICOLON))
+ warning (OPT_Wempty_body,
+ "suggest braces around empty body in %<do%> statement");
block = c_begin_compound_stmt (flag_isoc99);
loc = c_parser_peek_token (parser)->location;
save_break = c_break_label;
{
tree ocond = c_parser_expression_conv (parser).value;
cond = c_objc_common_truthvalue_conversion (ocond);
- if (EXPR_P (cond))
+ if (CAN_HAVE_LOCATION_P (cond))
SET_EXPR_LOCATION (cond, loc);
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
}
else
quals = NULL_TREE;
/* ??? Follow the C++ parser rather than using the
- c_lex_string_translate kludge. */
- c_lex_string_translate = 0;
+ lex_untranslated_string kludge. */
+ parser->lex_untranslated_string = true;
if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
{
- c_lex_string_translate = 1;
+ parser->lex_untranslated_string = false;
return NULL_TREE;
}
str = c_parser_asm_string_literal (parser);
}
if (!c_parser_require (parser, CPP_COLON, "expected %<:%> or %<)%>"))
{
- c_lex_string_translate = 1;
+ parser->lex_untranslated_string = false;
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
return NULL_TREE;
}
}
if (!c_parser_require (parser, CPP_COLON, "expected %<:%> or %<)%>"))
{
- c_lex_string_translate = 1;
+ parser->lex_untranslated_string = false;
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
return NULL_TREE;
}
}
if (!c_parser_require (parser, CPP_COLON, "expected %<:%> or %<)%>"))
{
- c_lex_string_translate = 1;
+ parser->lex_untranslated_string = false;
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
return NULL_TREE;
}
/* Parse clobbers. */
clobbers = c_parser_asm_clobbers (parser);
done_asm:
- c_lex_string_translate = 1;
+ parser->lex_untranslated_string = false;
if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
{
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
str = c_parser_asm_string_literal (parser);
if (str == NULL_TREE)
return NULL_TREE;
- c_lex_string_translate = 1;
+ parser->lex_untranslated_string = false;
if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
{
- c_lex_string_translate = 0;
+ parser->lex_untranslated_string = true;
return NULL_TREE;
}
expr = c_parser_expression (parser);
if (convert_p)
expr = default_function_array_conversion (expr);
- c_lex_string_translate = 0;
+ parser->lex_untranslated_string = true;
if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
{
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
}
/* Save casted types in the function's used types hash table. */
- if (debug_info_level > DINFO_LEVEL_NONE)
- used_types_insert (type_name->specs->type, cfun);
+ used_types_insert (type_name->specs->type);
if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
return c_parser_postfix_expression_after_paren_type (parser,
/* sizeof ( type-name ). */
skip_evaluation--;
in_sizeof--;
+ if (type_name->declarator->kind == cdk_array
+ && type_name->declarator->u.array.vla_unspec_p)
+ {
+ /* C99 6.7.5.2p4 */
+ error ("%<[*]%> not allowed in other than a declaration");
+ }
return c_expr_sizeof_type (type_name);
}
else
if (type == error_mark_node)
offsetof_ref = error_mark_node;
else
- offsetof_ref = build1 (INDIRECT_REF, type, NULL);
+ offsetof_ref = build1 (INDIRECT_REF, type, null_pointer_node);
/* Parse the second argument to __builtin_offsetof. We
must have one identifier, and beyond that we want to
accept sub structure and sub array references. */
c_parser_error (parser, "expected identifier");
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
"expected %<)%>");
- expr.value = fold_offsetof (offsetof_ref);
+ expr.value = fold_offsetof (offsetof_ref, NULL_TREE);
expr.original_code = ERROR_MARK;
}
break;
struct c_expr expr;
start_init (NULL_TREE, NULL, 0);
type = groktypename (type_name);
- if (C_TYPE_VARIABLE_SIZE (type))
+ if (type != error_mark_node && C_TYPE_VARIABLE_SIZE (type))
{
error ("compound literal has variable size");
type = error_mark_node;
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_LESS))
proto = c_parser_objc_protocol_refs (parser);
- objc_pq_context = 1;
+ parser->objc_pq_context = true;
objc_start_protocol (id, proto);
c_parser_objc_methodprotolist (parser);
c_parser_require_keyword (parser, RID_AT_END, "expected %<@end%>");
- objc_pq_context = 0;
+ parser->objc_pq_context = false;
objc_finish_interface ();
}
}
enum tree_code type = c_parser_objc_method_type (parser);
tree decl;
objc_set_method_type (type);
- objc_pq_context = 1;
+ parser->objc_pq_context = true;
decl = c_parser_objc_method_decl (parser);
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
c_parser_error (parser, "expected %<{%>");
return;
}
- objc_pq_context = 0;
+ parser->objc_pq_context = false;
objc_start_method_definition (decl);
add_stmt (c_parser_compound_statement (parser));
objc_finish_method_definition (current_function_decl);
tree decl;
objc_set_method_type (type);
/* Remember protocol qualifiers in prototypes. */
- objc_pq_context = 1;
+ parser->objc_pq_context = true;
decl = c_parser_objc_method_decl (parser);
/* Forget protocol qualifiers here. */
- objc_pq_context = 0;
+ parser->objc_pq_context = false;
objc_add_method_declaration (decl);
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
}
c_parser_omp_atomic (c_parser *parser)
{
tree lhs, rhs;
+ tree stmt;
enum tree_code code;
c_parser_skip_to_pragma_eol (parser);
rhs = c_parser_expression (parser).value;
break;
}
- c_finish_omp_atomic (code, lhs, rhs);
+ stmt = c_finish_omp_atomic (code, lhs, rhs);
+ if (stmt != error_mark_node)
+ add_stmt (stmt);
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
}
{
cond = c_parser_expression_conv (parser).value;
cond = c_objc_common_truthvalue_conversion (cond);
- if (EXPR_P (cond))
+ if (CAN_HAVE_LOCATION_P (cond))
SET_EXPR_LOCATION (cond, input_location);
}
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
if (stmt)
OMP_FOR_CLAUSES (stmt) = ws_clause;
stmt = c_finish_omp_parallel (par_clause, block);
+ OMP_PARALLEL_COMBINED (stmt) = 1;
break;
case PRAGMA_OMP_PARALLEL_SECTIONS:
if (stmt)
OMP_SECTIONS_CLAUSES (stmt) = ws_clause;
stmt = c_finish_omp_parallel (par_clause, block);
+ OMP_PARALLEL_COMBINED (stmt) = 1;
break;
default:
p_kind = c_parser_peek_token (parser)->pragma_kind;
c_parser_consume_pragma (parser);
+ /* For all constructs below except #pragma omp atomic
+ MUST_NOT_THROW catch handlers are needed when exceptions
+ are enabled. */
+ if (p_kind != PRAGMA_OMP_ATOMIC)
+ c_maybe_initialize_eh ();
+
switch (p_kind)
{
case PRAGMA_OMP_ATOMIC:
c_parser_consume_pragma (parser);
vars = c_parser_omp_var_list_parens (parser, 0, NULL);
- if (!targetm.have_tls)
- sorry ("threadprivate variables not supported in this target");
-
/* Mark every variable in VARS to be assigned thread local storage. */
for (t = vars; t; t = TREE_CHAIN (t))
{