diff options
author | Marek Polacek <polacek@redhat.com> | 2016-04-15 14:46:06 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2016-04-15 14:46:06 +0000 |
commit | 949505a900b4363539138c34aa8428723880a773 (patch) | |
tree | 4f15149dd5627d3e757afed4ee07978cb4680f99 /gcc | |
parent | fab0ad9253075c67250f311462f5da6a2e2048f9 (diff) | |
download | gcc-949505a900b4363539138c34aa8428723880a773.zip gcc-949505a900b4363539138c34aa8428723880a773.tar.gz gcc-949505a900b4363539138c34aa8428723880a773.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/bitfld-22.c | 18 |
4 files changed, 36 insertions, 6 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 3ba3f4e..7257f79 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +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> PR c/70436 diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 9a14994..59a3c61 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -4436,8 +4436,8 @@ build_unary_op (location_t location, case COMPONENT_REF: if (DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1))) { - error ("cannot take address of bit-field %qD", - TREE_OPERAND (arg, 1)); + error_at (location, "cannot take address of bit-field %qD", + TREE_OPERAND (arg, 1)); return error_mark_node; } @@ -4449,15 +4449,16 @@ build_unary_op (location_t location, if (!AGGREGATE_TYPE_P (TREE_TYPE (arg)) && !VECTOR_TYPE_P (TREE_TYPE (arg))) { - error ("cannot take address of scalar with reverse storage " - "order"); + error_at (location, "cannot take address of scalar with " + "reverse storage order"); return error_mark_node; } if (TREE_CODE (TREE_TYPE (arg)) == ARRAY_TYPE && TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (arg))) - warning (OPT_Wscalar_storage_order, "address of array with " - "reverse scalar storage order requested"); + warning_at (location, OPT_Wscalar_storage_order, + "address of array with reverse scalar storage " + "order requested"); } default: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 61c8f12..0f2e861 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +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> * gcc.target/i386/pr46470.c: Add -mno-red-zone to dg-options for diff --git a/gcc/testsuite/gcc.dg/bitfld-22.c b/gcc/testsuite/gcc.dg/bitfld-22.c new file mode 100644 index 0000000..2fb904b --- /dev/null +++ b/gcc/testsuite/gcc.dg/bitfld-22.c @@ -0,0 +1,18 @@ +/* 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'" } */ +} |