1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 class Iteratable {
6  public:
7   using const_iterator = int* const*;
8 
begin()9   const_iterator begin() { return nullptr; }
end()10   const_iterator end() { return nullptr; }
11 };
12 
13 class Foo {
14  public:
foo()15   void foo() {}
16 };
17 
18 void f();
19 
main()20 int main() {
21   int integer;
22   Foo foo;
23 
24   auto int_copy = integer;
25   const auto const_int_copy = integer;
26   const auto& const_int_ref = integer;
27 
28   auto raw_int_ptr = &integer;
29   const auto const_raw_int_ptr = &integer;
30   const auto& const_raw_int_ptr_ref = &integer;
31 
32   auto* raw_int_ptr_valid = &integer;
33   const auto* const_raw_int_ptr_valid = &integer;
34 
35   auto raw_foo_ptr = &foo;
36   const auto const_raw_foo_ptr = &foo;
37   const auto& const_raw_foo_ptr_ref = &foo;
38 
39   auto* raw_foo_ptr_valid = &foo;
40   const auto* const_raw_foo_ptr_valid = &foo;
41 
42   int* int_ptr;
43 
44   auto double_ptr_auto = &int_ptr;
45   auto* double_ptr_auto_ptr = &int_ptr;
46   auto** double_ptr_auto_double_ptr = &int_ptr;
47 
48   auto function_ptr = &f;
49   auto method_ptr = &Foo::foo;
50 
51   int* const* const volatile** const* pointer_awesomeness;
52   auto auto_awesome = pointer_awesomeness;
53 
54   auto& int_ptr_ref = int_ptr;
55   const auto& const_int_ptr_ref = int_ptr;
56   auto&& int_ptr_rref = static_cast<int*&&>(int_ptr);
57   const auto&& const_int_ptr_rref = static_cast<int*&&>(int_ptr);
58 
59   static auto static_ptr = new int;
60 
61   Iteratable iteratable;
62   for (auto& it : iteratable)
63     (void)it;
64 
65   // This is a valid usecase of deducing a type to be a raw pointer and should
66   // not trigger a warning / error.
67   auto lambda = [foo_ptr = &foo] { return *foo_ptr; };
68 }
69