summaryrefslogtreecommitdiffstats
path: root/libcxx/test/libcxx/diagnostics/chrono.nodiscard_extensions.compile.pass.cpp
blob: 9acb57fa05f75ccd7583f54ffbc5ba9552bd3632 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

// Check that format functions aren't marked [[nodiscard]] when
// _LIBCPP_DISABLE_NODISCARD_EXT is defined

// UNSUPPORTED: c++03, c++11, c++14, c++17
// UNSUPPORTED: no-filesystem, no-localization, no-tzdb

// XFAIL: libcpp-has-no-incomplete-tzdb
// XFAIL: availability-tzdb-missing

// <chrono>

// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_NODISCARD_EXT

#include <chrono>

#include "test_macros.h"

// These types have "private" constructors.
extern std::chrono::time_zone tz;
extern std::chrono::time_zone_link link;
extern std::chrono::leap_second leap;

void test() {
  std::chrono::tzdb_list& list = std::chrono::get_tzdb_list();
  list.front();
  list.begin();
  list.end();
  list.cbegin();
  list.cend();

  std::chrono::get_tzdb_list();
  std::chrono::get_tzdb();
  std::chrono::locate_zone("name");
  std::chrono::current_zone();
  std::chrono::remote_version();

  {
    const std::chrono::tzdb& t = list.front();
    t.locate_zone("name");
    t.current_zone();
  }

  {
    tz.name();
    operator==(tz, tz);
    operator<=>(tz, tz);
  }

  {
    link.name();
    link.target();
    operator==(link, link);
    operator<=>(link, link);
  }

  {
    leap.date();
    leap.value();
  }
}