+Mon Feb 8 11:50:50 1999 Alexandre Petit-Bianco <apbianco@cygnus.com>
+
+ * parse.h: DECL_P renamed JDECL_P.
+ * parse.y: DECL_P replaced by JDECL_P.
+ (build_array_from_name): Always use pointer's type.
+ (patch_bc_statement): Extra code to search continue target in a
+ for loop. Fixed comments. Continue target is current loop when
+ unlabeled.
+
1999-02-05 Andrew Haley <aph@cygnus.com>
* class.c (make_class_data): The superclass of an interface should
{
name = get_identifier (&more_dims [string]);
- /* If type already is a reference on an array, get the base type */
- if ((TREE_CODE (type) == POINTER_TYPE) &&
- TYPE_ARRAY_P (TREE_TYPE (type)))
- type = TREE_TYPE (type);
+ /* If we have a pointer, use its type */
+ if (TREE_CODE (type) == POINTER_TYPE)
+ type = TREE_TYPE (type);
/* Building the first dimension of a primitive type uses this
function */
}
/* We might have been trying to resolve field.method(). In which
case, the resolution is over and decl is the answer */
- else if (DECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
+ else if (JDECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
field_ref = decl;
- else if (DECL_P (decl))
+ else if (JDECL_P (decl))
{
int static_final_found = 0;
if (!type_found)
type_found = DECL_CONTEXT (decl);
- is_static = DECL_P (decl) && FIELD_STATIC (decl);
+ is_static = JDECL_P (decl) && FIELD_STATIC (decl);
if (FIELD_FINAL (decl)
&& JPRIMITIVE_TYPE_P (TREE_TYPE (decl))
&& DECL_LANG_SPECIFIC (decl)
case NEW_CLASS_EXPR:
/* If the access to the function call is a non static field,
build the code to access it. */
- if (DECL_P (decl) && !FIELD_STATIC (decl))
+ if (JDECL_P (decl) && !FIELD_STATIC (decl))
{
decl = maybe_access_field (decl, *where_found,
DECL_CONTEXT (decl));
case ARRAY_REF:
/* If the access to the function call is a non static field,
build the code to access it. */
- if (DECL_P (decl) && !FIELD_STATIC (decl))
+ if (JDECL_P (decl) && !FIELD_STATIC (decl))
{
decl = maybe_access_field (decl, *where_found, type);
if (decl == error_mark_node)
patch_assignment (node, wfl_op1, wfl_op2);
/* Now, we still mark the lhs as initialized */
- if (DECL_P (TREE_OPERAND (node, 0)))
+ if (JDECL_P (TREE_OPERAND (node, 0)))
INITIALIZED_P (TREE_OPERAND (node, 0)) = 1;
return error_mark_node;
check_final_assignment (lvalue, wfl)
tree lvalue, wfl;
{
- if (DECL_P (lvalue) && FIELD_FINAL (lvalue) &&
+ if (JDECL_P (lvalue) && FIELD_FINAL (lvalue) &&
DECL_NAME (current_function_decl) != clinit_identifier_node)
{
parse_error_context
EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
/* Lhs can be a named variable */
- if (DECL_P (lvalue))
+ if (JDECL_P (lvalue))
{
INITIALIZED_P (lvalue) = 1;
lhs_type = TREE_TYPE (lvalue);
case PREINCREMENT_EXPR:
/* 15.14.2 Prefix Decrement Operator -- */
case PREDECREMENT_EXPR:
- if (!DECL_P (op) && !((TREE_CODE (op) == INDIRECT_REF
- || TREE_CODE (op) == COMPONENT_REF)
- && JPRIMITIVE_TYPE_P (TREE_TYPE (op))))
+ if (!JDECL_P (op) && !((TREE_CODE (op) == INDIRECT_REF
+ || TREE_CODE (op) == COMPONENT_REF)
+ && JPRIMITIVE_TYPE_P (TREE_TYPE (op))))
{
tree lvalue;
/* Before screaming, check that we're not in fact trying to
COMPOUND_EXPR (loop main body)
EXIT_EXPR (this order is for while/for loops.
LABELED_BLOCK_EXPR the order is reversed for do loops)
- LABEL_DECL (continue occurding here branche at the
+ LABEL_DECL (a continue occuring here branches at the
BODY end of this labeled block)
INCREMENT (if any)
/* Find the statement we're targeting. */
target_stmt = LABELED_BLOCK_BODY (bc_label);
+ /* Target loop is slightly burrowed in the case of a for loop, it
+ appears at the first sight to be a block. */
+ if (TREE_CODE (target_stmt) == BLOCK)
+ {
+ tree sub = BLOCK_SUBBLOCKS (target_stmt);
+ if (sub && TREE_CODE (sub) == COMPOUND_EXPR && TREE_OPERAND (sub, 1)
+ && TREE_CODE (TREE_OPERAND (sub, 1)) == LOOP_EXPR)
+ target_stmt = TREE_OPERAND (sub, 1);
+ }
+
/* 14.13 The break Statement */
if (IS_BREAK_STMT_P (node))
{
while/do/for/switch */
if (is_unlabeled &&
!(TREE_CODE (target_stmt) == LOOP_EXPR /* do/while/for */
- || TREE_CODE (target_stmt) == SWITCH_EXPR)) /* switch FIXME */
+ || TREE_CODE (target_stmt) == SWITCH_EXPR)) /* switch */
{
parse_error_context (wfl_operator,
"`break' must be in loop or switch");
EXIT_BLOCK_LABELED_BLOCK (node) = bc_label;
}
/* 14.14 The continue Statement */
- /* The continue statement must always target a loop */
+ /* The continue statement must always target a loop, unnamed or not. */
else
- {
+ {
if (TREE_CODE (target_stmt) != LOOP_EXPR) /* do/while/for */
{
parse_error_context (wfl_operator, "`continue' must be in loop");
return error_mark_node;
}
/* Everything looks good. We can fix the `continue' jump to go
- at the place in the loop were the continue is. The continue
- is the current labeled block, by construction. */
- EXIT_BLOCK_LABELED_BLOCK (node) = bc_label = ctxp->current_labeled_block;
+ at the place in the loop were the continue is. For unlabeled
+ continue, the continuation point is the current labeled
+ block, by construction. */
+ if (is_unlabeled)
+ EXIT_BLOCK_LABELED_BLOCK (node) =
+ bc_label = ctxp->current_labeled_block;
}
CAN_COMPLETE_NORMALLY (bc_label) = 1;
&& (TYPE) == TREE_TYPE (null_pointer_node))
/* Other predicate */
-#define DECL_P(NODE) (NODE && (TREE_CODE (NODE) == PARM_DECL \
- || TREE_CODE (NODE) == VAR_DECL \
- || TREE_CODE (NODE) == FIELD_DECL))
+#define JDECL_P(NODE) (NODE && (TREE_CODE (NODE) == PARM_DECL \
+ || TREE_CODE (NODE) == VAR_DECL \
+ || TREE_CODE (NODE) == FIELD_DECL))
#define TYPE_INTERFACE_P(TYPE) \
(CLASS_P (TYPE) && CLASS_INTERFACE (TYPE_NAME (TYPE)))
{
name = get_identifier (&more_dims [string]);
- /* If type already is a reference on an array, get the base type */
- if ((TREE_CODE (type) == POINTER_TYPE) &&
- TYPE_ARRAY_P (TREE_TYPE (type)))
- type = TREE_TYPE (type);
+ /* If we have a pointer, use its type */
+ if (TREE_CODE (type) == POINTER_TYPE)
+ type = TREE_TYPE (type);
/* Building the first dimension of a primitive type uses this
function */
}
/* We might have been trying to resolve field.method(). In which
case, the resolution is over and decl is the answer */
- else if (DECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
+ else if (JDECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
field_ref = decl;
- else if (DECL_P (decl))
+ else if (JDECL_P (decl))
{
int static_final_found = 0;
if (!type_found)
type_found = DECL_CONTEXT (decl);
- is_static = DECL_P (decl) && FIELD_STATIC (decl);
+ is_static = JDECL_P (decl) && FIELD_STATIC (decl);
if (FIELD_FINAL (decl)
&& JPRIMITIVE_TYPE_P (TREE_TYPE (decl))
&& DECL_LANG_SPECIFIC (decl)
case NEW_CLASS_EXPR:
/* If the access to the function call is a non static field,
build the code to access it. */
- if (DECL_P (decl) && !FIELD_STATIC (decl))
+ if (JDECL_P (decl) && !FIELD_STATIC (decl))
{
decl = maybe_access_field (decl, *where_found,
DECL_CONTEXT (decl));
case ARRAY_REF:
/* If the access to the function call is a non static field,
build the code to access it. */
- if (DECL_P (decl) && !FIELD_STATIC (decl))
+ if (JDECL_P (decl) && !FIELD_STATIC (decl))
{
decl = maybe_access_field (decl, *where_found, type);
if (decl == error_mark_node)
patch_assignment (node, wfl_op1, wfl_op2);
/* Now, we still mark the lhs as initialized */
- if (DECL_P (TREE_OPERAND (node, 0)))
+ if (JDECL_P (TREE_OPERAND (node, 0)))
INITIALIZED_P (TREE_OPERAND (node, 0)) = 1;
return error_mark_node;
check_final_assignment (lvalue, wfl)
tree lvalue, wfl;
{
- if (DECL_P (lvalue) && FIELD_FINAL (lvalue) &&
+ if (JDECL_P (lvalue) && FIELD_FINAL (lvalue) &&
DECL_NAME (current_function_decl) != clinit_identifier_node)
{
parse_error_context
EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
/* Lhs can be a named variable */
- if (DECL_P (lvalue))
+ if (JDECL_P (lvalue))
{
INITIALIZED_P (lvalue) = 1;
lhs_type = TREE_TYPE (lvalue);
case PREINCREMENT_EXPR:
/* 15.14.2 Prefix Decrement Operator -- */
case PREDECREMENT_EXPR:
- if (!DECL_P (op) && !((TREE_CODE (op) == INDIRECT_REF
- || TREE_CODE (op) == COMPONENT_REF)
- && JPRIMITIVE_TYPE_P (TREE_TYPE (op))))
+ if (!JDECL_P (op) && !((TREE_CODE (op) == INDIRECT_REF
+ || TREE_CODE (op) == COMPONENT_REF)
+ && JPRIMITIVE_TYPE_P (TREE_TYPE (op))))
{
tree lvalue;
/* Before screaming, check that we're not in fact trying to
COMPOUND_EXPR (loop main body)
EXIT_EXPR (this order is for while/for loops.
LABELED_BLOCK_EXPR the order is reversed for do loops)
- LABEL_DECL (continue occurding here branche at the
+ LABEL_DECL (a continue occuring here branches at the
BODY end of this labeled block)
INCREMENT (if any)
/* Find the statement we're targeting. */
target_stmt = LABELED_BLOCK_BODY (bc_label);
+ /* Target loop is slightly burrowed in the case of a for loop, it
+ appears at the first sight to be a block. */
+ if (TREE_CODE (target_stmt) == BLOCK)
+ {
+ tree sub = BLOCK_SUBBLOCKS (target_stmt);
+ if (sub && TREE_CODE (sub) == COMPOUND_EXPR && TREE_OPERAND (sub, 1)
+ && TREE_CODE (TREE_OPERAND (sub, 1)) == LOOP_EXPR)
+ target_stmt = TREE_OPERAND (sub, 1);
+ }
+
/* 14.13 The break Statement */
if (IS_BREAK_STMT_P (node))
{
while/do/for/switch */
if (is_unlabeled &&
!(TREE_CODE (target_stmt) == LOOP_EXPR /* do/while/for */
- || TREE_CODE (target_stmt) == SWITCH_EXPR)) /* switch FIXME */
+ || TREE_CODE (target_stmt) == SWITCH_EXPR)) /* switch */
{
parse_error_context (wfl_operator,
"`break' must be in loop or switch");
EXIT_BLOCK_LABELED_BLOCK (node) = bc_label;
}
/* 14.14 The continue Statement */
- /* The continue statement must always target a loop */
+ /* The continue statement must always target a loop, unnamed or not. */
else
- {
+ {
if (TREE_CODE (target_stmt) != LOOP_EXPR) /* do/while/for */
{
parse_error_context (wfl_operator, "`continue' must be in loop");
return error_mark_node;
}
/* Everything looks good. We can fix the `continue' jump to go
- at the place in the loop were the continue is. The continue
- is the current labeled block, by construction. */
- EXIT_BLOCK_LABELED_BLOCK (node) = bc_label = ctxp->current_labeled_block;
+ at the place in the loop were the continue is. For unlabeled
+ continue, the continuation point is the current labeled
+ block, by construction. */
+ if (is_unlabeled)
+ EXIT_BLOCK_LABELED_BLOCK (node) =
+ bc_label = ctxp->current_labeled_block;
}
CAN_COMPLETE_NORMALLY (bc_label) = 1;