+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
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;
}
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;
}
+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
--- /dev/null
+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." }
+};
--- /dev/null
+struct A
+{
+ static int a : 1; // { dg-error "14:static member .a. cannot be a bit-field" }
+};
--- /dev/null
+template<typename T>
+struct A
+{
+ typedef T type();
+ type i : 2; // { dg-error "8:cannot declare bit-field" }
+};
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
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" } */
};