diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-04-22 01:11:06 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-04-22 01:11:06 +0000 |
| commit | e334c017737de0a1127a5cd70e99df198f9227b1 (patch) | |
| tree | f26724d88c25535998fec5b5a293a2b4fc7f537f | |
| parent | 393197a08e2b8376c4f5304c7eeaa84eecdf27cf (diff) | |
| download | bcm5719-llvm-e334c017737de0a1127a5cd70e99df198f9227b1.tar.gz bcm5719-llvm-e334c017737de0a1127a5cd70e99df198f9227b1.zip | |
Move the C++11 ExtWarn for converting a string literal to 'char*' out of
-Wc++11-compat-deprecated-writable-strings. It's neither a C++11 compatibility
warning nor a deprecated feature, it's just ill-formed.
In passing, add that warning to -Wdeprecated, where it belongs.
llvm-svn: 206833
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticGroups.td | 18 | ||||
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/writable-strings-deprecated.cpp | 13 |
3 files changed, 27 insertions, 6 deletions
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index f69e738aadf..5ab8b97ba78 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -82,11 +82,11 @@ def DeprecatedIncrementBool : DiagGroup<"deprecated-increment-bool">; def DeprecatedRegister : DiagGroup<"deprecated-register">; def DeprecatedWritableStr : DiagGroup<"deprecated-writable-strings", [CXX11CompatDeprecatedWritableStr]>; -// FIXME: Why are DeprecatedImplementations and DeprecatedWritableStr -// not in this group? +// FIXME: Why is DeprecatedImplementations not in this group? def Deprecated : DiagGroup<"deprecated", [DeprecatedDeclarations, DeprecatedIncrementBool, - DeprecatedRegister]>, + DeprecatedRegister, + DeprecatedWritableStr]>, DiagCategory<"Deprecations">; def : DiagGroup<"disabled-optimization">; @@ -422,8 +422,18 @@ def ZeroLengthArray : DiagGroup<"zero-length-array">; def GNUZeroLineDirective : DiagGroup<"gnu-zero-line-directive">; def GNUZeroVariadicMacroArguments : DiagGroup<"gnu-zero-variadic-macro-arguments">; +// This covers both the deprecated case (in C++98) +// and the extension case (in C++11 onwards). +def WritableStrings : DiagGroup<"writable-strings", [DeprecatedWritableStr]>; + // GCC calls -Wdeprecated-writable-strings -Wwrite-strings. -def GCCWriteStrings : DiagGroup<"write-strings" , [DeprecatedWritableStr]>; +// +// Bizarrely, this warning flag enables -fconst-strings in C. This is +// GCC-compatible, but really weird. +// +// FIXME: Should this affect C++11 (where this is an error, +// not just deprecated) or not? +def GCCWriteStrings : DiagGroup<"write-strings" , [WritableStrings]>; def CharSubscript : DiagGroup<"char-subscripts">; def LargeByValueCopy : DiagGroup<"large-by-value-copy">; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 03a82ec6e65..67d5e81a93b 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -4638,7 +4638,7 @@ def warn_deprecated_string_literal_conversion : Warning< InGroup<CXX11CompatDeprecatedWritableStr>; def ext_deprecated_string_literal_conversion : ExtWarn< "ISO C++11 does not allow conversion from string literal to %0">, - InGroup<CXX11CompatDeprecatedWritableStr>, SFINAEFailure; + InGroup<WritableStrings>, SFINAEFailure; def err_realimag_invalid_type : Error<"invalid type %0 to %1 operator">; def err_typecheck_sclass_fscope : Error< "illegal storage class on file-scoped variable">; diff --git a/clang/test/SemaCXX/writable-strings-deprecated.cpp b/clang/test/SemaCXX/writable-strings-deprecated.cpp index b8f605b63d6..f9258334980 100644 --- a/clang/test/SemaCXX/writable-strings-deprecated.cpp +++ b/clang/test/SemaCXX/writable-strings-deprecated.cpp @@ -1,14 +1,25 @@ // RUN: %clang_cc1 -fsyntax-only -Wno-deprecated-writable-strings -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wno-deprecated -Wdeprecated-increment-bool -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 +// RUN: %clang_cc1 -fsyntax-only -Werror=deprecated -Wno-error=deprecated-increment-bool -verify %s -DERROR +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -Wno-deprecated -Wdeprecated-increment-bool +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -pedantic-errors -DERROR // rdar://8827606 char *fun(void) { return "foo"; +#if __cplusplus >= 201103L #ifdef ERROR - // expected-error@-2 {{deprecated}} + // expected-error@-3 {{ISO C++11 does not allow conversion from string literal to 'char *'}} +#else + // expected-warning@-5 {{ISO C++11 does not allow conversion from string literal to 'char *'}} +#endif +#elif defined(ERROR) + // expected-error@-8 {{deprecated}} #endif } |

