Skip to content

Commit

Permalink
Merge pull request #40384 from dotnet/merges/release/dev16.4-to-relea…
Browse files Browse the repository at this point in the history
…se/dev16.4-vs-deps

Merge release/dev16.4 to release/dev16.4-vs-deps
  • Loading branch information
msftbot[bot] committed Dec 14, 2019
2 parents c4e5d13 + 0ca43e5 commit 1650460
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6480,7 +6480,7 @@ private StatementSyntax ParseStatementNoDeclaration(bool allowAnyExpression)
}
else
{
return this.ParseLocalDeclarationStatement(parseAwaitKeyword());
return this.ParseLocalDeclarationStatement(parseAwaitKeyword(MessageID.None));
}
}
else if (this.IsPossibleLabeledStatement())
Expand Down Expand Up @@ -6523,11 +6523,11 @@ bool isPossibleAwaitUsing()
this.PeekToken(1).Kind == SyntaxKind.UsingKeyword;
}

SyntaxToken parseAwaitKeyword(MessageID? feature = null)
SyntaxToken parseAwaitKeyword(MessageID feature)
{
Debug.Assert(this.CurrentToken.ContextualKind == SyntaxKind.AwaitKeyword);
SyntaxToken awaitToken = this.EatContextualToken(SyntaxKind.AwaitKeyword);
return feature.HasValue ? CheckFeatureAvailability(awaitToken, feature.GetValueOrDefault()) : awaitToken;
return feature != MessageID.None ? CheckFeatureAvailability(awaitToken, feature) : awaitToken;
}
}

Expand Down
96 changes: 93 additions & 3 deletions src/Compilers/CSharp/Test/Emit/Emit/EndToEndTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

using Roslyn.Test.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
Expand Down Expand Up @@ -43,6 +40,54 @@ private static void RunInThread(Action action)
}
}

private static void RunTest(int expectedDepth, Action<int> runTest)
{
if (runTestAndCatch(expectedDepth))
{
return;
}

int minDepth = 0;
int maxDepth = expectedDepth;
int actualDepth;
while (true)
{
int depth = (maxDepth - minDepth) / 2 + minDepth;
if (depth <= minDepth)
{
actualDepth = minDepth;
break;
}
if (depth >= maxDepth)
{
actualDepth = maxDepth;
break;
}
if (runTestAndCatch(depth))
{
minDepth = depth;
}
else
{
maxDepth = depth;
}
}
Assert.Equal(expectedDepth, actualDepth);

bool runTestAndCatch(int depth)
{
try
{
runTest(depth);
return true;
}
catch (Exception)
{
return false;
}
}
}

// This test is a canary attempting to make sure that we don't regress the # of fluent calls that
// the compiler can handle.
[WorkItem(16669, "https://github.com/dotnet/roslyn/issues/16669")]
Expand Down Expand Up @@ -175,5 +220,50 @@ public static void Main(string[] args)
});
}
}

[ConditionalFact(typeof(WindowsOnly))]
public void NestedIfStatements()
{
int nestingLevel = (ExecutionConditionUtil.Architecture, ExecutionConditionUtil.Configuration) switch
{
(ExecutionArchitecture.x86, ExecutionConfiguration.Debug) => 310,
(ExecutionArchitecture.x86, ExecutionConfiguration.Release) => 1650,
(ExecutionArchitecture.x64, ExecutionConfiguration.Debug) => 200,
(ExecutionArchitecture.x64, ExecutionConfiguration.Release) => 780,
_ => throw new Exception($"Unexpected configuration {ExecutionConditionUtil.Architecture} {ExecutionConditionUtil.Configuration}")
};

RunTest(nestingLevel, runTest);

static void runTest(int nestingLevel)
{
var builder = new StringBuilder();
builder.AppendLine(
@"class Program
{
static bool F(int i) => true;
static void Main()
{");
for (int i = 0; i < nestingLevel; i++)
{
builder.AppendLine(
$@" if (F({i}))
{{");
}
for (int i = 0; i < nestingLevel; i++)
{
builder.AppendLine(" }");
}
builder.AppendLine(
@" }
}");
var source = builder.ToString();
RunInThread(() =>
{
var comp = CreateCompilation(source);
comp.VerifyDiagnostics();
});
}
}
}
}

0 comments on commit 1650460

Please sign in to comment.