summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceParser.cpp
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2018-05-02 13:55:05 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-05-02 13:55:05 -0700
commit60f06b7770199fadddb3a5c5853c1f5232860c6a (patch)
treeb8e4193959ad52ed3015ad37fca97c76e359f4f3 /tools/aapt2/ResourceParser.cpp
parent8a88fc3db62fb9c486ab4c81d55b1ad73ca2fac1 (diff)
parent932c44d3297c94646ac7b0a24dc923f18c9e2fe9 (diff)
Merge "AAPT2: Fixed id parsing error" into pi-dev am: f4c089dd90
am: 932c44d329 Change-Id: I661784fcabac19d4d9bae137904b9282d9765d79
Diffstat (limited to 'tools/aapt2/ResourceParser.cpp')
-rw-r--r--tools/aapt2/ResourceParser.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp
index 0271d8bad37a..089c9e284570 100644
--- a/tools/aapt2/ResourceParser.cpp
+++ b/tools/aapt2/ResourceParser.cpp
@@ -601,10 +601,13 @@ bool ResourceParser::ParseResource(xml::XmlPullParser* parser,
// If no inner element exists, represent a unique identifier
out_resource->value = util::make_unique<Id>();
} else {
- // If an inner element exists, the inner element must be a reference to
- // another resource id
Reference* ref = ValueCast<Reference>(out_resource->value.get());
- if (!ref || ref->name.value().type != ResourceType::kId) {
+ if (ref && !ref->name && !ref->id) {
+ // A null reference also means there is no inner element when ids are in the form:
+ // <id name="name"/>
+ out_resource->value = util::make_unique<Id>();
+ } else if (!ref || ref->name.value().type != ResourceType::kId) {
+ // If an inner element exists, the inner element must be a reference to another resource id
diag_->Error(DiagMessage(out_resource->source)
<< "<" << parser->element_name()
<< "> inner element must either be a resource reference or empty");