tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

attributes_test.cc (1373B)


      1 // Copyright 2025 The Abseil Authors
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //     https://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 #include "absl/base/attributes.h"
     16 
     17 #include "gtest/gtest.h"
     18 #include "absl/base/config.h"
     19 
     20 namespace {
     21 
     22 TEST(Attributes, RequireExplicitInit) {
     23  struct Agg {
     24    int f1;
     25    int f2 ABSL_REQUIRE_EXPLICIT_INIT;
     26  };
     27  Agg good1 ABSL_ATTRIBUTE_UNUSED = {1, 2};
     28 #if ABSL_INTERNAL_CPLUSPLUS_LANG >= 202002L
     29  Agg good2 ABSL_ATTRIBUTE_UNUSED(1, 2);
     30 #endif
     31  Agg good3 ABSL_ATTRIBUTE_UNUSED{1, 2};
     32  Agg good4 ABSL_ATTRIBUTE_UNUSED = {1, 2};
     33  Agg good5 ABSL_ATTRIBUTE_UNUSED = Agg{1, 2};
     34  Agg good6[1] ABSL_ATTRIBUTE_UNUSED = {{1, 2}};
     35  Agg good7[1] ABSL_ATTRIBUTE_UNUSED = {Agg{1, 2}};
     36  union {
     37    Agg agg;
     38  } good8 ABSL_ATTRIBUTE_UNUSED = {{1, 2}};
     39  constexpr Agg good9 ABSL_ATTRIBUTE_UNUSED = {1, 2};
     40  constexpr Agg good10 ABSL_ATTRIBUTE_UNUSED{1, 2};
     41 }
     42 
     43 }  // namespace