[mlir] Fix typo in test vector transform pass descriptions (#118194)
[llvm-project.git] / clang / test / SemaCXX / for-range-dereference.cpp
blobde4958c31bce7242df7d3081375bd21afbd18ade
1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2 struct Data { };
3 struct T {
4 Data *begin();
5 Data *end();
6 };
8 struct NoBegin {
9 Data *end();
12 struct DeletedEnd : public T {
13 Data *begin();
14 Data *end() = delete; //expected-note {{'end' has been explicitly marked deleted here}}
17 struct DeletedADLBegin { };
19 int* begin(DeletedADLBegin) = delete; //expected-note {{candidate function has been explicitly deleted}} \
20 expected-note 6 {{candidate function not viable: no known conversion}}
22 struct PrivateEnd {
23 Data *begin();
25 private:
26 Data *end(); // expected-note 2 {{declared private here}}
29 struct ADLNoEnd { };
30 Data * begin(ADLNoEnd); // expected-note 7 {{candidate function not viable: no known conversion}}
32 struct OverloadedStar {
33 T operator*();
36 void f() {
37 T t;
38 for (auto i : t) { }
39 T *pt;
40 for (auto i : pt) { } // expected-error{{invalid range expression of type 'T *'; did you mean to dereference it with '*'?}}
42 int arr[10];
43 for (auto i : arr) { }
44 int (*parr)[10];
45 for (auto i : parr) { }// expected-error{{invalid range expression of type 'int (*)[10]'; did you mean to dereference it with '*'?}}
47 NoBegin NB;
48 for (auto i : NB) { }// expected-error{{invalid range expression of type 'NoBegin'; no viable 'begin' function available}}
49 NoBegin *pNB;
50 for (auto i : pNB) { }// expected-error{{invalid range expression of type 'NoBegin *'; no viable 'begin' function available}}
51 NoBegin **ppNB;
52 for (auto i : ppNB) { }// expected-error{{invalid range expression of type 'NoBegin **'; no viable 'begin' function available}}
53 NoBegin *****pppppNB;
54 for (auto i : pppppNB) { }// expected-error{{invalid range expression of type 'NoBegin *****'; no viable 'begin' function available}}
56 ADLNoEnd ANE;
57 for (auto i : ANE) { } // expected-error{{invalid range expression of type 'ADLNoEnd'; no viable 'end' function available}}
58 ADLNoEnd *pANE;
59 for (auto i : pANE) { } // expected-error{{invalid range expression of type 'ADLNoEnd *'; no viable 'begin' function available}}
61 DeletedEnd DE;
62 for (auto i : DE) { } // expected-error{{attempt to use a deleted function}} \
63 expected-note {{when looking up 'end' function for range expression of type 'DeletedEnd'}}
64 DeletedEnd *pDE;
66 for (auto i : pDE) { } // expected-error {{invalid range expression of type 'DeletedEnd *'; no viable 'begin' function available}}
68 PrivateEnd PE;
69 // FIXME: This diagnostic should be improved, as it does not specify that
70 // the range is invalid.
71 for (auto i : PE) { } // expected-error{{'end' is a private member of 'PrivateEnd'}}
73 PrivateEnd *pPE;
74 for (auto i : pPE) { }// expected-error {{invalid range expression of type 'PrivateEnd *'}}
75 // expected-error@-1 {{'end' is a private member of 'PrivateEnd'}}
77 DeletedADLBegin DAB;
78 for (auto i : DAB) { } // expected-error {{call to deleted function 'begin'}}\
79 expected-note {{when looking up 'begin' function for range expression of type 'DeletedADLBegin'}}
81 OverloadedStar OS;
82 for (auto i : *OS) { }
84 for (auto i : OS) { } // expected-error {{invalid range expression of type 'OverloadedStar'; did you mean to dereference it with '*'?}}
86 for (Data *p : pt) { } // expected-error {{invalid range expression of type 'T *'; did you mean to dereference it with '*'?}}
87 // expected-error@-1 {{no viable conversion from 'Data' to 'Data *'}}
88 // expected-note@4 {{selected 'begin' function with iterator type 'Data *'}}