Genex: Reform error-checking for nullary/unary expressions.

The error messages were incorrect (reporting that the expression
requires one or two parameters), and repeated.  Remove the now-unused
ZeroOrMoreParameters enum value.
This commit is contained in:
Stephen Kelly 2013-12-31 14:28:52 +01:00
parent fa651c7a19
commit 9ba47ee49b
1 changed files with 10 additions and 29 deletions

View File

@ -49,7 +49,7 @@ struct cmGeneratorExpressionNode
enum { enum {
DynamicParameters = 0, DynamicParameters = 0,
OneOrMoreParameters = -1, OneOrMoreParameters = -1,
ZeroOrMoreParameters = -2 OneOrZeroParameters = -2
}; };
virtual ~cmGeneratorExpressionNode() {} virtual ~cmGeneratorExpressionNode() {}
@ -384,7 +384,7 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
{ {
CompilerIdNode() {} CompilerIdNode() {}
virtual int NumExpectedParameters() const { return ZeroOrMoreParameters; } virtual int NumExpectedParameters() const { return OneOrZeroParameters; }
std::string EvaluateWithLanguage(const std::vector<std::string> &parameters, std::string EvaluateWithLanguage(const std::vector<std::string> &parameters,
cmGeneratorExpressionContext *context, cmGeneratorExpressionContext *context,
@ -430,12 +430,6 @@ static const struct CCompilerIdNode : public CompilerIdNode
const GeneratorExpressionContent *content, const GeneratorExpressionContent *content,
cmGeneratorExpressionDAGChecker *dagChecker) const cmGeneratorExpressionDAGChecker *dagChecker) const
{ {
if (parameters.size() != 0 && parameters.size() != 1)
{
reportError(context, content->GetOriginalExpression(),
"$<C_COMPILER_ID> expression requires one or two parameters");
return std::string();
}
if (!context->HeadTarget) if (!context->HeadTarget)
{ {
reportError(context, content->GetOriginalExpression(), reportError(context, content->GetOriginalExpression(),
@ -458,12 +452,6 @@ static const struct CXXCompilerIdNode : public CompilerIdNode
const GeneratorExpressionContent *content, const GeneratorExpressionContent *content,
cmGeneratorExpressionDAGChecker *dagChecker) const cmGeneratorExpressionDAGChecker *dagChecker) const
{ {
if (parameters.size() != 0 && parameters.size() != 1)
{
reportError(context, content->GetOriginalExpression(),
"$<CXX_COMPILER_ID> expression requires one or two parameters");
return std::string();
}
if (!context->HeadTarget) if (!context->HeadTarget)
{ {
reportError(context, content->GetOriginalExpression(), reportError(context, content->GetOriginalExpression(),
@ -481,7 +469,7 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode
{ {
CompilerVersionNode() {} CompilerVersionNode() {}
virtual int NumExpectedParameters() const { return ZeroOrMoreParameters; } virtual int NumExpectedParameters() const { return OneOrZeroParameters; }
std::string EvaluateWithLanguage(const std::vector<std::string> &parameters, std::string EvaluateWithLanguage(const std::vector<std::string> &parameters,
cmGeneratorExpressionContext *context, cmGeneratorExpressionContext *context,
@ -526,12 +514,6 @@ static const struct CCompilerVersionNode : public CompilerVersionNode
const GeneratorExpressionContent *content, const GeneratorExpressionContent *content,
cmGeneratorExpressionDAGChecker *dagChecker) const cmGeneratorExpressionDAGChecker *dagChecker) const
{ {
if (parameters.size() != 0 && parameters.size() != 1)
{
reportError(context, content->GetOriginalExpression(),
"$<C_COMPILER_VERSION> expression requires one or two parameters");
return std::string();
}
if (!context->HeadTarget) if (!context->HeadTarget)
{ {
reportError(context, content->GetOriginalExpression(), reportError(context, content->GetOriginalExpression(),
@ -554,13 +536,6 @@ static const struct CxxCompilerVersionNode : public CompilerVersionNode
const GeneratorExpressionContent *content, const GeneratorExpressionContent *content,
cmGeneratorExpressionDAGChecker *dagChecker) const cmGeneratorExpressionDAGChecker *dagChecker) const
{ {
if (parameters.size() != 0 && parameters.size() != 1)
{
reportError(context, content->GetOriginalExpression(),
"$<CXX_COMPILER_VERSION> expression requires one or two "
"parameters");
return std::string();
}
if (!context->HeadTarget) if (!context->HeadTarget)
{ {
reportError(context, content->GetOriginalExpression(), reportError(context, content->GetOriginalExpression(),
@ -579,7 +554,7 @@ struct PlatformIdNode : public cmGeneratorExpressionNode
{ {
PlatformIdNode() {} PlatformIdNode() {}
virtual int NumExpectedParameters() const { return ZeroOrMoreParameters; } virtual int NumExpectedParameters() const { return OneOrZeroParameters; }
std::string Evaluate(const std::vector<std::string> &parameters, std::string Evaluate(const std::vector<std::string> &parameters,
cmGeneratorExpressionContext *context, cmGeneratorExpressionContext *context,
@ -1822,6 +1797,12 @@ std::string GeneratorExpressionContent::EvaluateParameters(
reportError(context, this->GetOriginalExpression(), "$<" + identifier reportError(context, this->GetOriginalExpression(), "$<" + identifier
+ "> expression requires at least one parameter."); + "> expression requires at least one parameter.");
} }
if (numExpected == cmGeneratorExpressionNode::OneOrZeroParameters
&& parameters.size() > 2)
{
reportError(context, this->GetOriginalExpression(), "$<" + identifier
+ "> expression requires one or zero parameters.");
}
return std::string(); return std::string();
} }