@@ -5003,6 +5003,9 @@ decode_field_reference (location_t loc, tree *exp_, HOST_WIDE_INT *pbitsize,
|| *pbitsize < 0
|| offset != 0
|| TREE_CODE (inner) == PLACEHOLDER_EXPR
+ /* We eventually want to build a larger reference and need to take
+ the address of this. */
+ || (!REFERENCE_CLASS_P (inner) && !DECL_P (inner))
/* Reject out-of-bound accesses (PR79731). */
|| (! AGGREGATE_TYPE_P (TREE_TYPE (inner))
&& compare_tree_int (TYPE_SIZE (TREE_TYPE (inner)),
new file mode 100644
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+
+typedef struct {
+ char hours, day, month;
+ short year;
+} T;
+
+T g (void)
+{
+ T now;
+ now.hours = 1;
+ now.day = 2;
+ now.month = 3;
+ now.year = 4;
+ return now;
+}
+
+__attribute__((const)) T f (void)
+{
+ T virk = g ();
+ return virk;
+}
+
+int main ()
+{
+ if (f ().hours != 1 || f ().day != 2 || f ().month != 3 || f ().year != 4)
+ __builtin_abort ();
+ return 0;
+}