summaryrefslogtreecommitdiffstats
path: root/clang/include
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2018-03-14 19:31:34 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2018-03-14 19:31:34 +0000
commitfdf39fa4bf04f79ce2ab240174f12ef606223027 (patch)
tree9e96e2cb1c25b06cad82f0d4555915ad07e998d4 /clang/include
parent5a5ac65768d124d98a10e8520363a0a4be3f4e38 (diff)
downloadbcm5719-llvm-fdf39fa4bf04f79ce2ab240174f12ef606223027.tar.gz
bcm5719-llvm-fdf39fa4bf04f79ce2ab240174f12ef606223027.zip
[Parser] (C++) Make -Wextra-semi slightly more useful
Summary: Let's suppose the `-Weverything` is passed. Given code like ``` void F() {} ; ``` If the code is compiled with `-std=c++03`, it would diagnose that extra sema: ``` <source>:2:1: warning: extra ';' outside of a function is a C++11 extension [-Wc++11-extra-semi] ; ^~ ``` If the code is compiled with `-std=c++11`, it also would diagnose that extra sema: ``` <source>:2:1: warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-pedantic] ; ^~ ``` But, let's suppose the C++11 or higher is used, and the used does not care about `-Wc++98-compat-pedantic`, so he disables that diagnostic. And that silences the complaint about extra `;` too. And there is no way to re-enable that particular diagnostic, passing `-Wextra-semi` does nothing... Now, there is also a related `no newline at end of file` diagnostic, which is also emitted by `-Wc++98-compat-pedantic` ``` <source>:2:2: warning: C++98 requires newline at end of file [-Wc++98-compat-pedantic] ; ^ ``` But unlike the previous case, if `-Wno-c++98-compat-pedantic` is passed, that diagnostic stays displayed: ``` <source>:2:2: warning: no newline at end of file [-Wnewline-eof] ; ^ ``` This diff refactors the code so `-Wc++98-compat-extra-semi` can be re-enabled, after the `-Wc++98-compat-pedantic` was disabled. This seems ugly, but there does not seem to be any saner way. Testing: `$ ninja check-clang` Reviewers: rsmith, rtrieu, aaron.ballman Reviewed By: aaron.ballman Subscribers: jordan_rose, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D43162 llvm-svn: 327558
Diffstat (limited to 'clang/include')
-rw-r--r--clang/include/clang/Basic/DiagnosticGroups.td5
-rw-r--r--clang/include/clang/Basic/DiagnosticParseKinds.td2
2 files changed, 5 insertions, 2 deletions
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index 2d471f1fa5a..c6f98cbade4 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -151,8 +151,10 @@ def Exceptions : DiagGroup<"exceptions">;
def GNUEmptyInitializer : DiagGroup<"gnu-empty-initializer">;
def GNUEmptyStruct : DiagGroup<"gnu-empty-struct">;
def ExtraTokens : DiagGroup<"extra-tokens">;
+def CXX98CompatExtraSemi : DiagGroup<"c++98-compat-extra-semi">;
def CXX11ExtraSemi : DiagGroup<"c++11-extra-semi">;
-def ExtraSemi : DiagGroup<"extra-semi", [CXX11ExtraSemi]>;
+def ExtraSemi : DiagGroup<"extra-semi", [CXX98CompatExtraSemi,
+ CXX11ExtraSemi]>;
def GNUFlexibleArrayInitializer : DiagGroup<"gnu-flexible-array-initializer">;
def GNUFlexibleArrayUnionMember : DiagGroup<"gnu-flexible-array-union-member">;
@@ -196,6 +198,7 @@ def CXX98Compat : DiagGroup<"c++98-compat",
def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
[CXX98Compat,
CXX98CompatBindToTemporaryCopy,
+ CXX98CompatExtraSemi,
CXXPre14CompatPedantic,
CXXPre17CompatPedantic,
CXXPre2aCompatPedantic]>;
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
index e60f3ae64b2..40c84d4afdd 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -39,7 +39,7 @@ def ext_empty_translation_unit : Extension<
InGroup<DiagGroup<"empty-translation-unit">>;
def warn_cxx98_compat_top_level_semi : Warning<
"extra ';' outside of a function is incompatible with C++98">,
- InGroup<CXX98CompatPedantic>, DefaultIgnore;
+ InGroup<CXX98CompatExtraSemi>, DefaultIgnore;
def ext_extra_semi : Extension<
"extra ';' %select{"
"outside of a function|"
OpenPOWER on IntegriCloud