+2019-01-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * decl.c (start_decl): Improve error location.
+ * decl2.c (grokfield): Likewise.
+
+2019-01-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * decl.c (grokdeclarator): Move further up the location_t loc
+ declaration and use the location when building a TYPE_DECL for
+ a typedef name.
+ * decl2.c (grokbitfield): Use DECL_SOURCE_LOCATION in the error
+ about an ill-formed bit-field as typedef.
+
2019-01-14 Marek Polacek <polacek@redhat.com>
PR c++/88830 - ICE with abstract class.
if (initialized
&& TREE_CODE (decl) == TYPE_DECL)
{
- error ("typedef %qD is initialized (use decltype instead)", decl);
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "typedef %qD is initialized (use decltype instead)", decl);
return error_mark_node;
}
}
}
+ 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)
{
}
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)
{
{
tree decl = NULL_TREE;
- location_t loc = declarator ? declarator->id_loc : input_location;
if (decl_context == PARM)
{
if (TREE_CODE (value) == TYPE_DECL && init)
{
- error ("typedef %qD is initialized (use decltype instead)", value);
+ error_at (cp_expr_loc_or_loc (init, DECL_SOURCE_LOCATION (value)),
+ "typedef %qD is initialized (use decltype instead)", value);
init = NULL_TREE;
}
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;
}
+2019-01-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * g++.dg/diagnostic/typedef-initialized.C: New.
+
+2019-01-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * g++.dg/diagnostic/bitfld3.C: New.
+
2019-01-15 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/88775
--- /dev/null
+struct S
+{
+ typedef int i : 3; // { dg-error "15:cannot declare .i." }
+ typedef int : 3; // { dg-error "cannot declare" }
+};
--- /dev/null
+struct S
+{
+ typedef int i __attribute__((unused)) = 1; // { dg-error "15:typedef .i. is initialized" }
+};
+
+typedef int i __attribute__((unused)) = 1; // { dg-error "13:typedef .i. is initialized" }