Skip to content

Commit

Permalink
[flang] Add conversions from EnumSet<Attr> to Attrs
Browse files Browse the repository at this point in the history
This allows operations from EnumSet (e.g. `operator&`) to work as expected.

Original-commit: flang-compiler/f18@c8b8b74
Reviewed-on: flang-compiler/f18#675
  • Loading branch information
tskeith committed Aug 23, 2019
1 parent 5e65aaa commit a03a043
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 3 additions & 1 deletion flang/lib/semantics/attr.h
@@ -1,4 +1,4 @@
// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
// Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,6 +36,8 @@ class Attrs : public common::EnumSet<Attr, Attr_enumSize> {

public:
using enumSetType::enumSetType;
Attrs(const enumSetType &attrs) : enumSetType(attrs) {}
Attrs(enumSetType &&attrs) : enumSetType(std::move(attrs)) {}
constexpr bool HasAny(const Attrs &x) const { return !(*this & x).none(); }
constexpr bool HasAll(const Attrs &x) const { return (~*this & x).none(); }
// Internal error if any of these attributes are not in allowed.
Expand Down
3 changes: 1 addition & 2 deletions flang/lib/semantics/mod-file.cc
Expand Up @@ -288,8 +288,7 @@ void ModFileWriter::PutSubprogram(const Symbol &symbol) {
bindAttrs.set(Attr::BIND_C, true);
attrs.set(Attr::BIND_C, false);
}
Attrs prefixAttrs{subprogramPrefixAttrs};
prefixAttrs &= attrs;
Attrs prefixAttrs{subprogramPrefixAttrs & attrs};
// emit any non-prefix attributes in an attribute statement
attrs &= ~subprogramPrefixAttrs;
std::stringstream ss;
Expand Down
3 changes: 1 addition & 2 deletions flang/lib/semantics/resolve-names.cc
Expand Up @@ -1999,8 +1999,7 @@ static void ConvertToUseError(

void ModuleVisitor::AddUse(
const SourceName &location, Symbol &localSymbol, const Symbol &useSymbol) {
localSymbol.attrs() = useSymbol.attrs();
localSymbol.attrs() &= ~Attrs{Attr::PUBLIC, Attr::PRIVATE};
localSymbol.attrs() = useSymbol.attrs() & ~Attrs{Attr::PUBLIC, Attr::PRIVATE};
localSymbol.flags() = useSymbol.flags();
if (auto *useDetails{localSymbol.detailsIf<UseDetails>()}) {
const Symbol &ultimate{localSymbol.GetUltimate()};
Expand Down

0 comments on commit a03a043

Please sign in to comment.