Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / utilities / memory / util.smartptr / util.smartptr.shared / util.smartptr.shared.obs / op_arrow.verify.cpp
blob09fd98cec2ca87807599269fa33e2b4d885c6ae5
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // <memory>
11 // UNSUPPORTED: c++03, c++11, c++14
13 // shared_ptr
15 // element_type& operator[](ptrdiff_t i) const;
17 #include "test_macros.h"
19 #include <memory>
20 #include <cassert>
22 struct Foo {
23 void call() {}
26 int main(int, char**) {
27 // Check that we get a static assertion when we try to use the bracket
28 // operator on shared_ptr<T> when T is not an array type.
29 const std::shared_ptr<Foo[]> p1;
30 (void)p1->call(); // expected-error@*:* {{std::shared_ptr<T>::operator-> is only valid when T is not an array type.}}
31 const std::shared_ptr<Foo[4]> p2;
32 (void)p2->call(); // expected-error@*:* {{std::shared_ptr<T>::operator-> is only valid when T is not an array type.}}
33 return 0;