1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s 2 struct Data { }; 3 struct T { 4 Data *begin(); 5 Data *end(); 6 }; 7 8 struct NoBegin { 9 Data *end(); 10 }; 11 12 struct DeletedEnd : public T { 13 Data *begin(); 14 Data *end() = delete; //expected-note {{'end' has been explicitly marked deleted here}} 15 }; 16 17 struct DeletedADLBegin { }; 18 19 int* begin(DeletedADLBegin) = delete; //expected-note {{candidate function has been explicitly deleted}} \ 20 expected-note 5 {{candidate function not viable: no known conversion}} 21 22 struct PrivateEnd { 23 Data *begin(); 24 25 private: 26 Data *end(); // expected-note 2 {{declared private here}} 27 }; 28 29 struct ADLNoEnd { }; 30 Data * begin(ADLNoEnd); // expected-note 6 {{candidate function not viable: no known conversion}} 31 32 struct OverloadedStar { 33 T operator*(); 34 }; 35 f()36void 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 '*'?}} 41 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 '*'?}} 46 47 NoBegin NB; 48 for (auto i : NB) { }// expected-error{{range type 'NoBegin' has 'end' member but no 'begin' member}} 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}} 55 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}} 60 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; 65 66 for (auto i : pDE) { } // expected-error {{invalid range expression of type 'DeletedEnd *'; no viable 'begin' function available}} 67 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'}} 72 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'}} 76 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'}} 80 81 OverloadedStar OS; 82 for (auto i : *OS) { } 83 84 for (auto i : OS) { } // expected-error {{invalid range expression of type 'OverloadedStar'; did you mean to dereference it with '*'?}} 85 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 *'}} 89 } 90