1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions 3*f4a2713aSLionel Sambuc 4*f4a2713aSLionel Sambuc struct S { 5*f4a2713aSLionel Sambuc int *begin(); 6*f4a2713aSLionel Sambuc int *end(); 7*f4a2713aSLionel Sambuc }; 8*f4a2713aSLionel Sambuc 9*f4a2713aSLionel Sambuc struct T { 10*f4a2713aSLionel Sambuc }; 11*f4a2713aSLionel Sambuc 12*f4a2713aSLionel Sambuc struct Range {}; 13*f4a2713aSLionel Sambuc int begin(Range); // expected-note {{not viable}} 14*f4a2713aSLionel Sambuc int end(Range); 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambuc namespace NS { 17*f4a2713aSLionel Sambuc struct ADL {}; 18*f4a2713aSLionel Sambuc struct iter { 19*f4a2713aSLionel Sambuc int operator*(); 20*f4a2713aSLionel Sambuc bool operator!=(iter); 21*f4a2713aSLionel Sambuc void operator++(); 22*f4a2713aSLionel Sambuc }; 23*f4a2713aSLionel Sambuc iter begin(ADL); // expected-note {{not viable}} 24*f4a2713aSLionel Sambuc iter end(ADL); 25*f4a2713aSLionel Sambuc 26*f4a2713aSLionel Sambuc struct NoADL {}; 27*f4a2713aSLionel Sambuc } 28*f4a2713aSLionel Sambuc NS::iter begin(NS::NoADL); // expected-note {{not viable}} 29*f4a2713aSLionel Sambuc NS::iter end(NS::NoADL); 30*f4a2713aSLionel Sambuc f()31*f4a2713aSLionel Sambucvoid f() { 32*f4a2713aSLionel Sambuc int a[] = {1, 2, 3}; 33*f4a2713aSLionel Sambuc for (auto b : S()) {} // ok 34*f4a2713aSLionel Sambuc for (auto b : T()) {} // expected-error {{invalid range expression of type 'T'}} 35*f4a2713aSLionel Sambuc for (auto b : a) {} // ok 36*f4a2713aSLionel Sambuc for (int b : NS::ADL()) {} // ok 37*f4a2713aSLionel Sambuc for (int b : NS::NoADL()) {} // expected-error {{invalid range expression of type 'NS::NoADL'}} 38*f4a2713aSLionel Sambuc } 39*f4a2713aSLionel Sambuc PR11601()40*f4a2713aSLionel Sambucvoid PR11601() { 41*f4a2713aSLionel Sambuc void (*vv[])() = {PR11601, PR11601, PR11601}; 42*f4a2713aSLionel Sambuc for (void (*i)() : vv) i(); 43*f4a2713aSLionel Sambuc } 44