Package Kit/Launch Server: avoid/ignore use of requires keyword

In C++20 `requires` is a reserved keyword. GCC13 warns against its use. This
change removes the use of the keyword in our own code, and ignores it in the
external 'libsolv' code.

Change-Id: I3319d20c0a3fdad89630683cdff5ea3b17f04e99
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6647
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Niels Sascha Reedijk 2023-06-24 19:14:22 +01:00 committed by Adrien Destugues
parent 7345ce9a9e
commit 5140a1bb94
5 changed files with 17 additions and 12 deletions

View File

@ -312,9 +312,9 @@ public:
printf("\n");
}
void PrintRequires(const BPackageResolvableExpression& requires) const
void PrintRequires(const BPackageResolvableExpression& require) const
{
_PrintResolvableExpression("requires", requires);
_PrintResolvableExpression("requires", require);
}
void PrintSupplements(const BPackageResolvableExpression& supplements)

View File

@ -912,10 +912,10 @@ BPackageInfo::ClearRequiresList()
status_t
BPackageInfo::AddRequires(const BPackageResolvableExpression& requires)
BPackageInfo::AddRequires(const BPackageResolvableExpression& packageRequires)
{
BPackageResolvableExpression* newRequires
= new (std::nothrow) BPackageResolvableExpression(requires);
= new (std::nothrow) BPackageResolvableExpression(packageRequires);
if (newRequires == NULL)
return B_NO_MEMORY;

View File

@ -726,9 +726,9 @@ BPackageManager::_FindBasePackage(const PackageList& packages,
BPackageResolvableExpression* basePackage = NULL;
int32 count = info.RequiresList().CountItems();
for (int32 i = 0; i < count; i++) {
BPackageResolvableExpression* requires = info.RequiresList().ItemAt(i);
if (requires->Name() == info.BasePackage()) {
basePackage = requires;
BPackageResolvableExpression* require = info.RequiresList().ItemAt(i);
if (require->Name() == info.BasePackage()) {
basePackage = require;
break;
}
}

View File

@ -28,6 +28,11 @@ for architectureObject in [ MultiArchSubDirSetup ] {
be [ TargetLibstdc++ ]
;
if $(TARGET_PACKAGING_ARCH) != x86_gcc2 {
# External headers use the C++20 reserved keyword `requires`
ObjectC++Flags LibsolvSolver.cpp : -Wno-error=c++20-compat ;
}
Includes [ FGristFiles LibsolvSolver.cpp ]
: [ BuildFeatureAttribute libsolv : headers ] ;
}

View File

@ -254,15 +254,15 @@ Job::Init(const Finder& finder, std::set<BString>& dependencies)
// Check dependencies
for (int32 index = 0; index < Requirements().CountStrings(); index++) {
const BString& requires = Requirements().StringAt(index);
if (dependencies.find(requires) != dependencies.end()) {
const BString& requirement = Requirements().StringAt(index);
if (dependencies.find(requirement) != dependencies.end()) {
// Found a cyclic dependency
// TODO: log error
return fInitStatus = B_ERROR;
}
dependencies.insert(requires);
dependencies.insert(requirement);
Job* dependency = finder.FindJob(requires);
Job* dependency = finder.FindJob(requirement);
if (dependency != NULL) {
std::set<BString> subDependencies = dependencies;
@ -274,7 +274,7 @@ Job::Init(const Finder& finder, std::set<BString>& dependencies)
fInitStatus = _AddRequirement(dependency);
} else {
::Target* target = finder.FindTarget(requires);
::Target* target = finder.FindTarget(requirement);
if (target != NULL)
fInitStatus = _AddRequirement(dependency);
else {