Debian Codegraph @

gcc/testsuite/g++.dg/ext/flexarray-mangle-2.C

raw
1 // PR c++/69277 - [6 Regression] ICE mangling a flexible array member
2 // { dg-do compile { target c++11 } }
3 // { dg-additional-options "-Wno-error=pedantic" }
4
5 struct A {
6 int n;
7 char a[]; // { dg-warning "8:ISO C\\+\\+ forbids flexible array member" }
8 };
9
10 // Declare but do not define function templates.
11 template <class T>
12 void foo ();
13
14 template <typename T>
15 void fooref (T&);
16
17 // Rvalue references are a C++ 11 feature.
18 template <typename T>
19 void foorefref (T&&);
20
21 void bar (A a)
22 {
23 // Decltype is also a C++ 11 feature.
24 // Verify that decltype gets the right type and that foo is
25 // mangled correctly.
26 foo<decltype (a.a)>();
27
28 // Verify that function templates taking a reference and an rvalue
29 // references (as in PR c++/69277) are also mangled correctly.
30 fooref (a.a);
31 foorefref (a.a);
32 }
33
34 // In G++ versions prior to 6, flexible array members were incorrectly
35 // mangled as arrays of zero elements. Verify that flexible array
36 // members are mangled correctly as arrays of an unspecified number
37 // of elements.
38
39 // void foo<char []>():
40 // { dg-final { scan-assembler _Z3fooIA_cEvv } }
41
42 // The following is derived from PR c++/69277:
43 // void fooref<char []>(char (&) [])
44 // { dg-final { scan-assembler _Z6foorefIA_cEvRT_ } }
45
46 // void foorefref<char (&) []>(char (&) [])
47 // { dg-final { scan-assembler _Z9foorefrefIRA_cEvOT_ } }