Skip to content

Commit

Permalink
[Compiler] Changed 9118 from Error to Warning
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertvanderHulst committed May 27, 2023
1 parent 0685511 commit f1095aa
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion XSharp/src/Compiler/XSharpCodeAnalysis/ErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2087,7 +2087,7 @@ internal enum ErrorCode
ERR_ColonForTypeOrNs = 9115,
WRN_NullPszForStringArgument = 9116,
WRN_ConversionFromNilNotSupported = 9117,
ERR_AllParametersMustBeTyped = 9118,
WRN_ParameterMustBeTyped = 9118,

// XPP dialect Error messages
ERR_XPPMultipleInheritance = 9200,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ public static bool IsWarning(ErrorCode code)
case ErrorCode.WRN_FoxUnsupportedClause:
case ErrorCode.WRN_NullPszForStringArgument:
case ErrorCode.WRN_ConversionFromNilNotSupported:
case ErrorCode.WRN_ParameterMustBeTyped:
return true;
default:
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2704,10 +2704,6 @@ private AttributeSyntax EncodeDefaultParameter(XP.ExpressionContext initexpr, XP
}
}
}
if (datatype == null)
{
return null;
}
}
if (initexpr is XP.PrefixExpressionContext)
{
Expand All @@ -2730,6 +2726,7 @@ private AttributeSyntax EncodeDefaultParameter(XP.ExpressionContext initexpr, XP
switch (token.Type)
{
case XP.NIL:
if (datatype != null)
{
bool Ok;
Ok = datatype is XP.SimpleDatatypeContext sdtc1 && sdtc1.TypeName.Start.Type == XP.USUAL;
Expand Down Expand Up @@ -2778,7 +2775,6 @@ private AttributeSyntax EncodeDefaultParameter(XP.ExpressionContext initexpr, XP
case XP.NULL_CODEBLOCK:
return MakeDefaultParameter(GenerateLiteralNull(), zero); // 0 = regular .Net Value
case XP.INT_CONST:
var ts = datatype.Get<TypeSyntax>();
text = token.Text;
switch (text[text.Length - 1])
{
Expand Down Expand Up @@ -2814,6 +2810,7 @@ private AttributeSyntax EncodeDefaultParameter(XP.ExpressionContext initexpr, XP
expr1 = GenerateLiteral(Convert.ToDouble(iValue));
break;
default:
var ts = datatype.Get<TypeSyntax>();
if (sdtc.TypeName.NativeType != null)
expr1 = MakeCastTo(ts, expr1);
break;
Expand Down Expand Up @@ -3463,8 +3460,10 @@ protected void Check4ClipperCC(XP.IMemberContext context, IList<XP.ParameterCont
context.Data.MustBeVoid = true;
}
}
string convention = "STRICT";
if (Convention != null)
{
convention = Convention.Text;
context.Data.HasClipperCallingConvention = (Convention.Type == XP.CLIPPER);
hasConvention = true;
}
Expand All @@ -3474,12 +3473,13 @@ protected void Check4ClipperCC(XP.IMemberContext context, IList<XP.ParameterCont
// Function Foo or Function Foo() without convention
if (paramCount == 0 && !hasConvention)
{
context.Data.HasClipperCallingConvention = _options.HasOption(CompilerOption.ClipperCallingConvention, (XSharpParserRuleContext)context, PragmaOptions) && !isEntryPoint;
context.Data.HasClipperCallingConvention =
_options.HasOption(CompilerOption.ClipperCallingConvention, (XSharpParserRuleContext)context, PragmaOptions) && !isEntryPoint;
}
if (paramCount > 0)
{
bool bHasTypedParameter = false;
foreach (XP.ParameterContext par in parameters)
var bHasTypedParameter = false;
foreach (var par in parameters)
{
if (par.Type != null || par.Self != null)
{
Expand All @@ -3492,16 +3492,17 @@ protected void Check4ClipperCC(XP.IMemberContext context, IList<XP.ParameterCont
var last = parameters.Last();
if (last.Type == null && last.Ellipsis == null)
{
_parseErrors.Add(new ParseErrorData(last, ErrorCode.ERR_AllParametersMustBeTyped));
_parseErrors.Add(new ParseErrorData(last, ErrorCode.WRN_ParameterMustBeTyped, last.Id.GetText(), convention));
}
}
else
else if (hasConvention && !context.Data.HasClipperCallingConvention)
{
if (hasConvention && !context.Data.HasClipperCallingConvention)
// no typed parameters and not clipper.
// Warning for each of the parameters
foreach (var par in parameters)
{
_parseErrors.Add(new ParseErrorData(context.Params._Params.First(), ErrorCode.ERR_AllParametersMustBeTyped));
_parseErrors.Add(new ParseErrorData(par, ErrorCode.WRN_ParameterMustBeTyped, par.Id.GetText(), convention));
}

}
context.Data.HasTypedParameter = bHasTypedParameter;
if (!context.Data.HasClipperCallingConvention && !isEntryPoint && !hasConvention && _options.HasOption(CompilerOption.UntypedAllowed, (XSharpParserRuleContext)context, PragmaOptions))
Expand Down
4 changes: 2 additions & 2 deletions XSharp/src/Compiler/XSharpCodeAnalysis/XSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -7691,8 +7691,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="WRN_ConversionFromNilNotSupported" xml:space="preserve">
<value>A conversion from NIL to '{0}' is not supported and may have unwanted results.</value>
</data>
<data name="ERR_AllParametersMustBeTyped" xml:space="preserve">
<value>All parameters must be typed.</value>
<data name="WRN_ParameterMustBeTyped" xml:space="preserve">
<value>Untyped parameter '{0}' and '{1}' calling convention, assuming 'USUAL' type.</value>
</data>
</root>

0 comments on commit f1095aa

Please sign in to comment.