]> granicus.if.org Git - clang/commitdiff
Split off the binary literal warning into a subgroup of C++14 warnings
authorRichard Trieu <rtrieu@google.com>
Fri, 18 Sep 2015 23:18:39 +0000 (23:18 +0000)
committerRichard Trieu <rtrieu@google.com>
Fri, 18 Sep 2015 23:18:39 +0000 (23:18 +0000)
Binary literals predate C++14, but they are listed as a C++14 extension since
this was the first time they were standardized in the language.  Move the
warning into a subgroup so it can be selectively disabled when checking for
other C++14 features.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248064 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticLexKinds.td
test/Lexer/warn_binary_literals.cpp [new file with mode: 0644]

index 00b30b14ba6d60b91cb64cb84e79243f6a2591d8..a185b22519a068b2c4e5f38d1ebb5e15edcdf391 100644 (file)
@@ -29,6 +29,7 @@ def ArrayBoundsPointerArithmetic : DiagGroup<"array-bounds-pointer-arithmetic">;
 def Availability : DiagGroup<"availability">;
 def Section : DiagGroup<"section">;
 def AutoImport : DiagGroup<"auto-import">;
+def CXX14BinaryLiteral : DiagGroup<"c++14-binary-literal">;
 def GNUBinaryLiteral : DiagGroup<"gnu-binary-literal">;
 def GNUCompoundLiteralInitializer : DiagGroup<"gnu-compound-literal-initializer">;
 def BitFieldConstantConversion : DiagGroup<"bitfield-constant-conversion">;
@@ -680,7 +681,7 @@ def CXX11 : DiagGroup<"c++11-extensions", [CXX11ExtraSemi, CXX11LongLong]>;
 
 // A warning group for warnings about using C++14 features as extensions in
 // earlier C++ versions.
-def CXX14 : DiagGroup<"c++14-extensions">;
+def CXX14 : DiagGroup<"c++14-extensions", [CXX14BinaryLiteral]>;
 
 // A warning group for warnings about using C++1z features as extensions in
 // earlier C++ versions.
index 712ea63ae87df4373223516b2821145573e008f0..3384a34d61a28765aabd4a0e3cc988a6d9af07d9 100644 (file)
@@ -184,7 +184,7 @@ def ext_hexconstant_invalid : Extension<
 def ext_binary_literal : Extension<
   "binary integer literals are a GNU extension">, InGroup<GNUBinaryLiteral>;
 def ext_binary_literal_cxx14 : Extension<
-  "binary integer literals are a C++14 extension">, InGroup<CXX14>;
+  "binary integer literals are a C++14 extension">, InGroup<CXX14BinaryLiteral>;
 def warn_cxx11_compat_binary_literal : Warning<
   "binary integer literals are incompatible with C++ standards before C++14">,
   InGroup<CXXPre14CompatPedantic>, DefaultIgnore;
diff --git a/test/Lexer/warn_binary_literals.cpp b/test/Lexer/warn_binary_literals.cpp
new file mode 100644 (file)
index 0000000..d196be9
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -Wc++14-binary-literal
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -Wc++14-extensions
+
+int x = 0b11;
+// expected-warning@-1{{binary integer literals are a C++14 extension}}