Skip to content

Commit b4fd14e

Browse files
authored
Merge pull request #2248 from guwirth/close-2247
align messages with Visual Studio 2019 version 16.11 (compiler version 19.29.30100.0)
2 parents cb3afc3 + 88537e7 commit b4fd14e

File tree

5 files changed

+209
-6
lines changed

5 files changed

+209
-6
lines changed

cxx-sensors/src/main/resources/compiler-vc.xml

+149-3
Original file line numberDiff line numberDiff line change
@@ -3200,7 +3200,7 @@ Under strict ANSI compatibility (<a data-linktype="relative-path" href="https://
32003200
<name>C4407: cast between different pointer to member representations, compiler may generate incorrect code</name>
32013201
<description>
32023202
<![CDATA[
3203-
<p>An incorrect cast was detected.</p>
3203+
<p>An incorrect cast between pointer-to-member types was detected.</p>
32043204
<h2>Microsoft Documentation</h2>
32053205
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4407?view=msvc-160" target="_blank">C4407</a></p>]]>
32063206
</description>
@@ -4271,6 +4271,17 @@ Under strict ANSI compatibility (<a data-linktype="relative-path" href="https://
42714271
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c4596?view=msvc-160" target="_blank">C4596</a></p>]]>
42724272
</description>
42734273
<severity>INFO</severity>
4274+
</rule>
4275+
<rule>
4276+
<key>C4597</key>
4277+
<name>C4597: undefined behavior: offsetof applied to a member of a virtual base</name>
4278+
<description>
4279+
<![CDATA[
4280+
<p>Using <code>offsetof(T, m)</code> where <em><code>m</code></em> refers to a static data member or a member function results in C4597.</p>
4281+
<h2>Microsoft Documentation</h2>
4282+
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c4597?view=msvc-160" target="_blank">C4597</a></p>]]>
4283+
</description>
4284+
<severity>INFO</severity>
42744285
</rule>
42754286
<rule>
42764287
<key>C4600</key>
@@ -5052,6 +5063,17 @@ Under strict ANSI compatibility (<a data-linktype="relative-path" href="https://
50525063
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-c4694?view=msvc-160" target="_blank">C4694</a></p>]]>
50535064
</description>
50545065
<severity>INFO</severity>
5066+
</rule>
5067+
<rule>
5068+
<key>C4698</key>
5069+
<name>C4698: 'feature' is for evaluation purposes only and is subject to change or removal in future updates</name>
5070+
<description>
5071+
<![CDATA[
5072+
<p>WinRT APIs that are released for experimentation and feedback are decorated with the <code>Windows.Foundation.Metadata.ExperimentalAttribute</code> attribute. In Visual Studio 2017 version 15.3, the compiler produces warning C4698 for this attribute. A few APIs in previous versions of the Windows SDK have already been decorated with the attribute, and calls to these APIs now trigger this compiler warning. Newer Windows SDKs have the attribute removed from all shipped types. If you're using an older SDK, you'll need to suppress these warnings for all calls to shipped types.</p>
5073+
<h2>Microsoft Documentation</h2>
5074+
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c4698?view=msvc-160" target="_blank">C4698</a></p>]]>
5075+
</description>
5076+
<severity>INFO</severity>
50555077
</rule>
50565078
<rule>
50575079
<key>C4700</key>
@@ -5434,6 +5456,17 @@ Under strict ANSI compatibility (<a data-linktype="relative-path" href="https://
54345456
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4764?view=msvc-160" target="_blank">C4764</a></p>]]>
54355457
</description>
54365458
<severity>INFO</severity>
5459+
</rule>
5460+
<rule>
5461+
<key>C4768</key>
5462+
<name>C4768: __declspec attributes before linkage specification are ignored</name>
5463+
<description>
5464+
<![CDATA[
5465+
<p>The compiler warns if <code>__declspec(...)</code> is applied before the <code>extern "C"</code> linkage specification. Previously, the compiler would ignore the attribute, which could have runtime implications.</p>
5466+
<h2>Microsoft Documentation</h2>
5467+
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c4768?view=msvc-160" target="_blank">C4768</a></p>]]>
5468+
</description>
5469+
<severity>INFO</severity>
54375470
</rule>
54385471
<rule>
54395472
<key>C4772</key>
@@ -5709,6 +5742,17 @@ Under strict ANSI compatibility (<a data-linktype="relative-path" href="https://
57095742
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4829?view=msvc-160" target="_blank">C4829</a></p>]]>
57105743
</description>
57115744
<severity>INFO</severity>
5745+
</rule>
5746+
<rule>
5747+
<key>C4834</key>
5748+
<name>C4834: discarding return value of function with 'nodiscard' attribute</name>
5749+
<description>
5750+
<![CDATA[
5751+
<p>Starting in the C++17 Standard, the <code>[[nodiscard]]</code> attribute specifies that a function's return value isn't intended to be discarded. If a caller discards the return value, the compiler generates warning C4834.</p>
5752+
<h2>Microsoft Documentation</h2>
5753+
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c4834?view=msvc-160" target="_blank">C4834</a></p>]]>
5754+
</description>
5755+
<severity>INFO</severity>
57125756
</rule>
57135757
<rule>
57145758
<key>C4835</key>
@@ -5753,6 +5797,28 @@ Under strict ANSI compatibility (<a data-linktype="relative-path" href="https://
57535797
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4840?view=msvc-160" target="_blank">C4840</a></p>]]>
57545798
</description>
57555799
<severity>INFO</severity>
5800+
</rule>
5801+
<rule>
5802+
<key>C4841</key>
5803+
<name>C4841: non-standard extension used: compound member designator used in offsetof</name>
5804+
<description>
5805+
<![CDATA[
5806+
<p>If you use <code>offsetof(T, m)</code>, where <em><code>m</code></em> is a compound member designator, the compiler generates a warning when you compile with the <strong><code>/Wall</code></strong> option.</p>
5807+
<h2>Microsoft Documentation</h2>
5808+
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c4841?view=msvc-160" target="_blank">C4841</a></p>]]>
5809+
</description>
5810+
<severity>INFO</severity>
5811+
</rule>
5812+
<rule>
5813+
<key>C4843</key>
5814+
<name>C4843: 'type1': An exception handler of reference to array or function type is unreachable, use 'type2' instead</name>
5815+
<description>
5816+
<![CDATA[
5817+
<p>Handlers of reference to array or function type are never a match for any exception object. Starting in Visual Studio 2017 version 15.5, the compiler honors this rule and raises a level 4 warning. It also no longer matches a handler of <code>char*</code> or <code>wchar_t*</code> to a string literal when <strong><code>/Zc:strictStrings</code></strong> is used.</p>
5818+
<h2>Microsoft Documentation</h2>
5819+
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c4843?view=msvc-160" target="_blank">C4843</a></p>]]>
5820+
</description>
5821+
<severity>INFO</severity>
57565822
</rule>
57575823
<rule>
57585824
<key>C4866</key>
@@ -6326,12 +6392,23 @@ Under strict ANSI compatibility (<a data-linktype="relative-path" href="https://
63266392
</description>
63276393
<severity>INFO</severity>
63286394
</rule>
6395+
<rule>
6396+
<key>C5037</key>
6397+
<name>C5037: 'member-function': an out-of-line definition of a member of a class template cannot have default arguments</name>
6398+
<description>
6399+
<![CDATA[
6400+
<p>Default arguments aren't allowed on out-of-line definitions of member functions in template classes. The compiler issues a level 3 warning under <strong><code>/permissive</code></strong>, and an error under <a data-linktype="relative-path" href="https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-160"><code>/permissive-</code></a>.</p>
6401+
<h2>Microsoft Documentation</h2>
6402+
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5037?view=msvc-160" target="_blank">C5037</a></p>]]>
6403+
</description>
6404+
<severity>INFO</severity>
6405+
</rule>
63296406
<rule>
63306407
<key>C5038</key>
63316408
<name>C5038: data member 'member1' will be initialized after data member 'member2'</name>
63326409
<description>
63336410
<![CDATA[
6334-
<p>Class members are initialized in the order they're declared, not the order they appear in initializer lists. This warning indicates the order of initialization isn't the same as the declaration order of data members or base classes. This order can lead to undefined runtime behavior, if the initialization of one member in the list depends on the initialization of a member that's declared later.</p>
6411+
<p>Class members get initialized in the order they're declared, not the order they appear in initializer lists. The compiler warns when the initialization order isn't the same as the declaration order of data members or base classes. The order can lead to undefined runtime behavior: for example, if the initialization of one member in the list depends on the initialization of a member that's declared later.</p>
63356412
<h2>Microsoft Documentation</h2>
63366413
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5038?view=msvc-160" target="_blank">C5038</a></p>]]>
63376414
</description>
@@ -6358,6 +6435,17 @@ Under strict ANSI compatibility (<a data-linktype="relative-path" href="https://
63586435
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5046?view=msvc-160" target="_blank">C5046</a></p>]]>
63596436
</description>
63606437
<severity>INFO</severity>
6438+
</rule>
6439+
<rule>
6440+
<key>C5050</key>
6441+
<name>C5050: Possible incompatible environment while importing module 'module_name'</name>
6442+
<description>
6443+
<![CDATA[
6444+
<p>The compiler raises C5050 whenever the command-line options for modules aren't consistent between the module creation and module consumption sides.</p>
6445+
<h2>Microsoft Documentation</h2>
6446+
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5050?view=msvc-160" target="_blank">C5050</a></p>]]>
6447+
</description>
6448+
<severity>INFO</severity>
63616449
</rule>
63626450
<rule>
63636451
<key>C5105</key>
@@ -6380,6 +6468,39 @@ Under strict ANSI compatibility (<a data-linktype="relative-path" href="https://
63806468
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5208?view=msvc-160" target="_blank">C5208</a></p>]]>
63816469
</description>
63826470
<severity>INFO</severity>
6471+
</rule>
6472+
<rule>
6473+
<key>C5243</key>
6474+
<name>C5243: 'type': using incomplete class 'class-name' can cause ODR violation due to ABI limitation</name>
6475+
<description>
6476+
<![CDATA[
6477+
<p>The Microsoft C++ ABI in Visual Studio 2019 and earlier versions uses more than one kind of pointer-to-member type. These types have different sizes that depend on the inheritance model used by the class. The C++ standard allows you to declare a pointer-to-member of an incomplete class type. If you declare a variable of pointer-to-member type for an incomplete class, the compiler must use the most general representation. It can lead to a <em>one definition rule</em>, or ODR violation, since the compiler may use a smaller, more specific representation for this pointer-to-member type in other translation units where the complete class type is available.</p>
6478+
<h2>Microsoft Documentation</h2>
6479+
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5243?view=msvc-160" target="_blank">C5243</a></p>]]>
6480+
</description>
6481+
<severity>INFO</severity>
6482+
</rule>
6483+
<rule>
6484+
<key>C5247</key>
6485+
<name>C5247: section 'section-name' is reserved for C++ dynamic initialization</name>
6486+
<description>
6487+
<![CDATA[
6488+
<p>The Microsoft C++ compiler uses reserved section names for internal implementation of features such as C++ dynamic initialization. If your code creates a section with the same name as a reserved section, such as <code>.CRT$XCU</code>, it interferes with the compiler. It may prevent other dynamic initialization and cause undefined behavior.</p>
6489+
<h2>Microsoft Documentation</h2>
6490+
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5247?view=msvc-160" target="_blank">C5247</a></p>]]>
6491+
</description>
6492+
<severity>INFO</severity>
6493+
</rule>
6494+
<rule>
6495+
<key>C5248</key>
6496+
<name>C5248: section 'section-name' is reserved for C++ dynamic initialization</name>
6497+
<description>
6498+
<![CDATA[
6499+
<p>The Microsoft C++ compiler uses reserved section names for internal implementation of features such as C++ dynamic initialization. If your code inserts a variable in a reserved section, such as <code>.CRT$XCU</code>, it interferes with the compiler. Your variable isn't considered a C++ dynamic initializer. Also, its relative initialization order compared to compiler generated dynamic initializers isn't specified.</p>
6500+
<h2>Microsoft Documentation</h2>
6501+
<p><a href="https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5248?view=msvc-160" target="_blank">C5248</a></p>]]>
6502+
</description>
6503+
<severity>INFO</severity>
63836504
</rule>
63846505
<rule>
63856506
<key>C6001</key>
@@ -7857,6 +7978,19 @@ Under strict ANSI compatibility (<a data-linktype="relative-path" href="https://
78577978
<remediationFunction>LINEAR</remediationFunction>
78587979
<remediationFunctionGapMultiplier>5min</remediationFunctionGapMultiplier>
78597980
</rule>
7981+
<rule>
7982+
<key>C6389</key>
7983+
<name>C6389: MARK_INTERNAL_OR_MISSING_COMMON_DECL</name>
7984+
<description>
7985+
<![CDATA[
7986+
<p>This check is intended to help reduce the visibility of certain symbols and to modularize the code. In multi-file C++ projects, each declaration should be either local to a C++ file (part of the anonymous namespace) or declared in a common header file that's included by multiple C++ files.</p>
7987+
<h2>Microsoft Documentation</h2>
7988+
<p><a href="https://docs.microsoft.com/en-us/cpp/code-quality/c6389?view=msvc-160" target="_blank">C6389</a></p>]]>
7989+
</description>
7990+
<severity>CRITICAL</severity>
7991+
<remediationFunction>LINEAR</remediationFunction>
7992+
<remediationFunctionGapMultiplier>5min</remediationFunctionGapMultiplier>
7993+
</rule>
78607994
<rule>
78617995
<key>C6400</key>
78627996
<name>C6400: Using &lt;function name&gt; to perform a case-insensitive compare to constant string &lt;string name&gt;</name>
@@ -8696,7 +8830,7 @@ Deleting such a pointer may lead to immediate memory corruption due to double de
86968830
<name>C26409: Avoid calling new and delete explicitly, use std::make_unique&lt;T&gt; instead (r.11)</name>
86978831
<description>
86988832
<![CDATA[
8699-
<p>Even if code is clean of calls to<code>malloc()</code> and <code>free()</code>, we still suggest that you consider better options than explicit use of operators <a data-linktype="relative-path" href="https://docs.microsoft.com/en-us/cpp/cpp/new-and-delete-operators?view=msvc-160"><code>new</code> and <code>delete</code></a>.</p>
8833+
<p>Even if code is clean of calls to <code>malloc</code> and <code>free</code>, we still suggest that you consider better options than explicit use of operators <a data-linktype="relative-path" href="https://docs.microsoft.com/en-us/cpp/cpp/new-and-delete-operators?view=msvc-160"><code>new</code> and <code>delete</code></a>.</p>
87008834
<h2>Microsoft Documentation</h2>
87018835
<p><a href="https://docs.microsoft.com/en-us/cpp/code-quality/c26409?view=msvc-160" target="_blank">C26409</a></p>]]>
87028836
</description>
@@ -9155,6 +9289,18 @@ C4293 is a similar check in the Microsoft C++ compiler.</p>
91559289
</description>
91569290
<tag>core-guideline</tag>
91579291
<severity>INFO</severity>
9292+
</rule>
9293+
<rule>
9294+
<key>C26457</key>
9295+
<name>C26457: Never cast to (void) to ignore a [[nodiscard]] return value</name>
9296+
<description>
9297+
<![CDATA[
9298+
<p>Excerpt from the <a data-linktype="external" href="https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es48-avoid-casts">C++ Core Guideline for this warning</a>:</p>
9299+
<h2>Microsoft Documentation</h2>
9300+
<p><a href="https://docs.microsoft.com/en-us/cpp/code-quality/c26457?view=msvc-160" target="_blank">C26457</a></p>]]>
9301+
</description>
9302+
<tag>core-guideline</tag>
9303+
<severity>INFO</severity>
91589304
</rule>
91599305
<rule>
91609306
<key>C26460</key>

cxx-sensors/src/test/java/org/sonar/cxx/sensors/compiler/vc/CxxCompilerVcRuleRepositoryTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void createVcRulesTest() {
3838
def.define(context);
3939

4040
RulesDefinition.Repository repo = context.repository(CxxCompilerVcRuleRepository.KEY);
41-
assertThat(repo.rules()).hasSize(947);
41+
assertThat(repo.rules()).hasSize(960);
4242
}
4343

4444
}

cxx-sensors/src/tools/vc_createrules.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
# pip install beautifulsoup4
2727
# pip install selenium-requests
2828

29+
# pages contains JavaScript: script is using Firefox to create HTML pages
30+
# you have to download and install geckodriver
31+
# from https://github.com/mozilla/geckodriver/releases
32+
# to C:\Program Files\geckodriver
33+
2934
import re
3035
import sys
3136
from bs4 import BeautifulSoup
@@ -355,10 +360,10 @@ def add_template_rules(rules):
355360
Add template rule(s) to XML.
356361
"""
357362
rule_key = 'CustomRuleTemplate'
358-
rule_name = 'Template for custom Custom rules'
363+
rule_name = 'Rule template for Visual Studio custom rules'
359364
rule_severity = 'MAJOR'
360365
# pylint: disable=line-too-long
361-
rule_description = """<p>Follow these steps to make your custom Custom rules available in SonarQube:</p>
366+
rule_description = """<p>Follow these steps to make your custom rules available in SonarQube:</p>
362367
<ol>
363368
<ol>
364369
<li>Create a new rule in SonarQube by "copying" this rule template and specify the <code>CheckId</code> of your custom rule, a title, a description, and a default severity.</li>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<SchemaVersion>2.0</SchemaVersion>
6+
<ProjectGuid>{f4a3e4b0-40b1-4c37-82c8-a7c5e40c8930}</ProjectGuid>
7+
<ProjectHome />
8+
<StartupFile>vc_createrules.py</StartupFile>
9+
<SearchPath />
10+
<WorkingDirectory>.</WorkingDirectory>
11+
<OutputPath>.</OutputPath>
12+
<ProjectTypeGuids>{888888a0-9f3d-457c-b088-3a5042f75d52}</ProjectTypeGuids>
13+
<LaunchProvider>Standard Python launcher</LaunchProvider>
14+
<InterpreterId>Global|PythonCore|3.7</InterpreterId>
15+
</PropertyGroup>
16+
<PropertyGroup Condition="'$(Configuration)' == 'Debug'" />
17+
<PropertyGroup Condition="'$(Configuration)' == 'Release'" />
18+
<PropertyGroup>
19+
<VisualStudioVersion Condition=" '$(VisualStudioVersion)' == '' ">10.0</VisualStudioVersion>
20+
</PropertyGroup>
21+
<ItemGroup>
22+
<Compile Include="utils_createrules.py" />
23+
<Compile Include="vc_createrules.py" />
24+
</ItemGroup>
25+
<ItemGroup>
26+
<InterpreterReference Include="Global|PythonCore|3.7" />
27+
</ItemGroup>
28+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
29+
</Project>
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31313.79
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "vc_createrules", "vc_createrules.pyproj", "{F4A3E4B0-40B1-4C37-82C8-A7C5E40C8930}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{F4A3E4B0-40B1-4C37-82C8-A7C5E40C8930}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{F4A3E4B0-40B1-4C37-82C8-A7C5E40C8930}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
GlobalSection(ExtensibilityGlobals) = postSolution
21+
SolutionGuid = {F2AFAAF8-13A0-48E6-928C-53E41986A107}
22+
EndGlobalSection
23+
EndGlobal

0 commit comments

Comments
 (0)