1// Copyright 2024 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/synchronization/lock.h" 9 10namespace base { 11 12class SynchronizedInt { 13public: 14 void ResetWithoutCheckingAutolock() { 15 AutoTryLock maybe(lock); 16 value = 0; // expected-error {{writing variable 'value' requires holding mutex 'lock' exclusively}} 17 } 18 19private: 20 Lock lock; 21 int value GUARDED_BY(lock) = 0; 22}; 23 24} // namespace base 25