File: diagnostic5.C

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (43 lines) | stat: -rw-r--r-- 1,949 bytes parent folder | download | duplicates (2)
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
// { dg-do compile { target c++2a } }
// { dg-additional-options "-fconcepts-diagnostics-depth=2" }

template<typename T>
  concept c1 = requires { typename T::blah; };
// { dg-message "satisfaction of .c1<T>. .with T = char." "" { target *-*-* } .-1 }
// { dg-message ".typename T::blah. is invalid" "" { target *-*-* } .-2 }

template<typename T>
  concept c2 = requires (T x) { *x; };
// { dg-message "satisfaction of .c2<T>. .with T = char." "" { target *-*-* } .-1 }
// { dg-message "in requirements with .T x. .with T = char." "" { target *-*-* } .-2 }
// { dg-message "required expression .* is invalid" "" { target *-*-* } .-3 }

template<typename T>
  concept c3 = __is_same(T, const T) || __is_same(T, int);
// { dg-message "satisfaction of .c3<T>. .with T = char." "" { target *-*-* } .-1 }
// { dg-message "no operand of the disjunction is satisfied" "" { target *-*-* } .-2 }

template<typename T>
  concept c4 = requires (T x) { requires c2<const T> || c2<volatile T>; };
// { dg-message "satisfaction of .c4<T>. .with T = char." "" { target *-*-* } .-1 }
// { dg-message "nested requirement" "" { target *-*-* } .-2 }

template<typename T>
  concept c5 = requires (T x) { { &x } -> c1; };
// { dg-message "satisfaction of .c5<T>. .with T = char." "" { target *-*-* } .-1 }
// { dg-message "in requirements with .T x. .with T = char." "" { target *-*-* } .-2 }

template<typename T>
  requires (c1<T> || c2<T>) || (c3<T> || c4<T>) || c5<T> // { dg-message "49: no operand" }
  // { dg-message ".c1<T>. is unsatisfied because" "" { target *-*-* } .-1 }
  // { dg-message ".c2<T>. is unsatisfied because" "" { target *-*-* } .-2 }
  // { dg-message ".c3<T>. is unsatisfied because" "" { target *-*-* } .-3 }
  // { dg-message ".c4<T>. is unsatisfied because" "" { target *-*-* } .-4 }
  // { dg-message ".c5<T>. is unsatisfied because" "" { target *-*-* } .-5 }
  void foo() { }

void
bar()
{
  foo<char>(); // { dg-error "no match" }
}