Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 266818) +++ cp/decl2.c (working copy) @@ -1016,7 +1016,9 @@ 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. */ @@ -1023,11 +1025,12 @@ grokbitfield (const cp_declarator *declarator, 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 (value) || !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 % type", DECL_NAME (value)); Index: testsuite/g++.dg/parse/bitfield3.C =================================================================== --- testsuite/g++.dg/parse/bitfield3.C (revision 266818) +++ testsuite/g++.dg/parse/bitfield3.C (working copy) @@ -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." } */ }; Index: testsuite/g++.dg/parse/bitfield6b.C =================================================================== --- testsuite/g++.dg/parse/bitfield6b.C (nonexistent) +++ testsuite/g++.dg/parse/bitfield6b.C (working copy) @@ -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::\\)\\(\\)." } +};