Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/lib/check_compliance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,25 @@ namespace contractverify
RETURN_IF_FALSE(checkTemplSpec(fwdDecl.templateSpecification().value(), stateStructName, analysisData));
return true;
}

bool checkEnum(const cppast::CppEnum& enumDecl, AnalysisData& analysisData)
{
analysisData.additionalScopePrefixes.push_back(enumDecl.name());

if (!enumDecl.name().empty() && !enumDecl.underlyingType().empty())
{
RETURN_IF_FALSE(isTypeAllowed(enumDecl.underlyingType(), analysisData.additionalScopePrefixes));

if (isTypeAllowedAsIO(enumDecl.underlyingType(), analysisData))
{
std::vector<std::string> scopedName = analysisData.scopeNames;
scopedName.push_back(enumDecl.name());
analysisData.additionalInputOutputTypes.push_back(std::move(scopedName));
}
}

return true;
}

} // namespace

Expand Down Expand Up @@ -198,8 +217,7 @@ namespace contractverify
return true;

case cppast::CppEntityType::ENUM:
analysisData.additionalScopePrefixes.push_back(static_cast<const cppast::CppEnum&>(entity).name());
return true;
return checkEnum(static_cast<const cppast::CppEnum&>(entity), analysisData);

case cppast::CppEntityType::MACRO_CALL:
// macro arguments? but we are anyways restricted to the known macros
Expand Down
4 changes: 4 additions & 0 deletions test/contract_verify_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ namespace contractverify
"test_ok_oracles.h",
"Oracles"
},
{
"test_ok_input_output_enum_class_uint8.h",
"InputOutputEnumClassUint8"
},
};

FailureTestInfo failureTestInfos[] =
Expand Down
16 changes: 16 additions & 0 deletions test/testfiles/test_ok_input_output_enum_class_uint8.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using namespace QPI;

struct TESTCON : public ContractBase
{
public:
enum class EAuctionType : uint8
{
English = 0,
Dutch = 1,
};

struct GetAuction_output
{
EAuctionType auctionType;
};
};
Loading