Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1e13b4e9
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1e13b4e9
编写于
12月 29, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move diagnostic from parser to later phase.
上级
45273896
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
25 addition
and
17 deletion
+25
-17
src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
+9
-0
src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
+2
-11
src/Compilers/CSharp/Test/Syntax/Parsing/ParserErrorMessageTests.cs
...ers/CSharp/Test/Syntax/Parsing/ParserErrorMessageTests.cs
+13
-4
src/Compilers/CSharp/Test/Syntax/Parsing/ParsingErrorRecoveryTests.cs
...s/CSharp/Test/Syntax/Parsing/ParsingErrorRecoveryTests.cs
+1
-2
未找到文件。
src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
浏览文件 @
1e13b4e9
...
...
@@ -3371,11 +3371,20 @@ private ImmutableArray<BoundCatchBlock> BindCatchBlocks(SyntaxList<CatchClauseSy
}
var
catchBlocks
=
ArrayBuilder
<
BoundCatchBlock
>.
GetInstance
(
n
);
var
hasCatchAll
=
false
;
foreach
(
var
catchSyntax
in
catchClauses
)
{
if
(
hasCatchAll
)
{
diagnostics
.
Add
(
ErrorCode
.
ERR_TooManyCatches
,
catchSyntax
.
CatchKeyword
.
GetLocation
());
}
var
catchBinder
=
this
.
GetBinder
(
catchSyntax
);
var
catchBlock
=
catchBinder
.
BindCatchBlock
(
catchSyntax
,
catchBlocks
,
diagnostics
);
catchBlocks
.
Add
(
catchBlock
);
hasCatchAll
|=
catchSyntax
.
Declaration
==
null
&&
catchSyntax
.
Filter
==
null
;
}
return
catchBlocks
.
ToImmutableAndFree
();
}
...
...
src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
浏览文件 @
1e13b4e9
...
...
@@ -7649,7 +7649,6 @@ private TryStatementSyntax ParseTryStatement()
try
{
bool
hasEnd
=
false
;
bool
hasCatchAll
=
false
;
if
(
this
.
CurrentToken
.
Kind
==
SyntaxKind
.
CatchKeyword
)
{
...
...
@@ -7657,9 +7656,7 @@ private TryStatementSyntax ParseTryStatement()
catches
=
_pool
.
Allocate
<
CatchClauseSyntax
>();
while
(
this
.
CurrentToken
.
Kind
==
SyntaxKind
.
CatchKeyword
)
{
var
clause
=
this
.
ParseCatchClause
(
hasCatchAll
);
hasCatchAll
|=
clause
.
Declaration
==
null
&&
clause
.
Filter
==
null
;
catches
.
Add
(
clause
);
catches
.
Add
(
this
.
ParseCatchClause
());
}
}
...
...
@@ -7704,18 +7701,12 @@ private bool IsEndOfTryBlock()
||
this
.
CurrentToken
.
Kind
==
SyntaxKind
.
FinallyKeyword
;
}
private
CatchClauseSyntax
ParseCatchClause
(
bool
hasCatchAll
)
private
CatchClauseSyntax
ParseCatchClause
()
{
Debug
.
Assert
(
this
.
CurrentToken
.
Kind
==
SyntaxKind
.
CatchKeyword
);
var
@catch
=
this
.
EatToken
();
// Check for the error of catch clause following empty catch here.
if
(
hasCatchAll
)
{
@catch
=
this
.
AddError
(
@catch
,
ErrorCode
.
ERR_TooManyCatches
);
}
CatchDeclarationSyntax
decl
=
null
;
var
saveTerm
=
_termState
;
...
...
src/Compilers/CSharp/Test/Syntax/Parsing/ParserErrorMessageTests.cs
浏览文件 @
1e13b4e9
...
...
@@ -1711,10 +1711,19 @@ public static int Main()
}
"
;
ParseAndValidate
(
test
,
Diagnostic
(
ErrorCode
.
ERR_TooManyCatches
,
"catch"
),
Diagnostic
(
ErrorCode
.
ERR_TooManyCatches
,
"catch"
),
Diagnostic
(
ErrorCode
.
ERR_TooManyCatches
,
"catch"
));
CreateCompilationWithMscorlib
(
test
).
VerifyDiagnostics
(
// (16,9): error CS1017: Catch clauses cannot follow the general catch clause of a try statement
// catch (S1) {}
Diagnostic
(
ErrorCode
.
ERR_TooManyCatches
,
"catch"
).
WithLocation
(
16
,
9
),
// (17,9): error CS1017: Catch clauses cannot follow the general catch clause of a try statement
// catch (S) {}
Diagnostic
(
ErrorCode
.
ERR_TooManyCatches
,
"catch"
).
WithLocation
(
17
,
9
),
// (18,9): error CS1017: Catch clauses cannot follow the general catch clause of a try statement
// catch when (false) {}
Diagnostic
(
ErrorCode
.
ERR_TooManyCatches
,
"catch"
).
WithLocation
(
18
,
9
),
// (18,21): warning CS7095: Filter expression is a constant, consider removing the filter
// catch when (false) {}
Diagnostic
(
ErrorCode
.
WRN_FilterIsConstant
,
"false"
).
WithLocation
(
18
,
21
));
}
[
Fact
]
...
...
src/Compilers/CSharp/Test/Syntax/Parsing/ParsingErrorRecoveryTests.cs
浏览文件 @
1e13b4e9
...
...
@@ -3979,10 +3979,9 @@ public void TestCatchAfterCatchStart()
Assert
.
NotNull
(
ms
.
Body
);
Assert
.
Equal
(
1
,
ms
.
Body
.
Statements
.
Count
);
Assert
.
Equal
(
SyntaxKind
.
TryStatement
,
ms
.
Body
.
Statements
[
0
].
Kind
());
Assert
.
Equal
(
3
,
file
.
Errors
().
Length
);
Assert
.
Equal
(
2
,
file
.
Errors
().
Length
);
Assert
.
Equal
((
int
)
ErrorCode
.
ERR_LbraceExpected
,
file
.
Errors
()[
0
].
Code
);
Assert
.
Equal
((
int
)
ErrorCode
.
ERR_RbraceExpected
,
file
.
Errors
()[
1
].
Code
);
Assert
.
Equal
((
int
)
ErrorCode
.
ERR_TooManyCatches
,
file
.
Errors
()[
2
].
Code
);
}
[
Fact
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录