r194736 - Add -Wdeprecated-writable-string in C++ to -Wc++11-compat, since it's ill-formed in C++11.

Richard Smith richard-llvm at metafoo.co.uk
Thu Nov 14 14:22:31 PST 2013


Author: rsmith
Date: Thu Nov 14 16:22:31 2013
New Revision: 194736

URL: http://llvm.org/viewvc/llvm-project?rev=194736&view=rev
Log:
Add -Wdeprecated-writable-string in C++ to -Wc++11-compat, since it's ill-formed in C++11.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticGroups.td
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/test/SemaCXX/writable-strings-deprecated.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=194736&r1=194735&r2=194736&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Nov 14 16:22:31 2013
@@ -66,11 +66,15 @@ def GNUStringLiteralOperatorTemplate :
 def DeleteNonVirtualDtor : DiagGroup<"delete-non-virtual-dtor">;
 def AbstractFinalClass : DiagGroup<"abstract-final-class">;
 
+def CXX11CompatDeprecatedWritableStr :
+  DiagGroup<"c++11-compat-deprecated-writable-strings">;
+
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;
 def DeprecatedImplementations :DiagGroup<"deprecated-implementations">;
 def DeprecatedIncrementBool : DiagGroup<"deprecated-increment-bool">;
 def DeprecatedRegister : DiagGroup<"deprecated-register">;
-def DeprecatedWritableStr : DiagGroup<"deprecated-writable-strings">;
+def DeprecatedWritableStr : DiagGroup<"deprecated-writable-strings",
+                                      [CXX11CompatDeprecatedWritableStr]>;
 // FIXME: Why are DeprecatedImplementations and DeprecatedWritableStr
 // not in this group?
 def Deprecated : DiagGroup<"deprecated", [DeprecatedDeclarations,
@@ -143,6 +147,7 @@ def ReservedUserDefinedLiteral :
 def CXX11Compat : DiagGroup<"c++11-compat",
                             [CXX11Narrowing,
                              CXX11CompatReservedUserDefinedLiteral,
+                             CXX11CompatDeprecatedWritableStr,
                              CXXPre1yCompat]>;
 def : DiagGroup<"c++0x-compat", [CXX11Compat]>;
 def CXX11CompatPedantic : DiagGroup<"c++11-compat-pedantic",

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=194736&r1=194735&r2=194736&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Nov 14 16:22:31 2013
@@ -4499,7 +4499,8 @@ def ext_array_init_parens : ExtWarn<
   "parenthesized initialization of a member array is a GNU extension">,
   InGroup<DiagGroup<"gnu-array-member-paren-init">>, DefaultError;
 def warn_deprecated_string_literal_conversion : Warning<
-  "conversion from string literal to %0 is deprecated">, InGroup<DeprecatedWritableStr>;
+  "conversion from string literal to %0 is deprecated">,
+  InGroup<CXX11CompatDeprecatedWritableStr>;
 def warn_deprecated_string_literal_conversion_c : Warning<
   "dummy warning to enable -fconst-strings">, InGroup<DeprecatedWritableStr>, DefaultIgnore;
 def err_realimag_invalid_type : Error<"invalid type %0 to %1 operator">;

Modified: cfe/trunk/test/SemaCXX/writable-strings-deprecated.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/writable-strings-deprecated.cpp?rev=194736&r1=194735&r2=194736&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/writable-strings-deprecated.cpp (original)
+++ cfe/trunk/test/SemaCXX/writable-strings-deprecated.cpp Thu Nov 14 16:22:31 2013
@@ -1,11 +1,15 @@
 // RUN: %clang_cc1 -fsyntax-only -Wno-deprecated-writable-strings -verify %s
 // RUN: %clang_cc1 -fsyntax-only -fwritable-strings -verify %s
 // RUN: %clang_cc1 -fsyntax-only -Wno-write-strings -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Werror=c++11-compat -verify %s -DERROR
 // rdar://8827606
 
 char *fun(void)
 {
    return "foo";
+#ifdef ERROR
+   // expected-error at -2 {{deprecated}}
+#endif
 }
 
 void test(bool b)





More information about the cfe-commits mailing list