1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s 2f4a2713aSLionel Sambuc struct Data { }; 3f4a2713aSLionel Sambuc struct T { 4f4a2713aSLionel Sambuc Data *begin(); 5f4a2713aSLionel Sambuc Data *end(); 6f4a2713aSLionel Sambuc }; 7f4a2713aSLionel Sambuc 8f4a2713aSLionel Sambuc struct NoBegin { 9f4a2713aSLionel Sambuc Data *end(); 10f4a2713aSLionel Sambuc }; 11f4a2713aSLionel Sambuc 12f4a2713aSLionel Sambuc struct DeletedEnd : public T { 13f4a2713aSLionel Sambuc Data *begin(); 14*0a6a1f1dSLionel Sambuc Data *end() = delete; //expected-note {{'end' has been explicitly marked deleted here}} 15f4a2713aSLionel Sambuc }; 16f4a2713aSLionel Sambuc 17f4a2713aSLionel Sambuc struct DeletedADLBegin { }; 18f4a2713aSLionel Sambuc 19f4a2713aSLionel Sambuc int* begin(DeletedADLBegin) = delete; //expected-note {{candidate function has been explicitly deleted}} \ 20f4a2713aSLionel Sambuc expected-note 5 {{candidate function not viable: no known conversion}} 21f4a2713aSLionel Sambuc 22f4a2713aSLionel Sambuc struct PrivateEnd { 23f4a2713aSLionel Sambuc Data *begin(); 24f4a2713aSLionel Sambuc 25f4a2713aSLionel Sambuc private: 26f4a2713aSLionel Sambuc Data *end(); // expected-note 2 {{declared private here}} 27f4a2713aSLionel Sambuc }; 28f4a2713aSLionel Sambuc 29f4a2713aSLionel Sambuc struct ADLNoEnd { }; 30f4a2713aSLionel Sambuc Data * begin(ADLNoEnd); // expected-note 6 {{candidate function not viable: no known conversion}} 31f4a2713aSLionel Sambuc 32f4a2713aSLionel Sambuc struct OverloadedStar { 33f4a2713aSLionel Sambuc T operator*(); 34f4a2713aSLionel Sambuc }; 35f4a2713aSLionel Sambuc f()36f4a2713aSLionel Sambucvoid f() { 37f4a2713aSLionel Sambuc T t; 38f4a2713aSLionel Sambuc for (auto i : t) { } 39f4a2713aSLionel Sambuc T *pt; 40f4a2713aSLionel Sambuc for (auto i : pt) { } // expected-error{{invalid range expression of type 'T *'; did you mean to dereference it with '*'?}} 41f4a2713aSLionel Sambuc 42f4a2713aSLionel Sambuc int arr[10]; 43f4a2713aSLionel Sambuc for (auto i : arr) { } 44f4a2713aSLionel Sambuc int (*parr)[10]; 45f4a2713aSLionel Sambuc for (auto i : parr) { }// expected-error{{invalid range expression of type 'int (*)[10]'; did you mean to dereference it with '*'?}} 46f4a2713aSLionel Sambuc 47f4a2713aSLionel Sambuc NoBegin NB; 48f4a2713aSLionel Sambuc for (auto i : NB) { }// expected-error{{range type 'NoBegin' has 'end' member but no 'begin' member}} 49f4a2713aSLionel Sambuc NoBegin *pNB; 50f4a2713aSLionel Sambuc for (auto i : pNB) { }// expected-error{{invalid range expression of type 'NoBegin *'; no viable 'begin' function available}} 51f4a2713aSLionel Sambuc NoBegin **ppNB; 52f4a2713aSLionel Sambuc for (auto i : ppNB) { }// expected-error{{invalid range expression of type 'NoBegin **'; no viable 'begin' function available}} 53f4a2713aSLionel Sambuc NoBegin *****pppppNB; 54f4a2713aSLionel Sambuc for (auto i : pppppNB) { }// expected-error{{invalid range expression of type 'NoBegin *****'; no viable 'begin' function available}} 55f4a2713aSLionel Sambuc 56f4a2713aSLionel Sambuc ADLNoEnd ANE; 57f4a2713aSLionel Sambuc for (auto i : ANE) { } // expected-error{{invalid range expression of type 'ADLNoEnd'; no viable 'end' function available}} 58f4a2713aSLionel Sambuc ADLNoEnd *pANE; 59f4a2713aSLionel Sambuc for (auto i : pANE) { } // expected-error{{invalid range expression of type 'ADLNoEnd *'; no viable 'begin' function available}} 60f4a2713aSLionel Sambuc 61f4a2713aSLionel Sambuc DeletedEnd DE; 62f4a2713aSLionel Sambuc for (auto i : DE) { } // expected-error{{attempt to use a deleted function}} \ 63f4a2713aSLionel Sambuc expected-note {{when looking up 'end' function for range expression of type 'DeletedEnd'}} 64f4a2713aSLionel Sambuc DeletedEnd *pDE; 65f4a2713aSLionel Sambuc 66f4a2713aSLionel Sambuc for (auto i : pDE) { } // expected-error {{invalid range expression of type 'DeletedEnd *'; no viable 'begin' function available}} 67f4a2713aSLionel Sambuc 68f4a2713aSLionel Sambuc PrivateEnd PE; 69f4a2713aSLionel Sambuc // FIXME: This diagnostic should be improved, as it does not specify that 70f4a2713aSLionel Sambuc // the range is invalid. 71f4a2713aSLionel Sambuc for (auto i : PE) { } // expected-error{{'end' is a private member of 'PrivateEnd'}} 72f4a2713aSLionel Sambuc 73f4a2713aSLionel Sambuc PrivateEnd *pPE; 74f4a2713aSLionel Sambuc for (auto i : pPE) { }// expected-error {{invalid range expression of type 'PrivateEnd *'}} 75f4a2713aSLionel Sambuc // expected-error@-1 {{'end' is a private member of 'PrivateEnd'}} 76f4a2713aSLionel Sambuc 77f4a2713aSLionel Sambuc DeletedADLBegin DAB; 78f4a2713aSLionel Sambuc for (auto i : DAB) { } // expected-error {{call to deleted function 'begin'}}\ 79f4a2713aSLionel Sambuc expected-note {{when looking up 'begin' function for range expression of type 'DeletedADLBegin'}} 80f4a2713aSLionel Sambuc 81f4a2713aSLionel Sambuc OverloadedStar OS; 82f4a2713aSLionel Sambuc for (auto i : *OS) { } 83f4a2713aSLionel Sambuc 84f4a2713aSLionel Sambuc for (auto i : OS) { } // expected-error {{invalid range expression of type 'OverloadedStar'; did you mean to dereference it with '*'?}} 85f4a2713aSLionel Sambuc 86f4a2713aSLionel Sambuc for (Data *p : pt) { } // expected-error {{invalid range expression of type 'T *'; did you mean to dereference it with '*'?}} 87f4a2713aSLionel Sambuc // expected-error@-1 {{no viable conversion from 'Data' to 'Data *'}} 88f4a2713aSLionel Sambuc // expected-note@4 {{selected 'begin' function with iterator type 'Data *'}} 89f4a2713aSLionel Sambuc } 90