Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release/dev16.4 to release/dev16.4-vs-deps #40384

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
}
}
}
}