xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/operator-arrow-depth.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX=128 -foperator-arrow-depth 128
2f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX=2 -foperator-arrow-depth 2
3f4a2713aSLionel Sambuc // RUN: %clang -fsyntax-only -Xclang -verify %s -DMAX=10 -foperator-arrow-depth=10
4f4a2713aSLionel Sambuc 
5f4a2713aSLionel Sambuc template<int N> struct B;
6f4a2713aSLionel Sambuc template<int N> struct A {
7f4a2713aSLionel Sambuc   B<N> operator->(); // expected-note +{{'operator->' declared here produces an object of type 'B<}}
8f4a2713aSLionel Sambuc };
9f4a2713aSLionel Sambuc template<int N> struct B {
10f4a2713aSLionel Sambuc   A<N-1> operator->(); // expected-note +{{'operator->' declared here produces an object of type 'A<}}
11f4a2713aSLionel Sambuc #if MAX != 2
12*0a6a1f1dSLionel Sambuc   // expected-note-re@-2 {{(skipping {{120|2}} 'operator->'s in backtrace)}}
13f4a2713aSLionel Sambuc #endif
14f4a2713aSLionel Sambuc };
15f4a2713aSLionel Sambuc 
16f4a2713aSLionel Sambuc struct X { int n; };
17f4a2713aSLionel Sambuc template<> struct B<1> {
18f4a2713aSLionel Sambuc   X *operator->();
19f4a2713aSLionel Sambuc };
20f4a2713aSLionel Sambuc 
21f4a2713aSLionel Sambuc A<MAX/2> good;
22f4a2713aSLionel Sambuc int n = good->n;
23f4a2713aSLionel Sambuc 
24f4a2713aSLionel Sambuc B<MAX/2 + 1> bad;
25*0a6a1f1dSLionel Sambuc int m = bad->n; // expected-error-re {{use of 'operator->' on type 'B<{{2|10|128}} / 2 + 1>' would invoke a sequence of more than {{2|10|128}} 'operator->' calls}}
26f4a2713aSLionel Sambuc                 // expected-note@-1 {{use -foperator-arrow-depth=N to increase 'operator->' limit}}
27