PrevSpec, DiagID);
break;
case tok::kw_register:
- if (getLangOpts().CPlusPlus11)
+ // 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,
--- /dev/null
+#pragma GCC system_header
+#pragma once
+
+inline void f() { register int k; }
+#define to_int(x) ({ register int n = (x); n; })
// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
// RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify
+#include "Inputs/register.h"
+
void f() throw();
void g() throw(int);
void h() throw(...);
// expected-warning@-2 {{'register' storage class specifier is deprecated}}
#endif
+ int k = to_int(n); // no-warning
+
bool b;
++b; // expected-warning {{incrementing expression of type bool is deprecated}}