forked from OSchip/llvm-project
C++11: don't warn about the deprecated 'register' keyword if it's combined with
an asm label. llvm-svn: 184069
This commit is contained in:
parent
37ba45a3c5
commit
f2c9afceef
|
@ -2771,13 +2771,6 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
|
|||
PrevSpec, DiagID);
|
||||
break;
|
||||
case tok::kw_register:
|
||||
// In C++11, the 'register' storage class specifier is deprecated.
|
||||
// Suppress the warning in system macros, it's used in macros in some
|
||||
// popular C system headers, such as in glibc's htonl() macro.
|
||||
if (getLangOpts().CPlusPlus11 &&
|
||||
!PP.getSourceManager().isInSystemMacro(Tok.getLocation()))
|
||||
Diag(Tok, diag::warn_deprecated_register)
|
||||
<< FixItHint::CreateRemoval(Tok.getLocation());
|
||||
isInvalid = DS.SetStorageClassSpec(Actions, DeclSpec::SCS_register, Loc,
|
||||
PrevSpec, DiagID);
|
||||
break;
|
||||
|
|
|
@ -4727,6 +4727,17 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
|
|||
SC = SC_None;
|
||||
}
|
||||
|
||||
if (getLangOpts().CPlusPlus11 && SCSpec == DeclSpec::SCS_register &&
|
||||
!D.getAsmLabel() && !getSourceManager().isInSystemMacro(
|
||||
D.getDeclSpec().getStorageClassSpecLoc())) {
|
||||
// In C++11, the 'register' storage class specifier is deprecated.
|
||||
// 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)
|
||||
<< FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc());
|
||||
}
|
||||
|
||||
IdentifierInfo *II = Name.getAsIdentifierInfo();
|
||||
if (!II) {
|
||||
Diag(D.getIdentifierLoc(), diag::err_bad_variable_name)
|
||||
|
@ -4740,7 +4751,6 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
|
|||
// C99 6.9p2: The storage-class specifiers auto and register shall not
|
||||
// appear in the declaration specifiers in an external declaration.
|
||||
if (SC == SC_Auto || SC == SC_Register) {
|
||||
|
||||
// If this is a register variable with an asm label specified, then this
|
||||
// is a GNU extension.
|
||||
if (SC == SC_Register && D.getAsmLabel())
|
||||
|
@ -4750,7 +4760,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
|
|||
D.setInvalidType();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (getLangOpts().OpenCL) {
|
||||
// Set up the special work-group-local storage class for variables in the
|
||||
// OpenCL __local address space.
|
||||
|
|
|
@ -7,7 +7,7 @@ class A {
|
|||
#if __cplusplus < 201103L
|
||||
friend register class E; // expected-error {{'register' is invalid in friend declarations}}
|
||||
#else
|
||||
friend register class E; // expected-error {{'register' is invalid in friend declarations}} expected-warning {{deprecated}}
|
||||
friend register class E; // expected-error {{'register' is invalid in friend declarations}}
|
||||
#endif
|
||||
friend mutable class F; // expected-error {{'mutable' is invalid in friend declarations}}
|
||||
friend typedef class G; // expected-error {{'typedef' is invalid in friend declarations}}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// RUN: %clang_cc1 -std=c++98 %s -Wdeprecated -verify
|
||||
// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
|
||||
// RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify
|
||||
// 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++1y %s -Wdeprecated -verify -Wno-deprecated-register -DNO_DEPRECATED_FLAGS
|
||||
// RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify -triple x86_64-linux-gnu -Wno-deprecated-register -DNO_DEPRECATED_FLAGS
|
||||
|
||||
#include "Inputs/register.h"
|
||||
|
||||
|
@ -21,6 +21,8 @@ void stuff() {
|
|||
// expected-warning@-2 {{'register' storage class specifier is deprecated}}
|
||||
#endif
|
||||
|
||||
register int m asm("rbx"); // no-warning
|
||||
|
||||
int k = to_int(n); // no-warning
|
||||
|
||||
bool b;
|
||||
|
|
Loading…
Reference in New Issue