提交 b0c39b53 编写于 作者: R Rikki Gibson

Fix sizeof error location

上级 80721b45
......@@ -1136,7 +1136,7 @@ private BoundExpression BindSizeOf(SizeOfExpressionSyntax node, DiagnosticBag di
{
if (type.IsManagedType)
{
diagnostics.Add(ErrorCode.ERR_ManagedAddr, typeSyntax.Location, type);
diagnostics.Add(ErrorCode.ERR_ManagedAddr, node.Location, type);
typeHasErrors = true;
}
else if (type.GetArity() != 0)
......@@ -1145,7 +1145,7 @@ private BoundExpression BindSizeOf(SizeOfExpressionSyntax node, DiagnosticBag di
if (unsupported)
{
// PROTOTYPE
MessageID.IDS_FeatureUnmanagedGenericStructs.CheckFeatureAvailability(Compilation.LanguageVersion, diagnostics, typeSyntax.Location);
MessageID.IDS_FeatureUnmanagedGenericStructs.CheckFeatureAvailability(Compilation.LanguageVersion, diagnostics, node.Location);
typeHasErrors = true;
}
}
......
......@@ -3776,9 +3776,9 @@ public static unsafe void Test()
";
CreateCompilation(code, options: TestOptions.UnsafeReleaseDll, parseOptions: TestOptions.Regular7_3)
.VerifyDiagnostics(
// (8,27): error CS8370: Feature 'unmanaged generic structs' is not available in C# 7.3. Please use language version 8.0 or greater.
// (8,20): error CS8370: Feature 'unmanaged generic structs' is not available in C# 7.3. Please use language version 8.0 or greater.
// var size = sizeof(MyStruct<int>);
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7_3, "MyStruct<int>").WithArguments("unmanaged generic structs", "8.0").WithLocation(8, 27)
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7_3, "sizeof(MyStruct<int>)").WithArguments("unmanaged generic structs", "8.0").WithLocation(8, 20)
);
}
......@@ -3798,9 +3798,9 @@ public static unsafe void Test()
";
CreateCompilation(code, options: TestOptions.UnsafeReleaseDll, parseOptions: TestOptions.Regular7_3)
.VerifyDiagnostics(
// (8,27): error CS8370: Feature 'unmanaged generic structs' is not available in C# 7.3. Please use language version 8.0 or greater.
// var size = sizeof(MyStruct<int>);
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7_3, "MyStruct<int>").WithArguments("unmanaged generic structs", "8.0").WithLocation(8, 27)
// (8,19): error CS8370: Feature 'unmanaged generic structs' is not available in C# 7.3. Please use language version 8.0 or greater.
// var arr = stackalloc[] { new MyStruct<int>() };
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7_3, "stackalloc[] { new MyStruct<int>() }").WithArguments("unmanaged generic structs", "8.0").WithLocation(8, 19)
);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册