aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/consteval-prop11.C
blob: aca9675cd53ec87138576e2731a4959a4eca00e0 (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
39
40
41
42
43
44
45
46
47
48
49
// P2564R3
// { dg-do compile { target c++20 } }
// { dg-options "-fdiagnostics-show-caret" }
// Test diagnostic.

consteval int id (int i) { return i; }
constexpr int foo (int i ) { return i; }

constexpr int
foobar (auto i)
{
  return i + id (i);
  /* { dg-begin-multiline-output "" }
   return i + id (i);
              ~~~^~~
     { dg-end-multiline-output "" } */
}

void
g (int x)
{
  foobar (x); // { dg-error "10:call to consteval function .foobar<int>\\(x\\). is not a constant expression" }
// { dg-error ".x. is not a constant expression" "" { target *-*-* } .-1 }
  /* { dg-begin-multiline-output "" }
foobar (x);
   ~~~~~~~^~~
     { dg-end-multiline-output "" } */
}

constexpr int
f2 (auto i)
{
  auto p = &id;
  /* { dg-begin-multiline-output "" }
   auto p = &id;
            ^~~
     { dg-end-multiline-output "" } */
  return p (i);
}

void
g2 (int x)
{
  f2 (x); // { dg-error "6:call to consteval function .f2<int>\\(x\\). is not a constant expression|not a constant expression" }
  /* { dg-begin-multiline-output "" }
f2 (x);
   ~~~^~~
     { dg-end-multiline-output "" } */
}