diff options
author | Jooyung Han <jooyung@google.com> | 2021-01-07 14:12:40 +0900 |
---|---|---|
committer | Jooyung Han <jooyung@google.com> | 2021-01-07 08:16:30 +0000 |
commit | 633eab645d55bcaf9df97b126b6033529311adcb (patch) | |
tree | 8cd3fcec9f4ad7ea8563daab03475ea53a85424c /aidl_language_y.yy | |
parent | 720253dc96d6d6b48b5490d6f0dbb8e9e8bc69c6 (diff) | |
download | aidl-633eab645d55bcaf9df97b126b6033529311adcb.tar.gz |
Support annotations for 'const'
It was not supported and people use type-level annotations as a
workaround even when the annotations are meant to annotate constants.
const @Annotation... int foo = 0;
Now we can annotate constants like following.
@Annotation... const int foo = 0;
Bug: 174436374
Test: aidl_unittests
Change-Id: I5481de6ac48711765fcd7e1726003267360ba9e6
Diffstat (limited to 'aidl_language_y.yy')
-rw-r--r-- | aidl_language_y.yy | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/aidl_language_y.yy b/aidl_language_y.yy index 8273815d..64d9f437 100644 --- a/aidl_language_y.yy +++ b/aidl_language_y.yy @@ -519,11 +519,18 @@ constant_value_non_empty_list ; constant_decl - : CONST type identifier '=' const_expr ';' { - $2->SetComments($1->GetComments()); - $$ = new AidlConstantDeclaration(loc(@3), $2, $3->GetText(), $5); + : annotation_list CONST type identifier '=' const_expr ';' { + if ($1->size() > 0) { + $3->SetComments($1->begin()->GetComments()); + } else { + $3->SetComments($2->GetComments()); + } + // TODO(b/151102494) do not merge annotations. + $3->Annotate(std::move(*$1)); + $$ = new AidlConstantDeclaration(loc(@4), $3, $4->GetText(), $6); delete $1; - delete $3; + delete $2; + delete $4; } ; |