summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceParser.cpp
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2018-05-02 09:42:11 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-05-02 09:42:11 -0700
commit932c44d3297c94646ac7b0a24dc923f18c9e2fe9 (patch)
tree028178b16ef9166592c7c277fca23ae43d1327a3 /tools/aapt2/ResourceParser.cpp
parent83d84d2f454feac9bf3f95ae873a47623c8f1b74 (diff)
parentf4c089dd905fab6bccd83285581ab9ee074d8a42 (diff)
Merge "AAPT2: Fixed id parsing error" into pi-dev
am: f4c089dd90 Change-Id: I81147ee8629edc98ba19565083c09d7dce8e6bf7
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 19c6c3107e7c..7f48544c0ae4 100644
--- a/tools/aapt2/ResourceParser.cpp
+++ b/tools/aapt2/ResourceParser.cpp
@@ -598,10 +598,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");