diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-11-01 23:38:37 +0000 | 
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-11-01 23:38:37 +0000 | 
| commit | 4d629b80237c0a42601b7e1bc02202e3c33183bf (patch) | |
| tree | 9c97d165807b8a46f28fbce4f9258064697900a1 | |
| parent | 03aeeb09c53923072d561d004b6f682664a2eb8c (diff) | |
| download | bcm5719-llvm-4d629b80237c0a42601b7e1bc02202e3c33183bf.tar.gz bcm5719-llvm-4d629b80237c0a42601b7e1bc02202e3c33183bf.zip  | |
Fix missing -Wregister warning when 'register' is applied to a function parameter.
llvm-svn: 317140
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 8 | ||||
| -rw-r--r-- | clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp | 1 | ||||
| -rw-r--r-- | clang/test/SemaCXX/deprecated.cpp | 7 | ||||
| -rw-r--r-- | clang/test/SemaCXX/varargs.cpp | 2 | 
4 files changed, 16 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index d68b430bae8..0c00ef7e26c 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -11718,6 +11718,14 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {    StorageClass SC = SC_None;    if (DS.getStorageClassSpec() == DeclSpec::SCS_register) {      SC = SC_Register; +    // In C++11, the 'register' storage class specifier is deprecated. +    // In C++17, it is not allowed, but we tolerate it as an extension. +    if (getLangOpts().CPlusPlus11) { +      Diag(DS.getStorageClassSpecLoc(), +           getLangOpts().CPlusPlus1z ? diag::ext_register_storage_class +                                     : diag::warn_deprecated_register) +        << FixItHint::CreateRemoval(DS.getStorageClassSpecLoc()); +    }    } else if (getLangOpts().CPlusPlus &&               DS.getStorageClassSpec() == DeclSpec::SCS_auto) {      SC = SC_Auto; diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp index 0b7a902f937..13721518e6f 100644 --- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp +++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp @@ -39,6 +39,7 @@ struct S {  void foo(auto int ap, register int rp) {  #if __cplusplus >= 201103L // C++11 or later  // expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}} +// expected-warning@-3 {{'register' storage class specifier is deprecated}}  #endif    auto int abo;  #if __cplusplus >= 201103L // C++11 or later diff --git a/clang/test/SemaCXX/deprecated.cpp b/clang/test/SemaCXX/deprecated.cpp index a838cda7c42..773085bf2b9 100644 --- a/clang/test/SemaCXX/deprecated.cpp +++ b/clang/test/SemaCXX/deprecated.cpp @@ -20,7 +20,12 @@ void i() throw(...);  // expected-warning@-8 {{dynamic exception specifications are deprecated}} expected-note@-8 {{use 'noexcept(false)' instead}}  #endif -void stuff() { +void stuff(register int q) { +#if __cplusplus > 201402L +  // expected-error@-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}} diff --git a/clang/test/SemaCXX/varargs.cpp b/clang/test/SemaCXX/varargs.cpp index f9027c24799..f2f53dc2001 100644 --- a/clang/test/SemaCXX/varargs.cpp +++ b/clang/test/SemaCXX/varargs.cpp @@ -8,7 +8,7 @@ void f(const string& s, ...) {  // expected-note {{parameter of type 'const stri    __builtin_va_start(ap, s); // expected-warning {{passing an object of reference type to 'va_start' has undefined behavior}}  } -void g(register int i, ...) { +void g(register int i, ...) { // expected-warning 0-1{{deprecated}}    __builtin_va_start(ap, i); // UB in C, OK in C++  }  | 

