1*1c6e752cSArthur O'Dwyer //===----------------------------------------------------------------------===// 2*1c6e752cSArthur O'Dwyer // 3*1c6e752cSArthur O'Dwyer // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*1c6e752cSArthur O'Dwyer // See https://llvm.org/LICENSE.txt for license information. 5*1c6e752cSArthur O'Dwyer // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*1c6e752cSArthur O'Dwyer // 7*1c6e752cSArthur O'Dwyer //===----------------------------------------------------------------------===// 8*1c6e752cSArthur O'Dwyer 9*1c6e752cSArthur O'Dwyer // UNSUPPORTED: c++03, c++11, c++14, c++17 10*1c6e752cSArthur O'Dwyer // UNSUPPORTED: msvc 11*1c6e752cSArthur O'Dwyer 12*1c6e752cSArthur O'Dwyer // std::ranges::begin 13*1c6e752cSArthur O'Dwyer // std::ranges::cbegin 14*1c6e752cSArthur O'Dwyer // Test the fix for https://llvm.org/PR54100 15*1c6e752cSArthur O'Dwyer 16*1c6e752cSArthur O'Dwyer #include <ranges> 17*1c6e752cSArthur O'Dwyer #include <cassert> 18*1c6e752cSArthur O'Dwyer 19*1c6e752cSArthur O'Dwyer #include "test_macros.h" 20*1c6e752cSArthur O'Dwyer 21*1c6e752cSArthur O'Dwyer struct A { 22*1c6e752cSArthur O'Dwyer int m[0]; 23*1c6e752cSArthur O'Dwyer }; 24*1c6e752cSArthur O'Dwyer static_assert(sizeof(A) == 0); // an extension supported by GCC and Clang 25*1c6e752cSArthur O'Dwyer main(int,char **)26*1c6e752cSArthur O'Dwyerint main(int, char**) 27*1c6e752cSArthur O'Dwyer { 28*1c6e752cSArthur O'Dwyer A a[10]; 29*1c6e752cSArthur O'Dwyer std::same_as<A*> auto p = std::ranges::begin(a); 30*1c6e752cSArthur O'Dwyer assert(p == a); 31*1c6e752cSArthur O'Dwyer std::same_as<const A*> auto cp = std::ranges::cbegin(a); 32*1c6e752cSArthur O'Dwyer assert(cp == a); 33*1c6e752cSArthur O'Dwyer 34*1c6e752cSArthur O'Dwyer return 0; 35*1c6e752cSArthur O'Dwyer } 36