1 // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -std=c++11 %s 2>&1 | FileCheck %s
3 template<typename T
, typename U
>
6 template<typename T
, typename U
>
8 typedef pair
<T
,U
> *iterator
;
13 template<typename T
, typename U
>
14 pair
<T
,U
> &tie(T
&, U
&);
16 int foo(map
<char*,int> &m
) {
20 for (pair
<char*,int> x
: m
) {
24 for (tie(p
, n
) : m
) { // expected-error {{for range declaration must declare a variable}}
36 iterator
&operator++();
37 iterator
&operator++(int);
38 bool operator==(const iterator
&) const;
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}:":"
52 v
) // expected-error@-1 {{range-based 'for' statement uses ':', not '='}}
53 // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:7-[[@LINE-2]]:8}:":"
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 '='}}
66 int a
[] = {1, 2, 3, 4, 5};
68 for (auto x
= n
? 1 : 2 : a
); // expected-error {{expected ';' in 'for' statement specifier}} \
69 // expected-error {{expected expression}}
70 for (int i
= 1; auto x
= n
? 1 : 2 : a
); // expected-error {{expected ';' in 'for' statement specifier}}
73 for (auto x
= n
? 1 : 2 : a
) // expected-error {{expected ';' in 'for' statement specifier}} \
74 // expected-error {{expected expression}}
76 } // expected-error {{expected statement}}
78 for (int i
= 1; auto x
= n
? 1 : 2 : a
) // expected-error {{expected ';' in 'for' statement specifier}}
79 } // expected-error {{expected statement}}