aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp23/attr-assume9.C
blob: cbd681516920ec64c610502feb656c4036d5d997 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Diagnose failed assumptions involving a function call.
// { dg-do compile { target c++17 } }

struct string
{
  const char *p;
  constexpr string (const char *p): p(p) { }
  constexpr int length () { return __builtin_strlen (p); }
};

constexpr int f()
{
  string s ("foobar");
  [[assume (s.length () == 0)]]; // { dg-error "assume" }
  // { dg-message "6 == 0" "" { target *-*-* } .-1 }
  return s.length ();
}

static_assert (f());		// { dg-error "non-constant" }