From: Richard Smith Date: Wed, 25 Nov 2015 21:34:21 +0000 (+0000) Subject: P0001R1: 'register' storage class specifier is no longer permitted in C++1z. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=87bfff6664b4ea545a8ed5e9b39f4b830e4f95f1;p=clang P0001R1: 'register' storage class specifier is no longer permitted in C++1z. We will still allow it in system headers, in macros from system headers, when combined with an 'asm' label, and under the flag -Wno-register. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254097 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index b234fa7b15..8be6c5ee02 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -187,6 +187,8 @@ def CXX14Compat : DiagGroup<"c++14-compat", [CXXPre1zCompat]>; def CXX14CompatPedantic : DiagGroup<"c++14-compat-pedantic", [CXXPre1zCompatPedantic]>; +def CXX1zCompat : DiagGroup<"c++1z-compat", [DeprecatedRegister]>; + def : DiagGroup<"effc++">; def DivZero : DiagGroup<"division-by-zero">; def ExitTimeDestructors : DiagGroup<"exit-time-destructors">; @@ -314,6 +316,7 @@ def : DiagGroup<"redundant-decls">; def RedeclaredClassMember : DiagGroup<"redeclared-class-member">; def GNURedeclaredEnum : DiagGroup<"gnu-redeclared-enum">; def RedundantMove : DiagGroup<"redundant-move">; +def Register : DiagGroup<"register", [DeprecatedRegister]>; def ReturnStackAddress : DiagGroup<"return-stack-address">; def ReturnTypeCLinkage : DiagGroup<"return-type-c-linkage">; def ReturnType : DiagGroup<"return-type", [ReturnTypeCLinkage]>; diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index b097494ca6..91ccf77487 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -213,8 +213,11 @@ def warn_auto_storage_class : Warning< InGroup, DefaultIgnore; def warn_deprecated_register : Warning< - "'register' storage class specifier is deprecated">, - InGroup; + "'register' storage class specifier is deprecated " + "and incompatible with C++1z">, InGroup; +def ext_register_storage_class : ExtWarn< + "ISO C++1z does not allow 'register' storage class specifier">, + DefaultError, InGroup; def err_invalid_decl_spec_combination : Error< "cannot combine with previous '%0' declaration specifier">; diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 261a288908..a6f2d5d645 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -5709,7 +5709,8 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, // Suppress the warning in system macros, it's used in macros in some // popular C system headers, such as in glibc's htonl() macro. Diag(D.getDeclSpec().getStorageClassSpecLoc(), - diag::warn_deprecated_register) + getLangOpts().CPlusPlus1z ? diag::ext_register_storage_class + : diag::warn_deprecated_register) << FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc()); } diff --git a/test/SemaCXX/deprecated.cpp b/test/SemaCXX/deprecated.cpp index 5fcf2130d3..732c015e78 100644 --- a/test/SemaCXX/deprecated.cpp +++ b/test/SemaCXX/deprecated.cpp @@ -1,6 +1,7 @@ // RUN: %clang_cc1 -std=c++98 %s -Wdeprecated -verify -triple x86_64-linux-gnu // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -triple x86_64-linux-gnu // RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify -triple x86_64-linux-gnu +// RUN: %clang_cc1 -std=c++1z %s -Wdeprecated -verify -triple x86_64-linux-gnu // RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify -triple x86_64-linux-gnu -Wno-deprecated-register -DNO_DEPRECATED_FLAGS @@ -17,8 +18,10 @@ void h() throw(...); void stuff() { register int n; -#if __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS) - // expected-warning@-2 {{'register' storage class specifier is deprecated}} +#if __cplusplus > 201402L + // expected-error@-2 {{ISO C++1z 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 m asm("rbx"); // no-warning diff --git a/www/cxx_status.html b/www/cxx_status.html index 2ba262c13c..c41f1196fe 100644 --- a/www/cxx_status.html +++ b/www/cxx_status.html @@ -596,7 +596,7 @@ as the draft C++1z standard evolves.

Remove deprecated register storage class P0001R1 - No + Clang 3.8 Remove deprecated bool increment