summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBrian Sullivan <briansul@microsoft.com>2019-06-19 11:18:02 -0700
committerBrian Sullivan <briansul@microsoft.com>2019-06-19 13:34:25 -0700
commitd4fd282d4b3d2190f0350a2f1f92c188f0073017 (patch)
tree7271cdd3e5c6d43f1d6a90184872d1209cedc185 /tests
parentd10701cc4d591bc89697b7bab98553305dcc9df4 (diff)
downloadcoreclr-d4fd282d4b3d2190f0350a2f1f92c188f0073017.tar.gz
coreclr-d4fd282d4b3d2190f0350a2f1f92c188f0073017.tar.bz2
coreclr-d4fd282d4b3d2190f0350a2f1f92c188f0073017.zip
Fix Issue #25134 - AssertionProp incorrectly removes cast from uint
Add additional check for the GT_UNSIGNED flag + Ran clang-format + Code review feedback, use IsUnsigned()
Diffstat (limited to 'tests')
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_25134/GitHub_25134.cs90
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_25134/GitHub_25134.csproj33
2 files changed, 123 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_25134/GitHub_25134.cs b/tests/src/JIT/Regression/JitBlue/GitHub_25134/GitHub_25134.cs
new file mode 100644
index 0000000000..e68e2b82e8
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_25134/GitHub_25134.cs
@@ -0,0 +1,90 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.CompilerServices;
+
+class Program
+{
+ static bool s_caughtException;
+ static uint s_value = int.MaxValue + 1U;
+ static int s_result = 0;
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ static int CastToIntChecked(uint value)
+ {
+ return checked((int)value);
+ }
+
+ // Testing a checked cast to Uint -- the inlining case
+ //
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static void Test1()
+ {
+ int result = CastToIntChecked(s_value);
+ s_result = result;
+ Console.WriteLine("Result is " + result);
+ }
+
+ // Testing a checked cast to Uint -- the non-inlining case
+ //
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static void Test2()
+ {
+ uint copy = 0;
+ try
+ {
+ s_caughtException = false;
+
+ copy = s_value;
+
+ int result = checked((int)copy);
+ s_result = result;
+ Console.WriteLine("Result is " + result);
+ }
+ catch (System.OverflowException ex)
+ {
+ s_caughtException = true;
+ Console.WriteLine("CORRECT: " + ex);
+ copy = 0;
+ }
+ }
+
+ static int Main()
+ {
+ bool failed = false;
+
+ try
+ {
+ Test1();
+ }
+ catch (System.OverflowException ex)
+ {
+ s_caughtException = true;
+ Console.WriteLine("CORRECT: " + ex);
+ }
+
+ if (s_caughtException == false)
+ {
+ Console.WriteLine("FAILED - Test1");
+ failed = true;
+ }
+
+ Test2();
+ if (s_caughtException == false)
+ {
+ Console.WriteLine("FAILED - Test2");
+ failed = true;
+ }
+
+ if (failed)
+ {
+ return 101;
+ }
+ else
+ {
+ return 100;
+ }
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_25134/GitHub_25134.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_25134/GitHub_25134.csproj
new file mode 100644
index 0000000000..95052d9884
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_25134/GitHub_25134.csproj
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <PropertyGroup>
+ <DebugType>None</DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>