Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaaaa08d

Browse files
ForNeVeRKevinRansom
authored andcommitted
Remove unnecessary warnings for LayoutKind.Auto and Sequential (#3365)
*fsharp/fslang-suggestions#596: remove unnecessary warningAccording to ECMA-335, only LayoutKind.Explicit may produceunverifiable code. This commit removes warnings for other LayoutKinds.*fsharp/fslang-suggestions#596: fix review issues
1 parent49b2c32 commitaaaa08d

File tree

8 files changed

+28
-30
lines changed

8 files changed

+28
-30
lines changed

‎src/fsharp/TypeChecker.fs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15035,7 +15035,7 @@ module EstablishTypeDefinitionCores =
1503515035
let hasMeasureableAttr = HasFSharpAttribute cenv.g cenv.g.attrib_MeasureableAttribute attrs
1503615036
let hasCLIMutable = HasFSharpAttribute cenv.g cenv.g.attrib_CLIMutableAttribute attrs
1503715037

15038-
lethasStructLayoutAttr =HasFSharpAttribute cenv.g cenv.g.attrib_StructLayoutAttribute attrs
15038+
letstructLayoutAttr =TryFindFSharpInt32Attribute cenv.g cenv.g.attrib_StructLayoutAttribute attrs
1503915039
let hasAllowNullLiteralAttr = TryFindFSharpBoolAttribute cenv.g cenv.g.attrib_AllowNullLiteralAttribute attrs = Some(true)
1504015040

1504115041
if hasAbstractAttr then
@@ -15056,13 +15056,17 @@ module EstablishTypeDefinitionCores =
1505615056

1505715057

1505815058
let structLayoutAttributeCheck(allowed) =
15059-
if hasStructLayoutAttr then
15059+
let explicitKind = int32 System.Runtime.InteropServices.LayoutKind.Explicit
15060+
match structLayoutAttr with
15061+
| Some kind ->
1506015062
if allowed then
15061-
warning(PossibleUnverifiableCode(m))
15063+
if kind = explicitKind then
15064+
warning(PossibleUnverifiableCode(m))
1506215065
elif thisTyconRef.Typars(m).Length > 0 then
1506315066
errorR (Error(FSComp.SR.tcGenericTypesCannotHaveStructLayout(),m))
1506415067
else
1506515068
errorR (Error(FSComp.SR.tcOnlyStructsCanHaveStructLayout(),m))
15069+
| None -> ()
1506615070

1506715071
let hiddenReprChecks(hasRepr) =
1506815072
structLayoutAttributeCheck(false)

‎tests/fsharp/typecheck/sigs/neg06.bsl‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ neg06.fs(215,10,215,18): typecheck error FS0954: This type definition involves a
117117

118118
neg06.fs(223,13,223,21): typecheck error FS0039: The valueor constructor 'BadType3' isnot defined.
119119

120-
neg06.fs(294,10,294,12): typecheck error FS0009: Uses of this construct may resultin the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9'or '#nowarn"9"'.
121-
122-
neg06.fs(298,10,298,12): typecheck error FS0009: Uses of this construct may resultin the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9'or '#nowarn"9"'.
120+
neg06.fs(300,10,300,12): typecheck error FS0009: Uses of this construct may resultin the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9'or '#nowarn"9"'.
123121

124122
neg06.fs(304,10,304,12): typecheck error FS0937: Only structsand classes without primary constructors may be given the 'StructLayout' attribute
125123

‎tests/fsharp/typecheck/sigs/neg06.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,6 @@ end
283283

284284

285285

286-
287-
288286

289287

290288

@@ -298,6 +296,8 @@ module PositiveTests =
298296
typeX2=
299297
abstractM :unit->'a
300298

299+
[<System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Explicit)>]
300+
typeX1={ r:int}
301301

302302
moduleNegativeTests=
303303
[<System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)>]
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
// #Regression #Conformance #DeclarationElements #Attributes
1+
// #Regression #Conformance #DeclarationElements #Attributes
22
// Regression: FSB 4014
33
// Need to tighten up our imlementation of StructLayout.Sequential.
4-
//<Expects id="FS0009" span="(10,10-10,12)" status="warning">Uses of this construct may result in the generation of unverifiable \.NET IL code\. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'\.</Expects>
54

6-
modulePositiveTests=
5+
modulePositiveTests=
76

87
[<System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)>]
98
[<AbstractClass>]
10-
typeP2=
9+
typeP2=
1110
abstractM :unit->'a
12-
11+
1312
exit0
1413

1514

Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
// #Regression #Conformance #DeclarationElements #Attributes
1+
// #Regression #Conformance #DeclarationElements #Attributes
22
// Regression: FSB 4014
33
// Need to tighten up our imlementation of StructLayout.Sequential.
4-
//<Expects id="FS0009" span="(9,10-9,12)" status="warning">Uses of this construct may result in the generation of unverifiable \.NET IL code\. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'\.</Expects>
54

6-
modulePositiveTests=
5+
modulePositiveTests=
76

87
[<System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)>]
9-
typeP4=
8+
typeP4=
109
memberthis.M=1
1110
new()={}
12-
11+
1312
exit0
1413

1514

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
// #Regression #Conformance #DeclarationElements #Attributes
1+
// #Regression #Conformance #DeclarationElements #Attributes
22
// Regression: FSB 4014
33
// Need to tighten up our imlementation of StructLayout.Sequential.
4-
//<Expects id="FS0009" span="(9,10-9,12)" status="warning">Uses of this construct may result in the generation of unverifiable \.NET IL code\. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'\.</Expects>
54

6-
modulePositiveTests=
5+
modulePositiveTests=
76

87
[<System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)>]
9-
typeP3=
8+
typeP3=
109
memberthis.M=1
11-
10+
1211
exit0
1312

1413

‎tests/fsharpqa/Source/Conformance/DeclarationElements/CustomAttributes/Basic/W_StructLayoutSequentialPos_Record.fs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// #Regression #Conformance #DeclarationElements #Attributes
1+
// #Regression #Conformance #DeclarationElements #Attributes
22
// Regression: FSB 4014
33
// Need to tighten up our imlementation of StructLayout.Sequential.
4-
//<Expects id="FS0009" span="(9,10-9,12)" status="warning">Uses of this construct may result in the generation of unverifiable \.NET IL code\. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'\.</Expects>
54

6-
modulePositiveTests=
5+
modulePositiveTests=
76

87
[<System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)>]
98
typeP1={ r:int option; name:string}

‎tests/fsharpqa/Source/Conformance/DeclarationElements/CustomAttributes/Basic/env.lst‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
SOURCE=E_AttributeTargetSpecifications.fs# E_AttributeTargetSpecifications.fs
2727
SOURCE=W_StructLayoutExplicit01.fs SCFLAGS="--test:ErrorRanges" PEVER="/Exp_Fail"# W_StructLayoutExplicit01.fs
2828
SOURCE=ParamArrayAttrUsage.fs # ParamArrayAttrUsage.fs
29-
SOURCE=W_StructLayoutSequentialPos_Record.fs SCFLAGS="--test:ErrorRanges"# W_StructLayoutSequentialPos_Record.fs
30-
SOURCE=W_StructLayoutSequentialPos_AbstractClass.fs SCFLAGS="--test:ErrorRanges"# W_StructLayoutSequentialPos_AbstractClass.fs
31-
SOURCE=W_StructLayoutSequentialPos_ClassnoCtr.fs SCFLAGS="--test:ErrorRanges"# W_StructLayoutSequentialPos_ClassnoCtr.fs
32-
SOURCE=W_StructLayoutSequentialPos_ClassExpliCtr.fs SCFLAGS="--test:ErrorRanges"# E_StructLayoutSequential.fs
29+
SOURCE=W_StructLayoutSequentialPos_Record.fs SCFLAGS="--test:ErrorRanges --warnaserror+"# W_StructLayoutSequentialPos_Record.fs
30+
SOURCE=W_StructLayoutSequentialPos_AbstractClass.fs SCFLAGS="--test:ErrorRanges --warnaserror+"# W_StructLayoutSequentialPos_AbstractClass.fs
31+
SOURCE=W_StructLayoutSequentialPos_ClassnoCtr.fs SCFLAGS="--test:ErrorRanges --warnaserror+"# W_StructLayoutSequentialPos_ClassnoCtr.fs
32+
SOURCE=W_StructLayoutSequentialPos_ClassExpliCtr.fs SCFLAGS="--test:ErrorRanges --warnaserror+"# E_StructLayoutSequential.fs
3333
SOURCE=StructLayoutSequentialPos_Exception.fs# StructLayoutSequentialPos_Exception.fs
3434
SOURCE=E_StructLayoutSequentialNeg_Interface.fs SCFLAGS="--test:ErrorRanges"# E_StructLayoutSequentialNeg_Interface.fs
3535
SOURCE=E_StructLayoutSequentialNeg_AbstractClass.fs SCFLAGS="--test:ErrorRanges"# E_StructLayoutSequentialNeg_AbstractClass.fs

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp