From: Andy Ayers Date: Wed, 7 Feb 2018 00:05:00 +0000 (-0800) Subject: Add test case for contstructor devirtualization example (#16239) X-Git-Tag: accepted/tizen/unified/20190422.045933~3059 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ff1da90da40388afa547833722009ca7422c94d2;p=platform%2Fupstream%2Fcoreclr.git Add test case for contstructor devirtualization example (#16239) See #16198 for discussion. --- diff --git a/tests/src/JIT/opt/Devirtualization/constructor.cs b/tests/src/JIT/opt/Devirtualization/constructor.cs new file mode 100644 index 0000000..14deb26 --- /dev/null +++ b/tests/src/JIT/opt/Devirtualization/constructor.cs @@ -0,0 +1,40 @@ +// 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 Test +{ + static string s; + + public override string ToString() + { + return "Test"; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public Test() + { + s = ToString(); // cannot be devirtualized + } + + static int Main() + { + new Child(); + return (s == "Child" ? 100 : 0); + } +} + +class Child : Test +{ + + [MethodImpl(MethodImplOptions.NoInlining)] + public Child() { } + + public override string ToString() + { + return "Child"; + } +} diff --git a/tests/src/JIT/opt/Devirtualization/constructor.csproj b/tests/src/JIT/opt/Devirtualization/constructor.csproj new file mode 100644 index 0000000..47796bd --- /dev/null +++ b/tests/src/JIT/opt/Devirtualization/constructor.csproj @@ -0,0 +1,38 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + Properties + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + $(ProgramFiles)\Common Files\microsoft shared\VSTT .0\UITestExtensionPackages + ..\..\ + 7a9bfb7d + + + + + + + False + + + + PdbOnly + True + + + + + + + + + + \ No newline at end of file