Commit 7bd11157 by Tom Tromey Committed by Tom Tromey

c-parser.c (c_parser_omp_atomic): Pass location of assignment operator to c_finish_omp_atomic.

gcc
	* c-parser.c (c_parser_omp_atomic): Pass location of assignment
	operator to c_finish_omp_atomic.
	* c-typeck.c (lvalue_or_else): Add 'loc' argument.
	(build_unary_op): Update.
	(build_modify_expr): Update.
	(build_asm_expr): Update.
gcc/cp
	* typeck.c (cp_build_addr_expr_1): Update call to lvalue_error.
	(lvalue_or_else): Likewise.
gcc/c-family
	* c-common.h (lvalue_error): Update.
	* c-common.c (lvalue_error): Add 'loc' argument.  Call error_at,
	not error.

From-SVN: r168514
parent cd656e23
2011-01-05 Tom Tromey <tromey@redhat.com>
* c-parser.c (c_parser_omp_atomic): Pass location of assignment
operator to c_finish_omp_atomic.
* c-typeck.c (lvalue_or_else): Add 'loc' argument.
(build_unary_op): Update.
(build_modify_expr): Update.
(build_asm_expr): Update.
2011-01-05 Ulrich Weigand <Ulrich.Weigand@de.ibm.com> 2011-01-05 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
* config/spu/spu.c (emit_nop_for_insn): Set INSN_LOCATOR for * config/spu/spu.c (emit_nop_for_insn): Set INSN_LOCATOR for
......
2011-01-05 Tom Tromey <tromey@redhat.com>
* c-common.h (lvalue_error): Update.
* c-common.c (lvalue_error): Add 'loc' argument. Call error_at,
not error.
2010-12-29 Nicola Pero <nicola@nicola.brainstorm.co.uk> 2010-12-29 Nicola Pero <nicola@nicola.brainstorm.co.uk>
PR objc/47075 PR objc/47075
......
/* Subroutines shared by all languages that are variants of C. /* Subroutines shared by all languages that are variants of C.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -8631,27 +8631,28 @@ readonly_error (tree arg, enum lvalue_use use) ...@@ -8631,27 +8631,28 @@ readonly_error (tree arg, enum lvalue_use use)
} }
/* Print an error message for an invalid lvalue. USE says /* Print an error message for an invalid lvalue. USE says
how the lvalue is being used and so selects the error message. */ how the lvalue is being used and so selects the error message. LOC
is the location for the error. */
void void
lvalue_error (enum lvalue_use use) lvalue_error (location_t loc, enum lvalue_use use)
{ {
switch (use) switch (use)
{ {
case lv_assign: case lv_assign:
error ("lvalue required as left operand of assignment"); error_at (loc, "lvalue required as left operand of assignment");
break; break;
case lv_increment: case lv_increment:
error ("lvalue required as increment operand"); error_at (loc, "lvalue required as increment operand");
break; break;
case lv_decrement: case lv_decrement:
error ("lvalue required as decrement operand"); error_at (loc, "lvalue required as decrement operand");
break; break;
case lv_addressof: case lv_addressof:
error ("lvalue required as unary %<&%> operand"); error_at (loc, "lvalue required as unary %<&%> operand");
break; break;
case lv_asm: case lv_asm:
error ("lvalue required in asm statement"); error_at (loc, "lvalue required in asm statement");
break; break;
default: default:
gcc_unreachable (); gcc_unreachable ();
......
/* Definitions for c-common.c. /* Definitions for c-common.c.
Copyright (C) 1987, 1993, 1994, 1995, 1997, 1998, Copyright (C) 1987, 1993, 1994, 1995, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -929,7 +929,7 @@ enum lvalue_use { ...@@ -929,7 +929,7 @@ enum lvalue_use {
}; };
extern void readonly_error (tree, enum lvalue_use); extern void readonly_error (tree, enum lvalue_use);
extern void lvalue_error (enum lvalue_use); extern void lvalue_error (location_t, enum lvalue_use);
extern void invalid_indirection_error (location_t, tree, ref_operator); extern void invalid_indirection_error (location_t, tree, ref_operator);
extern int complete_array_type (tree *, tree, bool); extern int complete_array_type (tree *, tree, bool);
......
/* Parser for C and Objective-C. /* Parser for C and Objective-C.
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc. Free Software Foundation, Inc.
Parser actions based on the old Bison parser; structure somewhat Parser actions based on the old Bison parser; structure somewhat
...@@ -9104,6 +9104,9 @@ c_parser_omp_atomic (location_t loc, c_parser *parser) ...@@ -9104,6 +9104,9 @@ c_parser_omp_atomic (location_t loc, c_parser *parser)
goto saw_error; goto saw_error;
} }
/* Arrange to pass the location of the assignment operator to
c_finish_omp_atomic. */
loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser); c_parser_consume_token (parser);
{ {
location_t rhs_loc = c_parser_peek_token (parser)->location; location_t rhs_loc = c_parser_peek_token (parser)->location;
......
/* Build expressions with type checking for C compiler. /* Build expressions with type checking for C compiler.
Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -98,7 +98,7 @@ static void set_nonincremental_init (struct obstack *); ...@@ -98,7 +98,7 @@ static void set_nonincremental_init (struct obstack *);
static void set_nonincremental_init_from_string (tree, struct obstack *); static void set_nonincremental_init_from_string (tree, struct obstack *);
static tree find_init_member (tree, struct obstack *); static tree find_init_member (tree, struct obstack *);
static void readonly_warning (tree, enum lvalue_use); static void readonly_warning (tree, enum lvalue_use);
static int lvalue_or_else (const_tree, enum lvalue_use); static int lvalue_or_else (location_t, const_tree, enum lvalue_use);
static void record_maybe_used_decl (tree); static void record_maybe_used_decl (tree);
static int comptypes_internal (const_tree, const_tree, bool *, bool *); static int comptypes_internal (const_tree, const_tree, bool *, bool *);
...@@ -3564,7 +3564,8 @@ build_unary_op (location_t location, ...@@ -3564,7 +3564,8 @@ build_unary_op (location_t location,
/* Complain about anything that is not a true lvalue. In /* Complain about anything that is not a true lvalue. In
Objective-C, skip this check for property_refs. */ Objective-C, skip this check for property_refs. */
if (!objc_is_property_ref (arg) if (!objc_is_property_ref (arg)
&& !lvalue_or_else (arg, ((code == PREINCREMENT_EXPR && !lvalue_or_else (location,
arg, ((code == PREINCREMENT_EXPR
|| code == POSTINCREMENT_EXPR) || code == POSTINCREMENT_EXPR)
? lv_increment ? lv_increment
: lv_decrement))) : lv_decrement)))
...@@ -3747,7 +3748,7 @@ build_unary_op (location_t location, ...@@ -3747,7 +3748,7 @@ build_unary_op (location_t location,
/* Anything not already handled and not a true memory reference /* Anything not already handled and not a true memory reference
or a non-lvalue array is an error. */ or a non-lvalue array is an error. */
else if (typecode != FUNCTION_TYPE && !flag else if (typecode != FUNCTION_TYPE && !flag
&& !lvalue_or_else (arg, lv_addressof)) && !lvalue_or_else (location, arg, lv_addressof))
return error_mark_node; return error_mark_node;
/* Move address operations inside C_MAYBE_CONST_EXPR to simplify /* Move address operations inside C_MAYBE_CONST_EXPR to simplify
...@@ -3905,15 +3906,16 @@ readonly_warning (tree arg, enum lvalue_use use) ...@@ -3905,15 +3906,16 @@ readonly_warning (tree arg, enum lvalue_use use)
/* Return nonzero if REF is an lvalue valid for this language; /* Return nonzero if REF is an lvalue valid for this language;
otherwise, print an error message and return zero. USE says otherwise, print an error message and return zero. USE says
how the lvalue is being used and so selects the error message. */ how the lvalue is being used and so selects the error message.
LOCATION is the location at which any error should be reported. */
static int static int
lvalue_or_else (const_tree ref, enum lvalue_use use) lvalue_or_else (location_t loc, const_tree ref, enum lvalue_use use)
{ {
int win = lvalue_p (ref); int win = lvalue_p (ref);
if (!win) if (!win)
lvalue_error (use); lvalue_error (loc, use);
return win; return win;
} }
...@@ -4801,7 +4803,7 @@ build_modify_expr (location_t location, tree lhs, tree lhs_origtype, ...@@ -4801,7 +4803,7 @@ build_modify_expr (location_t location, tree lhs, tree lhs_origtype,
return error_mark_node; return error_mark_node;
/* For ObjC properties, defer this check. */ /* For ObjC properties, defer this check. */
if (!objc_is_property_ref (lhs) && !lvalue_or_else (lhs, lv_assign)) if (!objc_is_property_ref (lhs) && !lvalue_or_else (location, lhs, lv_assign))
return error_mark_node; return error_mark_node;
if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR) if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
...@@ -4851,7 +4853,7 @@ build_modify_expr (location_t location, tree lhs, tree lhs_origtype, ...@@ -4851,7 +4853,7 @@ build_modify_expr (location_t location, tree lhs, tree lhs_origtype,
return result; return result;
/* Else, do the check that we postponed for Objective-C. */ /* Else, do the check that we postponed for Objective-C. */
if (!lvalue_or_else (lhs, lv_assign)) if (!lvalue_or_else (location, lhs, lv_assign))
return error_mark_node; return error_mark_node;
} }
...@@ -8479,7 +8481,7 @@ build_asm_expr (location_t loc, tree string, tree outputs, tree inputs, ...@@ -8479,7 +8481,7 @@ build_asm_expr (location_t loc, tree string, tree outputs, tree inputs,
get an error. Gross, but ... */ get an error. Gross, but ... */
STRIP_NOPS (output); STRIP_NOPS (output);
if (!lvalue_or_else (output, lv_asm)) if (!lvalue_or_else (loc, output, lv_asm))
output = error_mark_node; output = error_mark_node;
if (output != error_mark_node if (output != error_mark_node
......
2011-01-05 Tom Tromey <tromey@redhat.com>
* typeck.c (cp_build_addr_expr_1): Update call to lvalue_error.
(lvalue_or_else): Likewise.
2011-01-01 Kai Tietz <kai.tietz@onevision.com> 2011-01-01 Kai Tietz <kai.tietz@onevision.com>
PR target/38662 PR target/38662
......
/* Build expressions with type checking for C++ compiler. /* Build expressions with type checking for C++ compiler.
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc. Free Software Foundation, Inc.
Hacked by Michael Tiemann (tiemann@cygnus.com) Hacked by Michael Tiemann (tiemann@cygnus.com)
...@@ -4756,7 +4756,7 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain) ...@@ -4756,7 +4756,7 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain)
if (kind == clk_none) if (kind == clk_none)
{ {
if (complain & tf_error) if (complain & tf_error)
lvalue_error (lv_addressof); lvalue_error (input_location, lv_addressof);
return error_mark_node; return error_mark_node;
} }
if (strict_lvalue && (kind & (clk_rvalueref|clk_class))) if (strict_lvalue && (kind & (clk_rvalueref|clk_class)))
...@@ -8219,7 +8219,7 @@ lvalue_or_else (tree ref, enum lvalue_use use, tsubst_flags_t complain) ...@@ -8219,7 +8219,7 @@ lvalue_or_else (tree ref, enum lvalue_use use, tsubst_flags_t complain)
if (kind == clk_none) if (kind == clk_none)
{ {
if (complain & tf_error) if (complain & tf_error)
lvalue_error (use); lvalue_error (input_location, use);
return 0; return 0;
} }
else if (kind & (clk_rvalueref|clk_class)) else if (kind & (clk_rvalueref|clk_class))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment