1 // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -std=c++11 %s 2>&1 | FileCheck %s
2 
3 template<typename T, typename U>
4 struct pair {};
5 
6 template<typename T, typename U>
7 struct map {
8   typedef pair<T,U> *iterator;
9   iterator begin();
10   iterator end();
11 };
12 
13 template<typename T, typename U>
14 pair<T,U> &tie(T &, U &);
15 
foo(map<char *,int> & m)16 int foo(map<char*,int> &m) {
17   char *p;
18   int n;
19 
20   for (pair<char*,int> x : m) {
21     (void)x;
22   }
23 
24   for (tie(p, n) : m) { // expected-error {{for range declaration must declare a variable}}
25     (void)p;
26     (void)n;
27   }
28 
29   return n;
30 }
31 
32 namespace PR19176 {
33 struct Vector {
34   struct iterator {
35     int &operator*();
36     iterator &operator++();
37     iterator &operator++(int);
38     bool operator==(const iterator &) const;
39   };
40   iterator begin();
41   iterator end();
42 };
43 
f()44 void f() {
45   Vector v;
46   int a[] = {1, 2, 3, 4};
47   for (auto foo   =     a) // expected-error {{range-based 'for' statement uses ':', not '='}}
48     // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:19-[[@LINE-1]]:20}:":"
49     (void)foo;
50   for (auto i
51       =
52       v) // expected-error@-1 {{range-based 'for' statement uses ':', not '='}}
53     // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:7-[[@LINE-2]]:8}:":"
54     (void)i;
55 #define FORRANGE(v, a) for (DECLVARWITHINIT(v) a)  // expected-note {{expanded from macro}}
56 #define DECLAUTOVAR(v) auto v
57 #define DECLVARWITHINIT(v) DECLAUTOVAR(v) =  // expected-note {{expanded from macro}}
58   FORRANGE(i, a) {  // expected-error {{range-based 'for' statement uses ':', not '='}}
59 
60   }
61 }
62 }
63