mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
A version of this macro is present in most code-bases. The use of this macro must satisfy two requirements: 1: If reached, the process must be terminated in all runtime modes and at all optimization levels. 2: If the compiler requires a value to be returned from the function, encountering this macro should not make the compiler insist on a return value (since the process is about to die anyway). We used to have a version of this macro that wasn't widely used and didn't satisfy the two requirements. I have removed the same and another unused macro in fml/logging.h Fixes https://github.com/flutter/flutter/issues/68164.
33 lines
876 B
C++
33 lines
876 B
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "flutter/fml/logging.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
namespace fml {
|
|
namespace testing {
|
|
|
|
int UnreachableScopeWithoutReturnDoesNotMakeCompilerMad() {
|
|
KillProcess();
|
|
// return 0; <--- Missing but compiler is fine.
|
|
}
|
|
|
|
int UnreachableScopeWithMacroWithoutReturnDoesNotMakeCompilerMad() {
|
|
FML_UNREACHABLE();
|
|
// return 0; <--- Missing but compiler is fine.
|
|
}
|
|
|
|
TEST(LoggingTest, UnreachableKillProcess) {
|
|
::testing::FLAGS_gtest_death_test_style = "threadsafe";
|
|
ASSERT_DEATH(KillProcess(), "");
|
|
}
|
|
|
|
TEST(LoggingTest, UnreachableKillProcessWithMacro) {
|
|
::testing::FLAGS_gtest_death_test_style = "threadsafe";
|
|
ASSERT_DEATH({ FML_UNREACHABLE(); }, "");
|
|
}
|
|
|
|
} // namespace testing
|
|
} // namespace fml
|