[flang] Change BeginAttrs to return true like BeginDecl

This is just for convenience. Any Pre function that calls BeginAttrs
must return true.

Original-commit: flang-compiler/f18@5a7bc11ba4
Reviewed-on: https://github.com/flang-compiler/f18/pull/173
Tree-same-pre-rewrite: false
This commit is contained in:
Tim Keith 2018-08-31 15:15:28 -07:00
parent f69f7ecf48
commit b8efe4bf11
1 changed files with 8 additions and 11 deletions

View File

@ -79,7 +79,7 @@ private:
// Provide Post methods to collect attributes into a member variable. // Provide Post methods to collect attributes into a member variable.
class AttrsVisitor { class AttrsVisitor {
public: public:
void BeginAttrs(); bool BeginAttrs();
Attrs GetAttrs(); Attrs GetAttrs();
Attrs EndAttrs(); Attrs EndAttrs();
void Post(const parser::LanguageBindingSpec &); void Post(const parser::LanguageBindingSpec &);
@ -762,9 +762,10 @@ void ShowImplicitRule(
// AttrsVisitor implementation // AttrsVisitor implementation
void AttrsVisitor::BeginAttrs() { bool AttrsVisitor::BeginAttrs() {
CHECK(!attrs_); CHECK(!attrs_);
attrs_ = std::make_optional<Attrs>(); attrs_ = std::make_optional<Attrs>();
return true;
} }
Attrs AttrsVisitor::GetAttrs() { Attrs AttrsVisitor::GetAttrs() {
CHECK(attrs_); CHECK(attrs_);
@ -1717,16 +1718,14 @@ void SubprogramVisitor::Post(const parser::InterfaceBody::Function &) {
} }
bool SubprogramVisitor::Pre(const parser::SubroutineStmt &stmt) { bool SubprogramVisitor::Pre(const parser::SubroutineStmt &stmt) {
BeginAttrs(); return BeginAttrs();
return true;
} }
bool SubprogramVisitor::Pre(const parser::FunctionStmt &stmt) { bool SubprogramVisitor::Pre(const parser::FunctionStmt &stmt) {
if (!subpNamesOnly_) { if (!subpNamesOnly_) {
BeginDeclTypeSpec(); BeginDeclTypeSpec();
CHECK(!funcResultName_); CHECK(!funcResultName_);
} }
BeginAttrs(); return BeginAttrs();
return true;
} }
void SubprogramVisitor::Post(const parser::SubroutineStmt &stmt) { void SubprogramVisitor::Post(const parser::SubroutineStmt &stmt) {
@ -1848,14 +1847,13 @@ Symbol *SubprogramVisitor::GetSpecificFromGeneric(const SourceName &name) {
bool DeclarationVisitor::BeginDecl() { bool DeclarationVisitor::BeginDecl() {
BeginDeclTypeSpec(); BeginDeclTypeSpec();
BeginAttrs();
BeginArraySpec(); BeginArraySpec();
return true; return BeginAttrs();
} }
void DeclarationVisitor::EndDecl() { void DeclarationVisitor::EndDecl() {
EndDeclTypeSpec(); EndDeclTypeSpec();
EndAttrs();
EndArraySpec(); EndArraySpec();
EndAttrs();
} }
bool DeclarationVisitor::CheckUseError( bool DeclarationVisitor::CheckUseError(
@ -2036,8 +2034,7 @@ void DeclarationVisitor::Post(const parser::DerivedTypeDef &x) {
derivedTypeData_.reset(); derivedTypeData_.reset();
} }
bool DeclarationVisitor::Pre(const parser::DerivedTypeStmt &x) { bool DeclarationVisitor::Pre(const parser::DerivedTypeStmt &x) {
BeginAttrs(); return BeginAttrs();
return true;
} }
void DeclarationVisitor::Post(const parser::DerivedTypeStmt &x) { void DeclarationVisitor::Post(const parser::DerivedTypeStmt &x) {
auto &name{std::get<parser::Name>(x.t).source}; auto &name{std::get<parser::Name>(x.t).source};