aboutsummaryrefslogtreecommitdiff
path: root/diagnostics.cpp
diff options
context:
space:
mode:
authorJooyung Han <jooyung@google.com>2021-02-08 11:02:48 +0900
committerTreehugger Robot <treehugger-gerrit@google.com>2021-02-10 00:47:06 +0000
commite33d67e1e7736dce62df5ad133f3c42a595009b5 (patch)
tree231374fc52c62791110ad5e8f6d89de37c348f6a /diagnostics.cpp
parent8e76eea03400118075646c6d9c30c1208f13ddc7 (diff)
downloadaidl-e33d67e1e7736dce62df5ad133f3c42a595009b5.tar.gz
Remove -Wexplicit-default
It was to check if primitives/strings/arrays have explicit default values. However, primitive types(bool, char, int...) are initialized as "zero" when explicit default is missing. This is well-defined across all backends. Strings/arrays are initialized as null in Java while non-null in other backends. But this behavior is consistent for other non-primitive types and these types have been used widely without explicit default values. Bug: 168028537 Test: aidl_unittests Change-Id: I40952bb3410907371ac4141eaef9b510e9aafa38
Diffstat (limited to 'diagnostics.cpp')
-rw-r--r--diagnostics.cpp13
1 files changed, 1 insertions, 12 deletions
diff --git a/diagnostics.cpp b/diagnostics.cpp
index b292b69c..b63ffa9e 100644
--- a/diagnostics.cpp
+++ b/diagnostics.cpp
@@ -194,18 +194,7 @@ struct DiagnoseExplicitDefault : DiagnosticsVisitor {
void CheckExplicitDefault(const AidlVariableDeclaration& v) {
if (v.IsDefaultUserSpecified()) return;
if (v.GetType().IsNullable()) return;
- if (v.GetType().IsArray()) {
- diag.Report(v.GetLocation(), DiagnosticID::explicit_default)
- << "The array field '" << v.GetName() << "' has no explicit value.";
- return;
- }
- const auto type_name = v.GetType().GetName();
- if (AidlTypenames::IsPrimitiveTypename(type_name) || type_name == "String" ||
- type_name == "CharSequence") {
- diag.Report(v.GetLocation(), DiagnosticID::explicit_default)
- << "The primitive field '" << v.GetName() << "' has no explicit value.";
- return;
- }
+ if (v.GetType().IsArray()) return;
const auto defined_type = v.GetType().GetDefinedType();
if (defined_type && defined_type->AsEnumDeclaration()) {
diag.Report(v.GetLocation(), DiagnosticID::enum_explicit_default)