annotate clang/test/SemaCXX/for-range-no-std.cpp @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 struct S {
anatofuz
parents:
diff changeset
5 int *begin();
anatofuz
parents:
diff changeset
6 int *end();
anatofuz
parents:
diff changeset
7 };
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 struct T {
anatofuz
parents:
diff changeset
10 };
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 struct Range {};
anatofuz
parents:
diff changeset
13 int begin(Range); // expected-note {{not viable}}
anatofuz
parents:
diff changeset
14 int end(Range);
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 namespace NS {
anatofuz
parents:
diff changeset
17 struct ADL {};
anatofuz
parents:
diff changeset
18 struct iter {
anatofuz
parents:
diff changeset
19 int operator*();
anatofuz
parents:
diff changeset
20 bool operator!=(iter);
anatofuz
parents:
diff changeset
21 void operator++();
anatofuz
parents:
diff changeset
22 };
anatofuz
parents:
diff changeset
23 iter begin(ADL); // expected-note {{not viable}}
anatofuz
parents:
diff changeset
24 iter end(ADL);
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 struct NoADL {};
anatofuz
parents:
diff changeset
27 }
anatofuz
parents:
diff changeset
28 NS::iter begin(NS::NoADL); // expected-note {{not viable}}
anatofuz
parents:
diff changeset
29 NS::iter end(NS::NoADL);
anatofuz
parents:
diff changeset
30
anatofuz
parents:
diff changeset
31 void f() {
anatofuz
parents:
diff changeset
32 int a[] = {1, 2, 3};
anatofuz
parents:
diff changeset
33 for (auto b : S()) {} // ok
anatofuz
parents:
diff changeset
34 for (auto b : T()) {} // expected-error {{invalid range expression of type 'T'}}
anatofuz
parents:
diff changeset
35 for (auto b : a) {} // ok
anatofuz
parents:
diff changeset
36 for (int b : NS::ADL()) {} // ok
anatofuz
parents:
diff changeset
37 for (int b : NS::NoADL()) {} // expected-error {{invalid range expression of type 'NS::NoADL'}}
anatofuz
parents:
diff changeset
38 }
anatofuz
parents:
diff changeset
39
anatofuz
parents:
diff changeset
40 void PR11601() {
anatofuz
parents:
diff changeset
41 void (*vv[])() = {PR11601, PR11601, PR11601};
anatofuz
parents:
diff changeset
42 for (void (*i)() : vv) i();
anatofuz
parents:
diff changeset
43 }