===================================================================
@@ -11933,6 +11934,8 @@ grokdeclarator (const cp_declarator *declarator,
}
}
+ location_t loc = declarator ? declarator->id_loc : input_location;
+
/* If this is declaring a typedef name, return a TYPE_DECL. */
if (typedef_p && decl_context != TYPENAME)
{
@@ -11978,9 +11981,9 @@ grokdeclarator (const cp_declarator *declarator,
}
if (decl_context == FIELD)
- decl = build_lang_decl (TYPE_DECL, unqualified_id, type);
+ decl = build_lang_decl_loc (loc, TYPE_DECL, unqualified_id, type);
else
- decl = build_decl (input_location, TYPE_DECL, unqualified_id, type);
+ decl = build_decl (loc, TYPE_DECL, unqualified_id, type);
if (decl_context != FIELD)
{
@@ -12221,7 +12224,6 @@ grokdeclarator (const cp_declarator *declarator,
{
tree decl = NULL_TREE;
- location_t loc = declarator ? declarator->id_loc : input_location;
if (decl_context == PARM)
{
===================================================================
@@ -1038,7 +1039,8 @@ grokbitfield (const cp_declarator *declarator,
if (TREE_CODE (value) == TYPE_DECL)
{
- error ("cannot declare %qD to be a bit-field type", value);
+ error_at (DECL_SOURCE_LOCATION (value),
+ "cannot declare %qD to be a bit-field type", value);
return NULL_TREE;
}
===================================================================
@@ -0,0 +1,5 @@
+struct S
+{
+ typedef int i : 3; // { dg-error "15:cannot declare .i." }
+ typedef int : 3; // { dg-error "cannot declare" }
+};