aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/flexary16.C
blob: 94eb6c8c577a855b464f284f7302b6412d37b6ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// PR c++/71147 - [6 Regression] Flexible array member wrongly rejected
//   in template
// { dg-do compile }
// { dg-options "-Wpedantic -Wno-error=pedantic" }

template <typename>
struct container
{
  struct elem {
    unsigned u;
  };

  struct incomplete {
    int x;
    elem array[];  // { dg-warning "10:ISO C\\+\\+ forbids flexible array member" }
  };
};

unsigned f (container<void>::incomplete* i)
{
  return i->array [0].u;
}


template <typename T>
struct D: container<T>
{
  struct S {
    int x;
    typename container<T>::elem array[];  // { dg-warning "33:ISO C\\+\\+ forbids flexible array member" }
  };
};


unsigned g (D<void>::S *s)
{
  return s->array [0].u;
}