xref: /aosp_15_r20/external/cronet/base/task/task_traits_nocompile.nc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1// Copyright 2017 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// This is a "No Compile Test" suite.
6// http://dev.chromium.org/developers/testing/no-compile-tests
7
8#include "base/task/task_traits.h"
9
10namespace base {
11
12constexpr TaskTraits traits = {MayBlock(), MayBlock()};  // expected-error {{constexpr variable 'traits' must be initialized by a constant expression}}
13                                                         // expected-error@base/traits_bag.h:* {{The traits bag contains multiple traits of the same type.}}
14
15constexpr TaskTraits traits2 = {WithBaseSyncPrimitives(),   // expected-error {{constexpr variable 'traits2' must be initialized by a constant expression}}
16                                WithBaseSyncPrimitives()};  // expected-error@base/traits_bag.h:* {{The traits bag contains multiple traits of the same type.}}
17
18constexpr TaskTraits traits3 = {TaskPriority::BEST_EFFORT,     // expected-error {{constexpr variable 'traits3' must be initialized by a constant expression}}
19                                TaskPriority::USER_BLOCKING};  // expected-error@base/traits_bag.h:* {{The traits bag contains multiple traits of the same type.}}
20                                                               // expected-error@*:* {{type occurs more than once in type list}}
21
22// Note: the three repetitions of "The traits bag contains multiple traits of
23// the same type." is *not* an error. Writing this really does cause three
24// occurrences of the same error message!
25constexpr TaskTraits traits4 = {TaskShutdownBehavior::BLOCK_SHUTDOWN,   // expected-error {{constexpr variable 'traits4' must be initialized by a constant expression}}
26                                TaskShutdownBehavior::BLOCK_SHUTDOWN};  // expected-error@base/traits_bag.h:* {{The traits bag contains multiple traits of the same type.}}
27                                                                        // expected-error@base/traits_bag.h:* {{The traits bag contains multiple traits of the same type.}}
28                                                                        // expected-error@*:* {{type occurs more than once in type list}}
29                                                                        // expected-error@base/traits_bag.h:* {{The traits bag contains multiple traits of the same type.}}
30
31constexpr TaskTraits traits5 = {TaskShutdownBehavior::BLOCK_SHUTDOWN,         // expected-error {{constexpr variable 'traits5' must be initialized by a constant expression}}
32                                MayBlock(),                                   // expected-error@base/traits_bag.h:* {{The traits bag contains multiple traits of the same type.}}
33                                TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN};  // expected-error@*:* {{type occurs more than once in type list}}
34
35constexpr TaskTraits traits6 = {TaskShutdownBehavior::BLOCK_SHUTDOWN, true};  // expected-error {{no matching constructor for initialization of 'const TaskTraits'}}
36
37}  // namespace base
38