Clang warning: 'register' storage class specifier is deprecated and incompatible with C++17 [-Wdeprecated-register] (warn_deprecated_register)
Jump to navigation
Jump to search
Text | error: 'register' storage class specifier is deprecated and incompatible with C++1z |
---|---|
Type | Warning |
Category | Deprecations |
Internal Id | warn_deprecated_register |
Active by Default | Yes |
Flags | -Wno-c++17-compat (45 elements) -Wno-c++17-compat-pedantic (89 elements) -Wno-c++1z-compat (45 elements) -Wno-deprecated (43 elements) -Wno-deprecated-register (1 element) -Wno-register (2 elements) |
Internal Message | 'register' storage class specifier is deprecated and incompatible with C++1z
|
Regular Expression | (?:warning|error|fatal error)\: 'register' storage class specifier is deprecated and incompatible with C\+\+17 \[(?:\-Werror,)?\-Wdeprecated\-register[^\]]*\]
|
First Commit | 2013-06-13 8ca78a16f4a5 Add -Wdeprecated warnings and fixits for things deprecated in C++11: |
Description
Example
Flags | -xc++ -std=c++11
|
|
---|---|---|
Source |
int main() {
// Deprecated in C++17
register int x = 0;
return x;
}
| |
Compiler Output |
<source>:3:3: warning: 'register' storage class specifier is deprecated and incompatible with C++17 [-Wdeprecated-register] |
Clang Internals (17.0.6)
Git Commit Message
Add -Wdeprecated warnings and fixits for things deprecated in C++11: - 'register' storage class - dynamic exception specifications Only the former check is enabled by default for now (the latter might be quite noisy). llvm-svn: 183881
Used in Clang Sources
This section lists all occurrences of the diagnostic within the Clang's codebase. For each occurrence, an auto-extracted snipped from the source code is listed including key elements like control structures, functions, or classes. It should illustrate the conditions under which the diagnostic is activated.
clang/lib/Sema/SemaDecl.cpp (line 7496)
NamedDecl *Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope, ArrayRef<BindingDecl *> Bindings) {
// ...
if (getLangOpts().CPlusPlus11 && SCSpec == DeclSpec::SCS_register && !D.getAsmLabel() && !getSourceManager().isInSystemMacro(D.getDeclSpec().getStorageClassSpecLoc())) {
// ...
Diag(D.getDeclSpec().getStorageClassSpecLoc(), getLangOpts().CPlusPlus17 ? diag::ext_register_storage_class : diag::warn_deprecated_register) << FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc());
clang/lib/Sema/SemaDecl.cpp (line 14738)
/// ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator()
/// to introduce parameters into function prototype scope.
Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
// ...
if (DS.getStorageClassSpec() == DeclSpec::SCS_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().CPlusPlus17 ? diag::ext_register_storage_class : diag::warn_deprecated_register) << FixItHint::CreateRemoval(DS.getStorageClassSpecLoc());
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/SemaCXX/attr-cxx0x.cpp
- clang/test/SemaCXX/attr-cxx0x.cpp:15:14: warning: 'register' storage class specifier is deprecated and incompatible with C++17 [-Wdeprecated-register]