Richard Smith | 762bb9d | 2011-10-13 22:29:44 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 |
David Blaikie | 5f31f08 | 2011-10-18 05:54:07 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions |
Richard Smith | ad762fc | 2011-04-14 22:09:26 +0000 | [diff] [blame] | 3 | |
| 4 | struct S { |
| 5 | int *begin(); |
| 6 | int *end(); |
| 7 | }; |
| 8 | |
| 9 | struct T { |
| 10 | }; |
| 11 | |
| 12 | struct Range {}; |
| 13 | int begin(Range); // expected-note {{not viable}} |
| 14 | int end(Range); |
| 15 | |
| 16 | namespace NS { |
| 17 | struct ADL {}; |
| 18 | struct iter { |
| 19 | int operator*(); |
| 20 | bool operator!=(iter); |
| 21 | void operator++(); |
| 22 | }; |
| 23 | iter begin(ADL); // expected-note {{not viable}} |
| 24 | iter end(ADL); |
| 25 | |
| 26 | struct NoADL {}; |
| 27 | } |
| 28 | NS::iter begin(NS::NoADL); // expected-note {{not viable}} |
| 29 | NS::iter end(NS::NoADL); |
| 30 | |
| 31 | void f() { |
| 32 | int a[] = {1, 2, 3}; |
| 33 | for (auto b : S()) {} // ok |
Sam Panzer | e1715b6 | 2012-08-21 00:52:01 +0000 | [diff] [blame] | 34 | for (auto b : T()) {} // expected-error {{invalid range expression of type 'T'}} |
Richard Smith | ad762fc | 2011-04-14 22:09:26 +0000 | [diff] [blame] | 35 | for (auto b : a) {} // ok |
| 36 | for (int b : NS::ADL()) {} // ok |
Sam Panzer | e1715b6 | 2012-08-21 00:52:01 +0000 | [diff] [blame] | 37 | for (int b : NS::NoADL()) {} // expected-error {{invalid range expression of type 'NS::NoADL'}} |
Richard Smith | ad762fc | 2011-04-14 22:09:26 +0000 | [diff] [blame] | 38 | } |
Eli Friedman | 9490ab4 | 2011-12-20 01:50:37 +0000 | [diff] [blame] | 39 | |
| 40 | void PR11601() { |
| 41 | void (*vv[])() = {PR11601, PR11601, PR11601}; |
| 42 | for (void (*i)() : vv) i(); |
| 43 | } |