[PATCH] D81772: Reduce -Wregister from DefaultError to a default-on warning.

James Y Knight via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 12 15:59:01 PDT 2020


jyknight created this revision.
jyknight added a reviewer: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

There is a lot of C++ code in the wild still using 'register', which
will become broken if we switch the default compilation mode to
C++17. A default-on warning seems to get the message across
sufficiently, without unnecessarily breaking code that hasn't asked
for it (e.g. with -Werror). GCC has also chosen to make -Wregister an
on-by-default warning.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81772

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/SemaCXX/deprecated.cpp


Index: clang/test/SemaCXX/deprecated.cpp
===================================================================
--- clang/test/SemaCXX/deprecated.cpp
+++ clang/test/SemaCXX/deprecated.cpp
@@ -27,13 +27,13 @@
 
 void stuff(register int q) {
 #if __cplusplus > 201402L
-  // expected-error at -2 {{ISO C++17 does not allow 'register' storage class specifier}}
+  // expected-warning at -2 {{ISO C++17 does not allow 'register' storage class specifier}}
 #elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
   // expected-warning at -4 {{'register' storage class specifier is deprecated}}
 #endif
   register int n;
 #if __cplusplus > 201402L
-  // expected-error at -2 {{ISO C++17 does not allow 'register' storage class specifier}}
+  // expected-warning at -2 {{ISO C++17 does not allow 'register' storage class specifier}}
 #elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
   // expected-warning at -4 {{'register' storage class specifier is deprecated}}
 #endif
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -240,7 +240,7 @@
   "and incompatible with C++17">, InGroup<DeprecatedRegister>;
 def ext_register_storage_class : ExtWarn<
   "ISO C++17 does not allow 'register' storage class specifier">,
-  DefaultError, InGroup<Register>;
+  InGroup<Register>;
 
 def err_invalid_decl_spec_combination : Error<
   "cannot combine with previous '%0' declaration specifier">;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81772.270534.patch
Type: text/x-patch
Size: 1561 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200612/524ff304/attachment.bin>


More information about the cfe-commits mailing list