diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index bdddd9717da..eeece1cb86c 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -501,6 +501,7 @@ if (is_win) { default_warning_flags += [ # Permanent. "/wd4091", # typedef warning from dbghelp.h + "/wd4722", # destructor never returns # Investigate. "/wd4312", # int to pointer of greater size conversion. diff --git a/runtime/bin/console_posix.cc b/runtime/bin/console_posix.cc index 61fd677dd77..af28e153e6c 100644 --- a/runtime/bin/console_posix.cc +++ b/runtime/bin/console_posix.cc @@ -88,5 +88,5 @@ void Console::RestoreConfig() { } // namespace bin } // namespace dart -#endif // defined(HOST_OS_LINUX) || defined(HOST_OS_MACOS) || \ +#endif // defined(HOST_OS_LINUX) || defined(HOST_OS_MACOS) || // defined(HOST_OS_ANDROID) || defined(HOST_OS_FUCHSIA) diff --git a/runtime/bin/run_vm_tests.cc b/runtime/bin/run_vm_tests.cc index b89697800f0..9d08b5dca09 100644 --- a/runtime/bin/run_vm_tests.cc +++ b/runtime/bin/run_vm_tests.cc @@ -297,7 +297,7 @@ static int Main(int argc, const char** argv) { OS::PrintErr("No tests matched: %s\n", run_filter); return 1; } - if (DynamicAssertionHelper::failed()) { + if (Expect::failed()) { return 255; } return 0; diff --git a/runtime/platform/assert.cc b/runtime/platform/assert.cc index fb7cc8876d4..262548eed19 100644 --- a/runtime/platform/assert.cc +++ b/runtime/platform/assert.cc @@ -10,9 +10,9 @@ namespace dart { -bool DynamicAssertionHelper::failed_ = false; +bool Expect::failed_ = false; -void DynamicAssertionHelper::Fail(const char* format, ...) { +void DynamicAssertionHelper::Print(const char* format, va_list arguments) { // Take only the last 1KB of the file name if it is longer. const intptr_t file_len = strlen(file_); const intptr_t file_offset = (file_len > (1 * KB)) ? file_len - (1 * KB) : 0; @@ -25,22 +25,32 @@ void DynamicAssertionHelper::Fail(const char* format, ...) { snprintf(buffer, sizeof(buffer), "%s: %d: error: ", file, line_); // Print the error message into the buffer. - va_list arguments; - va_start(arguments, format); vsnprintf(buffer + file_and_line_length, sizeof(buffer) - file_and_line_length, format, arguments); - va_end(arguments); // Print the buffer on stderr and/or syslog. OS::PrintErr("%s\n", buffer); +} - // In case of failed assertions, abort right away. Otherwise, wait - // until the program is exiting before producing a non-zero exit +void Assert::Fail(const char* format, ...) { + va_list arguments; + va_start(arguments, format); + Print(format, arguments); + va_end(arguments); + + // Abort right away. + NOT_IN_PRODUCT(Dart_DumpNativeStackTrace(NULL)); + OS::Abort(); +} + +void Expect::Fail(const char* format, ...) { + va_list arguments; + va_start(arguments, format); + Print(format, arguments); + va_end(arguments); + + // Wait until the program is exiting before producing a non-zero exit // code through abort. - if (kind_ == ASSERT) { - NOT_IN_PRODUCT(Dart_DumpNativeStackTrace(NULL)); - OS::Abort(); - } failed_ = true; } diff --git a/runtime/platform/assert.h b/runtime/platform/assert.h index 1b01b736b10..48d1443c443 100644 --- a/runtime/platform/assert.h +++ b/runtime/platform/assert.h @@ -26,15 +26,34 @@ namespace dart { class DynamicAssertionHelper { public: - enum Kind { ASSERT, EXPECT }; + DynamicAssertionHelper(const char* file, int line) + : file_(file), line_(line) {} - DynamicAssertionHelper(const char* file, int line, Kind kind) - : file_(file), line_(line), kind_(kind) {} + protected: + void Print(const char* format, va_list arguments); + + const char* const file_; + const int line_; + + DISALLOW_IMPLICIT_CONSTRUCTORS(DynamicAssertionHelper); +}; + +class Assert : public DynamicAssertionHelper { + public: + Assert(const char* file, int line) : DynamicAssertionHelper(file, line) {} + + DART_NORETURN void Fail(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); + + template + T NotNull(const T p); +}; + +class Expect : public DynamicAssertionHelper { + public: + Expect(const char* file, int line) : DynamicAssertionHelper(file, line) {} void Fail(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); - static bool failed() { return failed_; } - #if defined(TESTING) template void Equals(const E& expected, const A& actual); @@ -65,38 +84,29 @@ class DynamicAssertionHelper { template void GreaterEqual(const E& left, const A& right); -#endif template T NotNull(const T p); +#endif + + static bool failed() { return failed_; } private: static bool failed_; - - const char* const file_; - const int line_; - const Kind kind_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(DynamicAssertionHelper); }; -class Assert : public DynamicAssertionHelper { - public: - Assert(const char* file, int line) - : DynamicAssertionHelper(file, line, ASSERT) {} -}; - -class Expect : public DynamicAssertionHelper { - public: - Expect(const char* file, int line) - : DynamicAssertionHelper(file, line, EXPECT) {} -}; +template +T Assert::NotNull(const T p) { + if (p != NULL) return p; + Fail("expected: not NULL, found NULL"); + return NULL; +} #if defined(TESTING) // Only allow the expensive (with respect to code size) assertions // in testing code. template -void DynamicAssertionHelper::Equals(const E& expected, const A& actual) { +void Expect::Equals(const E& expected, const A& actual) { if (actual == expected) return; std::ostringstream ess, ass; ess << expected; @@ -106,7 +116,7 @@ void DynamicAssertionHelper::Equals(const E& expected, const A& actual) { } template -void DynamicAssertionHelper::NotEquals(const E& not_expected, const A& actual) { +void Expect::NotEquals(const E& not_expected, const A& actual) { if (actual != not_expected) return; std::ostringstream ness; ness << not_expected; @@ -115,9 +125,7 @@ void DynamicAssertionHelper::NotEquals(const E& not_expected, const A& actual) { } template -void DynamicAssertionHelper::FloatEquals(const E& expected, - const A& actual, - const T& tol) { +void Expect::FloatEquals(const E& expected, const A& actual, const T& tol) { if (((expected - tol) <= actual) && (actual <= (expected + tol))) { return; } @@ -131,8 +139,8 @@ void DynamicAssertionHelper::FloatEquals(const E& expected, } template -NO_SANITIZE_MEMORY void DynamicAssertionHelper::StringEquals(const E& expected, - const A& actual) { +NO_SANITIZE_MEMORY void Expect::StringEquals(const E& expected, + const A& actual) { std::ostringstream ess, ass; ess << expected; ass << actual; @@ -142,8 +150,8 @@ NO_SANITIZE_MEMORY void DynamicAssertionHelper::StringEquals(const E& expected, } template -NO_SANITIZE_MEMORY void DynamicAssertionHelper::IsSubstring(const E& needle, - const A& haystack) { +NO_SANITIZE_MEMORY void Expect::IsSubstring(const E& needle, + const A& haystack) { std::ostringstream ess, ass; ess << needle; ass << haystack; @@ -154,9 +162,8 @@ NO_SANITIZE_MEMORY void DynamicAssertionHelper::IsSubstring(const E& needle, } template -NO_SANITIZE_MEMORY void DynamicAssertionHelper::IsNotSubstring( - const E& needle, - const A& haystack) { +NO_SANITIZE_MEMORY void Expect::IsNotSubstring(const E& needle, + const A& haystack) { std::ostringstream ess, ass; ess << needle; ass << haystack; @@ -167,7 +174,7 @@ NO_SANITIZE_MEMORY void DynamicAssertionHelper::IsNotSubstring( } template -void DynamicAssertionHelper::LessThan(const E& left, const A& right) { +void Expect::LessThan(const E& left, const A& right) { if (left < right) return; std::ostringstream ess, ass; ess << left; @@ -177,7 +184,7 @@ void DynamicAssertionHelper::LessThan(const E& left, const A& right) { } template -void DynamicAssertionHelper::LessEqual(const E& left, const A& right) { +void Expect::LessEqual(const E& left, const A& right) { if (left <= right) return; std::ostringstream ess, ass; ess << left; @@ -187,7 +194,7 @@ void DynamicAssertionHelper::LessEqual(const E& left, const A& right) { } template -void DynamicAssertionHelper::GreaterThan(const E& left, const A& right) { +void Expect::GreaterThan(const E& left, const A& right) { if (left > right) return; std::ostringstream ess, ass; ess << left; @@ -197,7 +204,7 @@ void DynamicAssertionHelper::GreaterThan(const E& left, const A& right) { } template -void DynamicAssertionHelper::GreaterEqual(const E& left, const A& right) { +void Expect::GreaterEqual(const E& left, const A& right) { if (left >= right) return; std::ostringstream ess, ass; ess << left; @@ -205,14 +212,14 @@ void DynamicAssertionHelper::GreaterEqual(const E& left, const A& right) { std::string es = ess.str(), as = ass.str(); Fail("expected: %s >= %s", es.c_str(), as.c_str()); } -#endif template -T DynamicAssertionHelper::NotNull(const T p) { +T Expect::NotNull(const T p) { if (p != NULL) return p; Fail("expected: not NULL, found NULL"); return NULL; } +#endif } // namespace dart diff --git a/runtime/platform/utils.cc b/runtime/platform/utils.cc index c53af65eb9a..205cafc9f46 100644 --- a/runtime/platform/utils.cc +++ b/runtime/platform/utils.cc @@ -78,8 +78,10 @@ uint32_t Utils::StringHash(const char* data, int length) { switch (size) { case 3: hash ^= cursor[2] << 16; + /* Falls through. */ case 2: hash ^= cursor[1] << 8; + /* Falls through. */ case 1: hash ^= cursor[0]; hash *= M; diff --git a/runtime/vm/ast.cc b/runtime/vm/ast.cc index e7e74bc7f30..08def4b46ad 100644 --- a/runtime/vm/ast.cc +++ b/runtime/vm/ast.cc @@ -314,7 +314,7 @@ bool BinaryOpNode::IsPotentiallyConst() const { this->right()->AsLiteralNode()->literal().IsNull()) { return false; } - // Fall-through intentional. + /* Falls through */ case Token::kADD: case Token::kSUB: case Token::kMUL: @@ -353,7 +353,7 @@ const Instance* BinaryOpNode::EvalConstExpr() const { if (left_val->IsString()) { return right_val->IsString() ? left_val : NULL; } - // Fall-through intentional. + /* Falls through */ case Token::kSUB: case Token::kMUL: case Token::kDIV: diff --git a/runtime/vm/compiler/backend/il.h b/runtime/vm/compiler/backend/il.h index 62ebc72e621..2fee1fcd7bb 100644 --- a/runtime/vm/compiler/backend/il.h +++ b/runtime/vm/compiler/backend/il.h @@ -3263,7 +3263,10 @@ class InstanceCallInstr : public TemplateDartCall<0> { CompileType* result_type() const { return result_type_; } intptr_t result_cid() const { - return (result_type_ != NULL) ? result_type_->ToCid() : kDynamicCid; + if (result_type_ == NULL) { + return kDynamicCid; + } + return result_type_->ToCid(); } PRINT_OPERANDS_TO_SUPPORT @@ -3759,7 +3762,10 @@ class StaticCallInstr : public TemplateDartCall<0> { CompileType* result_type() const { return result_type_; } intptr_t result_cid() const { - return (result_type_ != NULL) ? result_type_->ToCid() : kDynamicCid; + if (result_type_ == NULL) { + return kDynamicCid; + } + return result_type_->ToCid(); } bool is_known_list_constructor() const { return is_known_list_constructor_; } diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc index 943119a2077..9d3d8898138 100644 --- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc +++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc @@ -38,43 +38,55 @@ void FunctionNodeHelper::ReadUntilExcluding(Field field) { ASSERT(tag == kFunctionNode); if (++next_read_ == field) return; } + /* Falls through */ case kPosition: position_ = helper_->ReadPosition(); // read position. if (++next_read_ == field) return; + /* Falls through */ case kEndPosition: end_position_ = helper_->ReadPosition(); // read end position. if (++next_read_ == field) return; + /* Falls through */ case kAsyncMarker: async_marker_ = static_cast(helper_->ReadByte()); if (++next_read_ == field) return; + /* Falls through */ case kDartAsyncMarker: dart_async_marker_ = static_cast( helper_->ReadByte()); // read dart async marker. if (++next_read_ == field) return; + /* Falls through */ case kTypeParameters: helper_->SkipTypeParametersList(); // read type parameters. if (++next_read_ == field) return; + /* Falls through */ case kTotalParameterCount: total_parameter_count_ = helper_->ReadUInt(); // read total parameter count. if (++next_read_ == field) return; + /* Falls through */ case kRequiredParameterCount: required_parameter_count_ = helper_->ReadUInt(); // read required parameter count. if (++next_read_ == field) return; + /* Falls through */ case kPositionalParameters: helper_->SkipListOfVariableDeclarations(); // read positionals. if (++next_read_ == field) return; + /* Falls through */ case kNamedParameters: helper_->SkipListOfVariableDeclarations(); // read named. if (++next_read_ == field) return; + /* Falls through */ case kReturnType: helper_->SkipDartType(); // read return type. if (++next_read_ == field) return; + /* Falls through */ case kBody: if (helper_->ReadTag() == kSomething) helper_->SkipStatement(); // read body. if (++next_read_ == field) return; + /* Falls through */ case kEnd: return; } @@ -114,25 +126,32 @@ void VariableDeclarationHelper::ReadUntilExcluding(Field field) { case kPosition: position_ = helper_->ReadPosition(); // read position. if (++next_read_ == field) return; + /* Falls through */ case kEqualPosition: equals_position_ = helper_->ReadPosition(); // read equals position. if (++next_read_ == field) return; + /* Falls through */ case kAnnotations: helper_->SkipListOfExpressions(); // read annotations. if (++next_read_ == field) return; + /* Falls through */ case kFlags: flags_ = helper_->ReadFlags(); if (++next_read_ == field) return; + /* Falls through */ case kNameIndex: name_index_ = helper_->ReadStringReference(); // read name index. if (++next_read_ == field) return; + /* Falls through */ case kType: helper_->SkipDartType(); // read type. if (++next_read_ == field) return; + /* Falls through */ case kInitializer: if (helper_->ReadTag() == kSomething) helper_->SkipExpression(); // read initializer. if (++next_read_ == field) return; + /* Falls through */ case kEnd: return; } @@ -156,28 +175,35 @@ void FieldHelper::ReadUntilExcluding(Field field, ASSERT(tag == kField); if (++next_read_ == field) return; } + /* Falls through */ case kCanonicalName: canonical_name_ = helper_->ReadCanonicalNameReference(); // read canonical_name. if (++next_read_ == field) return; + /* Falls through */ case kSourceUriIndex: source_uri_index_ = helper_->ReadUInt(); // read source_uri_index. helper_->set_current_script_id(source_uri_index_); if (++next_read_ == field) return; + /* Falls through */ case kPosition: position_ = helper_->ReadPosition(false); // read position. helper_->RecordTokenPosition(position_); if (++next_read_ == field) return; + /* Falls through */ case kEndPosition: end_position_ = helper_->ReadPosition(false); // read end position. helper_->RecordTokenPosition(end_position_); if (++next_read_ == field) return; + /* Falls through */ case kFlags: flags_ = helper_->ReadFlags(); if (++next_read_ == field) return; + /* Falls through */ case kName: helper_->SkipName(); // read name. if (++next_read_ == field) return; + /* Falls through */ case kAnnotations: { annotation_count_ = helper_->ReadListLength(); // read list length. for (intptr_t i = 0; i < annotation_count_; ++i) { @@ -185,9 +211,11 @@ void FieldHelper::ReadUntilExcluding(Field field, } if (++next_read_ == field) return; } + /* Falls through */ case kType: helper_->SkipDartType(); // read type. if (++next_read_ == field) return; + /* Falls through */ case kInitializer: if (helper_->ReadTag() == kSomething) { if (detect_function_literal_initializer && @@ -207,6 +235,7 @@ void FieldHelper::ReadUntilExcluding(Field field, helper_->SkipExpression(); // read initializer. } if (++next_read_ == field) return; + /* Falls through */ case kEnd: return; } @@ -222,31 +251,39 @@ void ProcedureHelper::ReadUntilExcluding(Field field) { ASSERT(tag == kProcedure); if (++next_read_ == field) return; } + /* Falls through */ case kCanonicalName: canonical_name_ = helper_->ReadCanonicalNameReference(); // read canonical_name. if (++next_read_ == field) return; + /* Falls through */ case kSourceUriIndex: source_uri_index_ = helper_->ReadUInt(); // read source_uri_index. helper_->set_current_script_id(source_uri_index_); if (++next_read_ == field) return; + /* Falls through */ case kPosition: position_ = helper_->ReadPosition(false); // read position. helper_->RecordTokenPosition(position_); if (++next_read_ == field) return; + /* Falls through */ case kEndPosition: end_position_ = helper_->ReadPosition(false); // read end position. helper_->RecordTokenPosition(end_position_); if (++next_read_ == field) return; + /* Falls through */ case kKind: kind_ = static_cast(helper_->ReadByte()); if (++next_read_ == field) return; + /* Falls through */ case kFlags: flags_ = helper_->ReadFlags(); if (++next_read_ == field) return; + /* Falls through */ case kName: helper_->SkipName(); // read name. if (++next_read_ == field) return; + /* Falls through */ case kAnnotations: { annotation_count_ = helper_->ReadListLength(); // read list length. for (intptr_t i = 0; i < annotation_count_; ++i) { @@ -254,20 +291,24 @@ void ProcedureHelper::ReadUntilExcluding(Field field) { } if (++next_read_ == field) return; } + /* Falls through */ case kForwardingStubSuperTarget: if (helper_->ReadTag() == kSomething) { forwarding_stub_super_target_ = helper_->ReadCanonicalNameReference(); } if (++next_read_ == field) return; + /* Falls through */ case kForwardingStubInterfaceTarget: if (helper_->ReadTag() == kSomething) { helper_->ReadCanonicalNameReference(); } if (++next_read_ == field) return; + /* Falls through */ case kFunction: if (helper_->ReadTag() == kSomething) helper_->SkipFunctionNode(); // read function node. if (++next_read_ == field) return; + /* Falls through */ case kEnd: return; } @@ -283,28 +324,35 @@ void ConstructorHelper::ReadUntilExcluding(Field field) { ASSERT(tag == kConstructor); if (++next_read_ == field) return; } + /* Falls through */ case kCanonicalName: canonical_name_ = helper_->ReadCanonicalNameReference(); // read canonical_name. if (++next_read_ == field) return; + /* Falls through */ case kSourceUriIndex: source_uri_index_ = helper_->ReadUInt(); // read source_uri_index. helper_->set_current_script_id(source_uri_index_); if (++next_read_ == field) return; + /* Falls through */ case kPosition: position_ = helper_->ReadPosition(); // read position. helper_->RecordTokenPosition(position_); if (++next_read_ == field) return; + /* Falls through */ case kEndPosition: end_position_ = helper_->ReadPosition(); // read end position. helper_->RecordTokenPosition(end_position_); if (++next_read_ == field) return; + /* Falls through */ case kFlags: flags_ = helper_->ReadFlags(); if (++next_read_ == field) return; + /* Falls through */ case kName: helper_->SkipName(); // read name. if (++next_read_ == field) return; + /* Falls through */ case kAnnotations: { annotation_count_ = helper_->ReadListLength(); // read list length. for (intptr_t i = 0; i < annotation_count_; ++i) { @@ -312,9 +360,11 @@ void ConstructorHelper::ReadUntilExcluding(Field field) { } if (++next_read_ == field) return; } + /* Falls through */ case kFunction: helper_->SkipFunctionNode(); // read function. if (++next_read_ == field) return; + /* Falls through */ case kInitializers: { intptr_t list_length = helper_->ReadListLength(); // read initializers list length. @@ -323,6 +373,7 @@ void ConstructorHelper::ReadUntilExcluding(Field field) { } if (++next_read_ == field) return; } + /* Falls through */ case kEnd: return; } @@ -338,28 +389,35 @@ void ClassHelper::ReadUntilExcluding(Field field) { ASSERT(tag == kClass); if (++next_read_ == field) return; } + /* Falls through */ case kCanonicalName: canonical_name_ = helper_->ReadCanonicalNameReference(); // read canonical_name. if (++next_read_ == field) return; + /* Falls through */ case kSourceUriIndex: source_uri_index_ = helper_->ReadUInt(); // read source_uri_index. helper_->set_current_script_id(source_uri_index_); if (++next_read_ == field) return; + /* Falls through */ case kPosition: position_ = helper_->ReadPosition(false); // read position. helper_->RecordTokenPosition(position_); if (++next_read_ == field) return; + /* Falls through */ case kEndPosition: end_position_ = helper_->ReadPosition(); // read end position. helper_->RecordTokenPosition(end_position_); if (++next_read_ == field) return; + /* Falls through */ case kFlags: flags_ = helper_->ReadFlags(); // read flags. if (++next_read_ == field) return; + /* Falls through */ case kNameIndex: name_index_ = helper_->ReadStringReference(); // read name index. if (++next_read_ == field) return; + /* Falls through */ case kAnnotations: { annotation_count_ = helper_->ReadListLength(); // read list length. for (intptr_t i = 0; i < annotation_count_; ++i) { @@ -367,9 +425,11 @@ void ClassHelper::ReadUntilExcluding(Field field) { } if (++next_read_ == field) return; } + /* Falls through */ case kTypeParameters: helper_->SkipTypeParametersList(); // read type parameters. if (++next_read_ == field) return; + /* Falls through */ case kSuperClass: { Tag type_tag = helper_->ReadTag(); // read super class type (part 1). if (type_tag == kSomething) { @@ -377,6 +437,7 @@ void ClassHelper::ReadUntilExcluding(Field field) { } if (++next_read_ == field) return; } + /* Falls through */ case kMixinType: { Tag type_tag = helper_->ReadTag(); // read mixin type (part 1). if (type_tag == kSomething) { @@ -384,9 +445,11 @@ void ClassHelper::ReadUntilExcluding(Field field) { } if (++next_read_ == field) return; } + /* Falls through */ case kImplementedClasses: helper_->SkipListOfDartTypes(); // read implemented_classes. if (++next_read_ == field) return; + /* Falls through */ case kFields: { intptr_t list_length = helper_->ReadListLength(); // read fields list length. @@ -396,6 +459,7 @@ void ClassHelper::ReadUntilExcluding(Field field) { } if (++next_read_ == field) return; } + /* Falls through */ case kConstructors: { intptr_t list_length = helper_->ReadListLength(); // read constructors list length. @@ -406,6 +470,7 @@ void ClassHelper::ReadUntilExcluding(Field field) { } if (++next_read_ == field) return; } + /* Falls through */ case kProcedures: { procedure_count_ = helper_->ReadListLength(); // read procedures #. for (intptr_t i = 0; i < procedure_count_; i++) { @@ -415,6 +480,7 @@ void ClassHelper::ReadUntilExcluding(Field field) { } if (++next_read_ == field) return; } + /* Falls through */ case kClassIndex: // Read class index. for (intptr_t i = 0; i < procedure_count_; ++i) { @@ -423,6 +489,7 @@ void ClassHelper::ReadUntilExcluding(Field field) { helper_->reader_.ReadUInt32(); helper_->reader_.ReadUInt32(); if (++next_read_ == field) return; + /* Falls through */ case kEnd: return; } @@ -437,20 +504,25 @@ void LibraryHelper::ReadUntilExcluding(Field field) { flags_ = helper_->ReadFlags(); if (++next_read_ == field) return; } + /* Falls through */ case kCanonicalName: canonical_name_ = helper_->ReadCanonicalNameReference(); // read canonical_name. if (++next_read_ == field) return; + /* Falls through */ case kName: name_index_ = helper_->ReadStringReference(); // read name index. if (++next_read_ == field) return; + /* Falls through */ case kSourceUriIndex: source_uri_index_ = helper_->ReadUInt(); // read source_uri_index. helper_->set_current_script_id(source_uri_index_); if (++next_read_ == field) return; + /* Falls through */ case kAnnotations: helper_->SkipListOfExpressions(); // read annotations. if (++next_read_ == field) return; + /* Falls through */ case kDependencies: { intptr_t dependency_count = helper_->ReadUInt(); // read list length. for (intptr_t i = 0; i < dependency_count; ++i) { @@ -458,6 +530,7 @@ void LibraryHelper::ReadUntilExcluding(Field field) { } if (++next_read_ == field) return; } + /* Falls through */ case kAdditionalExports: { intptr_t name_count = helper_->ReadUInt(); for (intptr_t i = 0; i < name_count; ++i) { @@ -465,6 +538,7 @@ void LibraryHelper::ReadUntilExcluding(Field field) { } if (++next_read_ == field) return; } + /* Falls through */ case kParts: { intptr_t part_count = helper_->ReadUInt(); // read list length. for (intptr_t i = 0; i < part_count; ++i) { @@ -472,6 +546,7 @@ void LibraryHelper::ReadUntilExcluding(Field field) { } if (++next_read_ == field) return; } + /* Falls through */ case kTypedefs: { intptr_t typedef_count = helper_->ReadListLength(); // read list length. for (intptr_t i = 0; i < typedef_count; i++) { @@ -479,6 +554,7 @@ void LibraryHelper::ReadUntilExcluding(Field field) { } if (++next_read_ == field) return; } + /* Falls through */ case kClasses: { class_count_ = helper_->ReadListLength(); // read list length. for (intptr_t i = 0; i < class_count_; ++i) { @@ -487,6 +563,7 @@ void LibraryHelper::ReadUntilExcluding(Field field) { } if (++next_read_ == field) return; } + /* Falls through */ case kToplevelField: { intptr_t field_count = helper_->ReadListLength(); // read list length. for (intptr_t i = 0; i < field_count; ++i) { @@ -495,6 +572,7 @@ void LibraryHelper::ReadUntilExcluding(Field field) { } if (++next_read_ == field) return; } + /* Falls through */ case kToplevelProcedures: { procedure_count_ = helper_->ReadListLength(); // read list length. for (intptr_t i = 0; i < procedure_count_; ++i) { @@ -503,6 +581,7 @@ void LibraryHelper::ReadUntilExcluding(Field field) { } if (++next_read_ == field) return; } + /* Falls through */ case kLibraryIndex: // Read library index. for (intptr_t i = 0; i < class_count_; ++i) { @@ -516,6 +595,7 @@ void LibraryHelper::ReadUntilExcluding(Field field) { helper_->reader_.ReadUInt32(); helper_->reader_.ReadUInt32(); if (++next_read_ == field) return; + /* Falls through */ case kEnd: return; } @@ -530,22 +610,27 @@ void LibraryDependencyHelper::ReadUntilExcluding(Field field) { helper_->ReadPosition(); if (++next_read_ == field) return; } + /* Falls through */ case kFlags: { flags_ = helper_->ReadFlags(); if (++next_read_ == field) return; } + /* Falls through */ case kAnnotations: { helper_->SkipListOfExpressions(); if (++next_read_ == field) return; } + /* Falls through */ case kTargetLibrary: { target_library_canonical_name_ = helper_->ReadCanonicalNameReference(); if (++next_read_ == field) return; } + /* Falls through */ case kName: { name_index_ = helper_->ReadStringReference(); if (++next_read_ == field) return; } + /* Falls through */ case kCombinators: { intptr_t count = helper_->ReadListLength(); for (intptr_t i = 0; i < count; ++i) { @@ -556,6 +641,7 @@ void LibraryDependencyHelper::ReadUntilExcluding(Field field) { } if (++next_read_ == field) return; } + /* Falls through */ case kEnd: return; } @@ -5779,7 +5865,7 @@ FlowGraph* StreamingFlowGraphBuilder::BuildGraph(intptr_t kernel_offset) { return BuildGraphOfImplicitClosureFunction(function); } } - // fallthrough intended + /* Falls through */ case RawFunction::kClosureFunction: case RawFunction::kConvertedClosureFunction: { ReadUntilFunctionNode(parsed_function()); // read until function node. diff --git a/runtime/vm/object_test.cc b/runtime/vm/object_test.cc index 17eadb09ad9..31437e41285 100644 --- a/runtime/vm/object_test.cc +++ b/runtime/vm/object_test.cc @@ -3268,9 +3268,9 @@ TEST_CASE(StackTraceFormat) { const char* lib_url = isolate->use_dart_frontend() ? "file:///test-lib" : "test-lib"; - const size_t kExpectedLen = 512; - char expected[kExpectedLen]; - snprintf(expected, kExpectedLen, + const size_t kBufferSize = 1024; + char expected[kBufferSize]; + snprintf(expected, kBufferSize, "Unhandled exception:\n" "MyException\n" "#0 baz (%1$s:2:3)\n" diff --git a/runtime/vm/os.h b/runtime/vm/os.h index 1fde4dac950..94bb98d194c 100644 --- a/runtime/vm/os.h +++ b/runtime/vm/os.h @@ -120,9 +120,9 @@ class OS { // Shut down the OS class. static void Shutdown(); - static void Abort(); + static DART_NORETURN void Abort(); - static void Exit(int code); + static DART_NORETURN void Exit(int code); }; } // namespace dart diff --git a/runtime/vm/regexp_parser.cc b/runtime/vm/regexp_parser.cc index 5d10d0872ed..bd6b1e3b730 100644 --- a/runtime/vm/regexp_parser.cc +++ b/runtime/vm/regexp_parser.cc @@ -557,8 +557,8 @@ RegExpTree* RegExpParser::ParseDisjunction() { ReportError("Nothing to repeat"); UNREACHABLE(); } - // fallthrough } + /* Falls through */ default: builder->AddCharacter(current()); Advance();