aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp23/auto-fncast3.C
blob: 1204458c9316c2d5d2347800aa5784b20d8573c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// PR c++/103049
// P0849R8 - auto(x)
// { dg-do compile { target c++23 } }
// Test invalid use.

void
f ()
{
  char x[] = "foo";
  +decltype(auto){x}; // { dg-error "invalid use of .decltype\\(auto\\)." }
  +decltype(auto)(x); // { dg-error "invalid use of .decltype\\(auto\\)." }

  +auto(); // { dg-error "invalid use of .auto." }
  new auto(); // { dg-error "requires exactly one element" }
  +auto{}; // { dg-error "invalid use of .auto." }
  new auto{}; // { dg-error "requires exactly one element" }
  +auto(1, 2); // { dg-error "invalid use of .auto." }
  new auto(1, 2); // { dg-error "requires exactly one element" }
  +auto{1, 2}; // { dg-error "too many initializers" }
  new auto{1, 2}; // { dg-error "requires exactly one element" }
}