diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2018-12-07 17:48:39 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2018-12-07 17:48:39 +0000 |
commit | fee11e77e59bb08b695ca4fb356322a8214a03c2 (patch) | |
tree | f24d1372131fa2548e34bf3e90ac769722bf308a | |
parent | 96e14fda0dca4d79479137844b4457305fad2c3f (diff) | |
download | gcc-fee11e77e59bb08b695ca4fb356322a8214a03c2.zip gcc-fee11e77e59bb08b695ca4fb356322a8214a03c2.tar.gz gcc-fee11e77e59bb08b695ca4fb356322a8214a03c2.tar.bz2 |
decl2.c (grokbitfield): Use DECL_SOURCE_LOCATION in error messages about bit-fields with function type...
/cp
2018-12-07 Paolo Carlini <paolo.carlini@oracle.com>
* decl2.c (grokbitfield): Use DECL_SOURCE_LOCATION in error messages
about bit-fields with function type, warn_if_not_aligned type, and
static bit-fields; avoid DECL_NAME for unnamed declarations.
/testsuite
2018-12-07 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/other/bitfield7.C: New.
* g++.dg/parse/bitfield8.C: Likewise.
* g++.dg/parse/bitfield9.C: Likewise.
* g++.dg/pr53037-4.C: Test the locations too.
From-SVN: r266900
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/other/bitfield7.C | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/bitfield8.C | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/bitfield9.C | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/pr53037-4.C | 4 |
7 files changed, 39 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6481ad4..fc22f20 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-12-07 Paolo Carlini <paolo.carlini@oracle.com> + + * decl2.c (grokbitfield): Use DECL_SOURCE_LOCATION in error messages + about bit-fields with function type, warn_if_not_aligned type, and + static bit-fields; avoid DECL_NAME for unnamed declarations. + 2018-12-07 Jakub Jelinek <jakub@redhat.com> PR c++/86669 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 15b0393..a8bf28a 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1046,15 +1046,15 @@ grokbitfield (const cp_declarator *declarator, check here. */ if (TREE_CODE (value) == FUNCTION_DECL) { - error ("cannot declare bit-field %qD with function type", - DECL_NAME (value)); + error_at (DECL_SOURCE_LOCATION (value), + "cannot declare bit-field %qD with function type", value); return NULL_TREE; } - if (width && TYPE_WARN_IF_NOT_ALIGN (type)) + if (TYPE_WARN_IF_NOT_ALIGN (type)) { - error ("cannot declare bit-field %qD with %<warn_if_not_aligned%> type", - DECL_NAME (value)); + error_at (DECL_SOURCE_LOCATION (value), "cannot declare bit-field " + "%qD with %<warn_if_not_aligned%> type", value); return NULL_TREE; } @@ -1067,7 +1067,8 @@ grokbitfield (const cp_declarator *declarator, if (TREE_STATIC (value)) { - error ("static member %qD cannot be a bit-field", value); + error_at (DECL_SOURCE_LOCATION (value), + "static member %qD cannot be a bit-field", value); return NULL_TREE; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 58b0ef3..afa3d70 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-12-07 Paolo Carlini <paolo.carlini@oracle.com> + + * g++.dg/other/bitfield7.C: New. + * g++.dg/parse/bitfield8.C: Likewise. + * g++.dg/parse/bitfield9.C: Likewise. + * g++.dg/pr53037-4.C: Test the locations too. + 2018-12-07 Peter Bergner <bergner@linux.ibm.com> PR target/87496 diff --git a/gcc/testsuite/g++.dg/other/bitfield7.C b/gcc/testsuite/g++.dg/other/bitfield7.C new file mode 100644 index 0000000..fa13662 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/bitfield7.C @@ -0,0 +1,7 @@ +typedef int __attribute__((warn_if_not_aligned(8))) intwna; + +struct S +{ + intwna : 2; // { dg-error "cannot declare bit-field" } + intwna i : 2; // { dg-error "10:cannot declare bit-field .i." } +}; diff --git a/gcc/testsuite/g++.dg/parse/bitfield8.C b/gcc/testsuite/g++.dg/parse/bitfield8.C new file mode 100644 index 0000000..19b862c --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/bitfield8.C @@ -0,0 +1,4 @@ +struct A +{ + static int a : 1; // { dg-error "14:static member .a. cannot be a bit-field" } +}; diff --git a/gcc/testsuite/g++.dg/parse/bitfield9.C b/gcc/testsuite/g++.dg/parse/bitfield9.C new file mode 100644 index 0000000..5256d2c --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/bitfield9.C @@ -0,0 +1,6 @@ +template<typename T> +struct A +{ + typedef T type(); + type i : 2; // { dg-error "8:cannot declare bit-field" } +}; diff --git a/gcc/testsuite/g++.dg/pr53037-4.C b/gcc/testsuite/g++.dg/pr53037-4.C index 553dd9a..f73f35f 100644 --- a/gcc/testsuite/g++.dg/pr53037-4.C +++ b/gcc/testsuite/g++.dg/pr53037-4.C @@ -12,7 +12,7 @@ foo2 (void) /* { dg-error "'warn_if_not_aligned' may not be specified for 'void struct foo3 { - int i : 2 __attribute__((warn_if_not_aligned(8))); /* { dg-error "'warn_if_not_aligned' may not be specified for 'i'" } */ + int i : 2 __attribute__((warn_if_not_aligned(8))); /* { dg-error "7:'warn_if_not_aligned' may not be specified for 'i'" } */ }; typedef unsigned int __u32 @@ -20,5 +20,5 @@ typedef unsigned int __u32 struct foo4 { - __u32 i : 2; /* { dg-error "cannot declare bit-field 'i' with 'warn_if_not_aligned' type" } */ + __u32 i : 2; /* { dg-error "9:cannot declare bit-field 'i' with 'warn_if_not_aligned' type" } */ }; |