r184005 - Suppress the c++11 -Wdeprecated warning for 'register' if it is expanded from a
Richard Smith
richard-llvm at metafoo.co.uk
Fri Jun 14 14:05:24 PDT 2013
Author: rsmith
Date: Fri Jun 14 16:05:24 2013
New Revision: 184005
URL: http://llvm.org/viewvc/llvm-project?rev=184005&view=rev
Log:
Suppress the c++11 -Wdeprecated warning for 'register' if it is expanded from a
macro defined in a system header. glibc uses it in macros, apparently.
Added:
cfe/trunk/test/SemaCXX/Inputs/register.h
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/SemaCXX/deprecated.cpp
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=184005&r1=184004&r2=184005&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri Jun 14 16:05:24 2013
@@ -2771,7 +2771,11 @@ void Parser::ParseDeclarationSpecifiers(
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,
Added: cfe/trunk/test/SemaCXX/Inputs/register.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/Inputs/register.h?rev=184005&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/Inputs/register.h (added)
+++ cfe/trunk/test/SemaCXX/Inputs/register.h Fri Jun 14 16:05:24 2013
@@ -0,0 +1,5 @@
+#pragma GCC system_header
+#pragma once
+
+inline void f() { register int k; }
+#define to_int(x) ({ register int n = (x); n; })
Modified: cfe/trunk/test/SemaCXX/deprecated.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/deprecated.cpp?rev=184005&r1=184004&r2=184005&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/deprecated.cpp (original)
+++ cfe/trunk/test/SemaCXX/deprecated.cpp Fri Jun 14 16:05:24 2013
@@ -2,6 +2,8 @@
// 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(...);
@@ -17,6 +19,8 @@ void stuff() {
// expected-warning at -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}}
More information about the cfe-commits
mailing list