Skip to content

Commit f1095aa

Browse files
[Compiler] Changed 9118 from Error to Warning
1 parent 0685511 commit f1095aa

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

XSharp/src/Compiler/XSharpCodeAnalysis/ErrorCode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,7 @@ internal enum ErrorCode
20872087
ERR_ColonForTypeOrNs = 9115,
20882088
WRN_NullPszForStringArgument = 9116,
20892089
WRN_ConversionFromNilNotSupported = 9117,
2090-
ERR_AllParametersMustBeTyped = 9118,
2090+
WRN_ParameterMustBeTyped = 9118,
20912091

20922092
// XPP dialect Error messages
20932093
ERR_XPPMultipleInheritance = 9200,

XSharp/src/Compiler/XSharpCodeAnalysis/Generated/ErrorFacts.Generated.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ public static bool IsWarning(ErrorCode code)
351351
case ErrorCode.WRN_FoxUnsupportedClause:
352352
case ErrorCode.WRN_NullPszForStringArgument:
353353
case ErrorCode.WRN_ConversionFromNilNotSupported:
354+
case ErrorCode.WRN_ParameterMustBeTyped:
354355
return true;
355356
default:
356357
return false;

XSharp/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationRT.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2704,10 +2704,6 @@ private AttributeSyntax EncodeDefaultParameter(XP.ExpressionContext initexpr, XP
27042704
}
27052705
}
27062706
}
2707-
if (datatype == null)
2708-
{
2709-
return null;
2710-
}
27112707
}
27122708
if (initexpr is XP.PrefixExpressionContext)
27132709
{
@@ -2730,6 +2726,7 @@ private AttributeSyntax EncodeDefaultParameter(XP.ExpressionContext initexpr, XP
27302726
switch (token.Type)
27312727
{
27322728
case XP.NIL:
2729+
if (datatype != null)
27332730
{
27342731
bool Ok;
27352732
Ok = datatype is XP.SimpleDatatypeContext sdtc1 && sdtc1.TypeName.Start.Type == XP.USUAL;
@@ -2778,7 +2775,6 @@ private AttributeSyntax EncodeDefaultParameter(XP.ExpressionContext initexpr, XP
27782775
case XP.NULL_CODEBLOCK:
27792776
return MakeDefaultParameter(GenerateLiteralNull(), zero); // 0 = regular .Net Value
27802777
case XP.INT_CONST:
2781-
var ts = datatype.Get<TypeSyntax>();
27822778
text = token.Text;
27832779
switch (text[text.Length - 1])
27842780
{
@@ -2814,6 +2810,7 @@ private AttributeSyntax EncodeDefaultParameter(XP.ExpressionContext initexpr, XP
28142810
expr1 = GenerateLiteral(Convert.ToDouble(iValue));
28152811
break;
28162812
default:
2813+
var ts = datatype.Get<TypeSyntax>();
28172814
if (sdtc.TypeName.NativeType != null)
28182815
expr1 = MakeCastTo(ts, expr1);
28192816
break;
@@ -3463,8 +3460,10 @@ protected void Check4ClipperCC(XP.IMemberContext context, IList<XP.ParameterCont
34633460
context.Data.MustBeVoid = true;
34643461
}
34653462
}
3463+
string convention = "STRICT";
34663464
if (Convention != null)
34673465
{
3466+
convention = Convention.Text;
34683467
context.Data.HasClipperCallingConvention = (Convention.Type == XP.CLIPPER);
34693468
hasConvention = true;
34703469
}
@@ -3474,12 +3473,13 @@ protected void Check4ClipperCC(XP.IMemberContext context, IList<XP.ParameterCont
34743473
// Function Foo or Function Foo() without convention
34753474
if (paramCount == 0 && !hasConvention)
34763475
{
3477-
context.Data.HasClipperCallingConvention = _options.HasOption(CompilerOption.ClipperCallingConvention, (XSharpParserRuleContext)context, PragmaOptions) && !isEntryPoint;
3476+
context.Data.HasClipperCallingConvention =
3477+
_options.HasOption(CompilerOption.ClipperCallingConvention, (XSharpParserRuleContext)context, PragmaOptions) && !isEntryPoint;
34783478
}
34793479
if (paramCount > 0)
34803480
{
3481-
bool bHasTypedParameter = false;
3482-
foreach (XP.ParameterContext par in parameters)
3481+
var bHasTypedParameter = false;
3482+
foreach (var par in parameters)
34833483
{
34843484
if (par.Type != null || par.Self != null)
34853485
{
@@ -3492,16 +3492,17 @@ protected void Check4ClipperCC(XP.IMemberContext context, IList<XP.ParameterCont
34923492
var last = parameters.Last();
34933493
if (last.Type == null && last.Ellipsis == null)
34943494
{
3495-
_parseErrors.Add(new ParseErrorData(last, ErrorCode.ERR_AllParametersMustBeTyped));
3495+
_parseErrors.Add(new ParseErrorData(last, ErrorCode.WRN_ParameterMustBeTyped, last.Id.GetText(), convention));
34963496
}
34973497
}
3498-
else
3498+
else if (hasConvention && !context.Data.HasClipperCallingConvention)
34993499
{
3500-
if (hasConvention && !context.Data.HasClipperCallingConvention)
3500+
// no typed parameters and not clipper.
3501+
// Warning for each of the parameters
3502+
foreach (var par in parameters)
35013503
{
3502-
_parseErrors.Add(new ParseErrorData(context.Params._Params.First(), ErrorCode.ERR_AllParametersMustBeTyped));
3504+
_parseErrors.Add(new ParseErrorData(par, ErrorCode.WRN_ParameterMustBeTyped, par.Id.GetText(), convention));
35033505
}
3504-
35053506
}
35063507
context.Data.HasTypedParameter = bHasTypedParameter;
35073508
if (!context.Data.HasClipperCallingConvention && !isEntryPoint && !hasConvention && _options.HasOption(CompilerOption.UntypedAllowed, (XSharpParserRuleContext)context, PragmaOptions))

XSharp/src/Compiler/XSharpCodeAnalysis/XSharpResources.resx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7691,8 +7691,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
76917691
<data name="WRN_ConversionFromNilNotSupported" xml:space="preserve">
76927692
<value>A conversion from NIL to '{0}' is not supported and may have unwanted results.</value>
76937693
</data>
7694-
<data name="ERR_AllParametersMustBeTyped" xml:space="preserve">
7695-
<value>All parameters must be typed.</value>
7694+
<data name="WRN_ParameterMustBeTyped" xml:space="preserve">
7695+
<value>Untyped parameter '{0}' and '{1}' calling convention, assuming 'USUAL' type.</value>
76967696
</data>
76977697
</root>
76987698

0 commit comments

Comments
 (0)