view gcc/testsuite/g++.dg/ext/flexary16.C @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 1830386684a0
line wrap: on
line source

// 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 "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 "forbids flexible array member" }
  };
};


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