diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2018-12-06 08:23:04 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2018-12-06 08:23:04 +0000 |
commit | 34b1a7d63d96b0c39734c0b6dfee76715506efcf (patch) | |
tree | e897985b35ad8beaf0811b3b69770ec8701b81f8 /gcc/cp | |
parent | bd38d0da47c238e6660a3d1d8461083abfe23aa2 (diff) | |
download | gcc-34b1a7d63d96b0c39734c0b6dfee76715506efcf.zip gcc-34b1a7d63d96b0c39734c0b6dfee76715506efcf.tar.gz gcc-34b1a7d63d96b0c39734c0b6dfee76715506efcf.tar.bz2 |
decl2.c (grokbitfield): Use DECL_SOURCE_LOCATION in error message...
/cp
2018-12-06 Paolo Carlini <paolo.carlini@oracle.com>
* decl2.c (grokbitfield): Use DECL_SOURCE_LOCATION in error message;
print the type too; fix thinko in INDIRECT_TYPE_P use.
/testsuite
2018-12-06 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/parse/bitfield6b.C: New.
* g++.dg/parse/bitfield3.C: Test location and type.
From-SVN: r266841
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 15 |
2 files changed, 14 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3958992..704e01d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-12-06 Paolo Carlini <paolo.carlini@oracle.com> + + * decl2.c (grokbitfield): Use DECL_SOURCE_LOCATION in error message; + print the type too; fix thinko in INDIRECT_TYPE_P use. + 2018-12-05 Alexandre Oliva <aoliva@redhat.com> PR c++/85569 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index ffc0d0d..79abdae 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1016,18 +1016,21 @@ grokbitfield (const cp_declarator *declarator, if (value == error_mark_node) return NULL_TREE; /* friends went bad. */ - if (TREE_TYPE (value) == error_mark_node) + + tree type = TREE_TYPE (value); + if (type == error_mark_node) return value; /* Pass friendly classes back. */ if (VOID_TYPE_P (value)) return void_type_node; - if (!INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (value)) - && (INDIRECT_TYPE_P (value) - || !dependent_type_p (TREE_TYPE (value)))) + if (!INTEGRAL_OR_ENUMERATION_TYPE_P (type) + && (INDIRECT_TYPE_P (type) || !dependent_type_p (type))) { - error ("bit-field %qD with non-integral type", value); + error_at (DECL_SOURCE_LOCATION (value), + "bit-field %qD with non-integral type %qT", + value, type); return error_mark_node; } @@ -1048,7 +1051,7 @@ grokbitfield (const cp_declarator *declarator, return NULL_TREE; } - if (width && TYPE_WARN_IF_NOT_ALIGN (TREE_TYPE (value))) + if (width && TYPE_WARN_IF_NOT_ALIGN (type)) { error ("cannot declare bit-field %qD with %<warn_if_not_aligned%> type", DECL_NAME (value)); |