Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / Parser / cxx0x-for-range.cpp
bloba265c4764af56f0b6e66e88acc8c579a1540c957
1 // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -std=c++11 %s 2>&1 | FileCheck %s
3 template<typename T, typename U>
4 struct pair {};
6 template<typename T, typename U>
7 struct map {
8 typedef pair<T,U> *iterator;
9 iterator begin();
10 iterator end();
13 template<typename T, typename U>
14 pair<T,U> &tie(T &, U &);
16 int foo(map<char*,int> &m) {
17 char *p;
18 int n;
20 for (pair<char*,int> x : m) {
21 (void)x;
24 for (tie(p, n) : m) { // expected-error {{for range declaration must declare a variable}}
25 (void)p;
26 (void)n;
29 return n;
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;
40 iterator begin();
41 iterator end();
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
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 '='}}
64 namespace GH63010 {
65 void foo(int n) {
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}}