Commit 949505a9 by Marek Polacek Committed by Marek Polacek

re PR c/70671 (Wrong column number shown for "error: cannot take address of bit-field")

	PR c/70671
	* c-typeck.c (build_unary_op): Pass location down to error and
	warning call.

	* gcc.dg/bitfld-22.c: New test.

From-SVN: r235032
parent fab0ad92
2016-04-15 Marek Polacek <polacek@redhat.com>
PR c/70671
* c-typeck.c (build_unary_op): Pass location down to error and
warning call.
2016-04-15 Jakub Jelinek <jakub@redhat.com> 2016-04-15 Jakub Jelinek <jakub@redhat.com>
PR c/70436 PR c/70436
......
...@@ -4436,8 +4436,8 @@ build_unary_op (location_t location, ...@@ -4436,8 +4436,8 @@ build_unary_op (location_t location,
case COMPONENT_REF: case COMPONENT_REF:
if (DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1))) if (DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1)))
{ {
error ("cannot take address of bit-field %qD", error_at (location, "cannot take address of bit-field %qD",
TREE_OPERAND (arg, 1)); TREE_OPERAND (arg, 1));
return error_mark_node; return error_mark_node;
} }
...@@ -4449,15 +4449,16 @@ build_unary_op (location_t location, ...@@ -4449,15 +4449,16 @@ build_unary_op (location_t location,
if (!AGGREGATE_TYPE_P (TREE_TYPE (arg)) if (!AGGREGATE_TYPE_P (TREE_TYPE (arg))
&& !VECTOR_TYPE_P (TREE_TYPE (arg))) && !VECTOR_TYPE_P (TREE_TYPE (arg)))
{ {
error ("cannot take address of scalar with reverse storage " error_at (location, "cannot take address of scalar with "
"order"); "reverse storage order");
return error_mark_node; return error_mark_node;
} }
if (TREE_CODE (TREE_TYPE (arg)) == ARRAY_TYPE if (TREE_CODE (TREE_TYPE (arg)) == ARRAY_TYPE
&& TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (arg))) && TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (arg)))
warning (OPT_Wscalar_storage_order, "address of array with " warning_at (location, OPT_Wscalar_storage_order,
"reverse scalar storage order requested"); "address of array with reverse scalar storage "
"order requested");
} }
default: default:
......
2016-04-15 Marek Polacek <polacek@redhat.com>
PR c/70671
* gcc.dg/bitfld-22.c: New test.
2016-04-15 Bernd Schmidt <bschmidt@redhat.com> 2016-04-15 Bernd Schmidt <bschmidt@redhat.com>
* gcc.target/i386/pr46470.c: Add -mno-red-zone to dg-options for * gcc.target/i386/pr46470.c: Add -mno-red-zone to dg-options for
......
/* PR c/70671 */
/* { dg-do compile } */
extern void bar (int *);
struct S
{
int x:2;
} s, *r;
void
foo (void)
{
int *p1 = &s.x; /* { dg-error "13:cannot take address of bit-field 'x'" } */
int *p2;
p2 = &s.x; /* { dg-error "8:cannot take address of bit-field 'x'" } */
bar (&s.x); /* { dg-error "8:cannot take address of bit-field 'x'" } */
}
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