+2018-12-06 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * class.c (check_bitfield_decl): In error message about non-integral
+ type print the type itself too.
+ * decl.c (grokdeclarator): Do not ICE on unnamed bit-fields declared
+ friends; when calling build_decl for a FIELD_DECL possibly pass the
+ declarator->id_loc.
+
2018-12-06 Alexandre Oliva <aoliva@redhat.com>
PR c++/86747
/* Detect invalid bit-field type. */
if (!INTEGRAL_OR_ENUMERATION_TYPE_P (type))
{
- error ("bit-field %q+#D with non-integral type", field);
+ error_at (DECL_SOURCE_LOCATION (field),
+ "bit-field %q#D with non-integral type %qT", field, type);
w = error_mark_node;
}
else
{
if (friendp)
{
- error_at (declarator->id_loc,
- "%qE is neither function nor member function; "
- "cannot be declared friend", unqualified_id);
+ if (unqualified_id && declarator)
+ error_at (declarator->id_loc,
+ "%qE is neither function nor member function; "
+ "cannot be declared friend", unqualified_id);
+ else
+ error ("unnamed field is neither function nor member "
+ "function; cannot be declared friend");
return error_mark_node;
}
decl = NULL_TREE;
if (decl == NULL_TREE)
{
+ location_t loc = declarator ? declarator->id_loc : input_location;
if (staticp)
{
/* C++ allows static class members. All other work
for this is done by grokfield. */
- decl = build_lang_decl_loc (declarator
- ? declarator->id_loc
- : input_location,
- VAR_DECL, unqualified_id, type);
+ decl = build_lang_decl_loc (loc, VAR_DECL,
+ unqualified_id, type);
set_linkage_for_static_data_member (decl);
if (concept_p)
error_at (declspecs->locations[ds_concept],
unqualified_id);
constexpr_p = false;
}
- decl = build_decl (input_location,
- FIELD_DECL, unqualified_id, type);
+ decl = build_decl (loc, FIELD_DECL, unqualified_id, type);
DECL_NONADDRESSABLE_P (decl) = bitfield;
if (bitfield && !unqualified_id)
{
+2018-12-06 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * g++.dg/parse/bitfield7.C: New.
+ * g++.dg/other/bitfield2.C: Check location and type.
+ * g++.dg/parse/bitfield1.C: Likewise.
+ * g++.dg/parse/bitfield2.C: Likewise.
+
2018-12-06 Alexandre Oliva <aoliva@redhat.com>
PR c++/86747
struct A
{
- X x : 2; // { dg-error "non-integral type" }
+ X x : 2; // { dg-error "7:bit-field .x. with non-integral type .X." }
};
struct B : A {};
template <typename T>
struct D
{
- T t : 3; // { dg-error "non-integral type" }
+ T t : 3; // { dg-error "5:bit-field .double D\\<double\\>::t. with non-integral type .double." }
};
D<double> d; // { dg-message "required" }
struct E
{
typedef T* U;
- U t : 3; // { dg-error "non-integral type" }
+ U t : 3; // { dg-error "5:bit-field .t. with non-integral type .E\\<T\\>::U." }
};
E<double> e;