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@-2 {{ISO C++17 does not allow 'register' storage class 
specifier}}
+  // expected-warning@-2 {{ISO C++17 does not allow 'register' storage class 
specifier}}
 #elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
   // expected-warning@-4 {{'register' storage class specifier is deprecated}}
 #endif
   register int n;
 #if __cplusplus > 201402L
-  // expected-error@-2 {{ISO C++17 does not allow 'register' storage class 
specifier}}
+  // expected-warning@-2 {{ISO C++17 does not allow 'register' storage class 
specifier}}
 #elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
   // expected-warning@-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">;


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@-2 {{ISO C++17 does not allow 'register' storage class specifier}}
+  // expected-warning@-2 {{ISO C++17 does not allow 'register' storage class specifier}}
 #elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
   // expected-warning@-4 {{'register' storage class specifier is deprecated}}
 #endif
   register int n;
 #if __cplusplus > 201402L
-  // expected-error@-2 {{ISO C++17 does not allow 'register' storage class specifier}}
+  // expected-warning@-2 {{ISO C++17 does not allow 'register' storage class specifier}}
 #elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
   // expected-warning@-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">;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to