aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl2.c15
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/parse/bitfield3.C2
-rw-r--r--gcc/testsuite/g++.dg/parse/bitfield6b.C4
5 files changed, 24 insertions, 7 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));
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d330d0e..922cc52 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-12-06 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * g++.dg/parse/bitfield6b.C: New.
+ * g++.dg/parse/bitfield3.C: Test location and type.
+
2018-12-06 Iain Sandoe <iain@sandoe.co.uk>
* lib/c-compat.exp (compat-use-alt-compiler):
diff --git a/gcc/testsuite/g++.dg/parse/bitfield3.C b/gcc/testsuite/g++.dg/parse/bitfield3.C
index 387548a..efff2ec 100644
--- a/gcc/testsuite/g++.dg/parse/bitfield3.C
+++ b/gcc/testsuite/g++.dg/parse/bitfield3.C
@@ -5,5 +5,5 @@ typedef void (func_type)();
struct A
{
- friend func_type f : 2; /* { dg-error "with non-integral type" } */
+ friend func_type f : 2; /* { dg-error "20:bit-field .void f\\(\\). with non-integral type .func_type." } */
};
diff --git a/gcc/testsuite/g++.dg/parse/bitfield6b.C b/gcc/testsuite/g++.dg/parse/bitfield6b.C
new file mode 100644
index 0000000..1cd99a5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/bitfield6b.C
@@ -0,0 +1,4 @@
+typedef void a();
+struct A {
+a a1: 1; // { dg-error "3:bit-field .void A::a1\\(\\). with non-integral type .void \\(A::\\)\\(\\)." }
+};