/* Record the initialization. */
TREE_VALUE (subobject_init) = TREE_VALUE (init);
+ /* Carry over the dummy TREE_TYPE node containing the source location. */
+ TREE_TYPE (subobject_init) = TREE_TYPE (init);
next_subobject = subobject_init;
}
/* Initialize the data members. */
while (mem_inits)
{
+ /* If this initializer was explicitly provided, then the dummy TREE_TYPE
+ node contains the source location. */
+ iloc_sentinel ils (EXPR_LOCATION (TREE_TYPE (mem_inits)));
+
perform_member_init (TREE_PURPOSE (mem_inits),
TREE_VALUE (mem_inits));
mem_inits = TREE_CHAIN (mem_inits);
in_base_initializer = 0;
- return member ? build_tree_list (member, expression_list) : error_mark_node;
+ if (!member)
+ return error_mark_node;
+ tree node = build_tree_list (member, expression_list);
+
+ /* We can't attach the source location of this initializer directly to
+ the list node, so we instead attach it to a dummy EMPTY_CLASS_EXPR
+ within the TREE_TYPE of the list node. */
+ location_t loc
+ = make_location (token->location, token->location, parser->lexer);
+ tree dummy = build0 (EMPTY_CLASS_EXPR, NULL_TREE);
+ SET_EXPR_LOCATION (dummy, loc);
+ TREE_TYPE (node) = dummy;
+
+ return node;
}
/* Parse a mem-initializer-id.
if (decl)
{
init = build_tree_list (decl, init);
+ /* Carry over the dummy TREE_TYPE node containing the source
+ location. */
+ TREE_TYPE (init) = TREE_TYPE (t);
TREE_CHAIN (init) = inits;
inits = init;
}
--- /dev/null
+// PR c++/94024
+// { dg-do compile }
+
+struct A {
+ A()
+ : a() // { dg-error "reference type" }
+ , b(1) // { dg-error "incompatible" }
+ , c(0) // { dg-bogus "" }
+ {}
+
+ int &a;
+ int b[1];
+ char c;
+};
+
+template<typename T, typename U>
+struct B {
+ B()
+ : a() // { dg-error "reference type" }
+ , b(1) // { dg-error "incompatible" }
+ , c(0) // { dg-bogus "" }
+ {}
+
+ T a;
+ U b;
+ char c;
+};
+
+B<int&, int[1]> b;