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