[PATCH] D157435: [Sema] Do not emit -Wmissing-variable-declarations for register variables
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGa22d385f9656: [Sema] Do not emit -Wmissing-variable-declarations for register variables (authored by nathanchance). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157435/new/ https://reviews.llvm.org/D157435 Files: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaDecl.cpp clang/test/Sema/warn-missing-variable-declarations-register.c Index: clang/test/Sema/warn-missing-variable-declarations-register.c === --- /dev/null +++ clang/test/Sema/warn-missing-variable-declarations-register.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -Wmissing-variable-declarations -fsyntax-only -verify %s +// expected-no-diagnostics + +register unsigned long current_stack_pointer asm("rsp"); Index: clang/lib/Sema/SemaDecl.cpp === --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -14144,6 +14144,7 @@ var->getDeclContext()->getRedeclContext()->isFileContext() && var->isExternallyVisible() && var->hasLinkage() && !var->isInline() && !var->getDescribedVarTemplate() && + var->getStorageClass() != SC_Register && !isa(var) && !isTemplateInstantiation(var->getTemplateSpecializationKind()) && !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations, Index: clang/docs/ReleaseNotes.rst === --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -123,6 +123,8 @@ template-specialization function calls. - Clang contexpr evaluator now displays notes as well as an error when a constructor of a base class is not called in the constructor of its derived class. +- Clang no longer emits ``-Wmissing-variable-declarations`` for variables declared + with the ``register`` storage class. Bug Fixes in This Version - Index: clang/test/Sema/warn-missing-variable-declarations-register.c === --- /dev/null +++ clang/test/Sema/warn-missing-variable-declarations-register.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -Wmissing-variable-declarations -fsyntax-only -verify %s +// expected-no-diagnostics + +register unsigned long current_stack_pointer asm("rsp"); Index: clang/lib/Sema/SemaDecl.cpp === --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -14144,6 +14144,7 @@ var->getDeclContext()->getRedeclContext()->isFileContext() && var->isExternallyVisible() && var->hasLinkage() && !var->isInline() && !var->getDescribedVarTemplate() && + var->getStorageClass() != SC_Register && !isa(var) && !isTemplateInstantiation(var->getTemplateSpecializationKind()) && !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations, Index: clang/docs/ReleaseNotes.rst === --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -123,6 +123,8 @@ template-specialization function calls. - Clang contexpr evaluator now displays notes as well as an error when a constructor of a base class is not called in the constructor of its derived class. +- Clang no longer emits ``-Wmissing-variable-declarations`` for variables declared + with the ``register`` storage class. Bug Fixes in This Version - ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D157435: [Sema] Do not emit -Wmissing-variable-declarations for register variables
nathanchance updated this revision to Diff 548337. nathanchance added a comment. - Update formatting in release notes - Add GCC bug link to commit message - Remove unnecessary REQUIRES: in test Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157435/new/ https://reviews.llvm.org/D157435 Files: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaDecl.cpp clang/test/Sema/warn-missing-variable-declarations-register.c Index: clang/test/Sema/warn-missing-variable-declarations-register.c === --- /dev/null +++ clang/test/Sema/warn-missing-variable-declarations-register.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -Wmissing-variable-declarations -fsyntax-only -verify %s +// expected-no-diagnostics + +register unsigned long current_stack_pointer asm("rsp"); Index: clang/lib/Sema/SemaDecl.cpp === --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -14144,6 +14144,7 @@ var->getDeclContext()->getRedeclContext()->isFileContext() && var->isExternallyVisible() && var->hasLinkage() && !var->isInline() && !var->getDescribedVarTemplate() && + var->getStorageClass() != SC_Register && !isa(var) && !isTemplateInstantiation(var->getTemplateSpecializationKind()) && !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations, Index: clang/docs/ReleaseNotes.rst === --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -123,6 +123,8 @@ template-specialization function calls. - Clang contexpr evaluator now displays notes as well as an error when a constructor of a base class is not called in the constructor of its derived class. +- Clang no longer emits ``-Wmissing-variable-declarations`` for variables declared + with the ``register`` storage class. Bug Fixes in This Version - Index: clang/test/Sema/warn-missing-variable-declarations-register.c === --- /dev/null +++ clang/test/Sema/warn-missing-variable-declarations-register.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -Wmissing-variable-declarations -fsyntax-only -verify %s +// expected-no-diagnostics + +register unsigned long current_stack_pointer asm("rsp"); Index: clang/lib/Sema/SemaDecl.cpp === --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -14144,6 +14144,7 @@ var->getDeclContext()->getRedeclContext()->isFileContext() && var->isExternallyVisible() && var->hasLinkage() && !var->isInline() && !var->getDescribedVarTemplate() && + var->getStorageClass() != SC_Register && !isa(var) && !isTemplateInstantiation(var->getTemplateSpecializationKind()) && !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations, Index: clang/docs/ReleaseNotes.rst === --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -123,6 +123,8 @@ template-specialization function calls. - Clang contexpr evaluator now displays notes as well as an error when a constructor of a base class is not called in the constructor of its derived class. +- Clang no longer emits ``-Wmissing-variable-declarations`` for variables declared + with the ``register`` storage class. Bug Fixes in This Version - ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D157435: [Sema] Do not emit -Wmissing-variable-declarations for register variables
aaron.ballman accepted this revision. aaron.ballman added a comment. LGTM aside from some minor nits. Comment at: clang/docs/ReleaseNotes.rst:126-127 of a base class is not called in the constructor of its derived class. +- Clang no longer emits `-Wmissing-variable-declarations` for variables declared + with the `register` storage class. Sphinx fixes Comment at: clang/test/Sema/warn-missing-variable-declarations-register.c:2 +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -Wmissing-variable-declarations -fsyntax-only -verify %s +// REQUIRES: x86-registered-target +// expected-no-diagnostics nickdesaulniers wrote: > @aaron.ballman do we need this REQUIRES clause? Nope, no need for `REQUIRES` here. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157435/new/ https://reviews.llvm.org/D157435 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D157435: [Sema] Do not emit -Wmissing-variable-declarations for register variables
nickdesaulniers accepted this revision. nickdesaulniers added a comment. This revision is now accepted and ready to land. Thanks for the patch; I think it's better not to warn rather than expect users to add an `unsigned long currest_stack_pointer;` declaration before the definition for `register` storage variables. Maybe worth add a link to the GCC bug report in the commit message, too? https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110947 Comment at: clang/test/Sema/warn-missing-variable-declarations-register.c:2 +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -Wmissing-variable-declarations -fsyntax-only -verify %s +// REQUIRES: x86-registered-target +// expected-no-diagnostics @aaron.ballman do we need this REQUIRES clause? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157435/new/ https://reviews.llvm.org/D157435 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D157435: [Sema] Do not emit -Wmissing-variable-declarations for register variables
nathanchance created this revision. nathanchance added reviewers: aaron.ballman, nickdesaulniers. Herald added a subscriber: pengfei. Herald added a project: All. nathanchance requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. When building the Linux kernel with -Wmissing-variable-declarations, there are several instances of warnings around variables declared with register storage: arch/x86/include/asm/asm.h:208:24: warning: no previous extern declaration for non-static variable 'current_stack_pointer' [-Wmissing-variable-declarations] register unsigned long current_stack_pointer asm(_ASM_SP); ^ arch/x86/include/asm/asm.h:208:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit register unsigned long current_stack_pointer asm(_ASM_SP); ^ 1 warning generated. The suggestion is invalid, as the variable cannot have both static and register storage. Do not emit -Wmissing-variable-declarations for register variables. Closes: https://github.com/llvm/llvm-project/issues/64509 Link: https://lore.kernel.org/202308081050.szew4cq5-...@intel.com/ Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D157435 Files: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaDecl.cpp clang/test/Sema/warn-missing-variable-declarations-register.c Index: clang/test/Sema/warn-missing-variable-declarations-register.c === --- /dev/null +++ clang/test/Sema/warn-missing-variable-declarations-register.c @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -Wmissing-variable-declarations -fsyntax-only -verify %s +// REQUIRES: x86-registered-target +// expected-no-diagnostics + +register unsigned long current_stack_pointer asm("rsp"); Index: clang/lib/Sema/SemaDecl.cpp === --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -14144,6 +14144,7 @@ var->getDeclContext()->getRedeclContext()->isFileContext() && var->isExternallyVisible() && var->hasLinkage() && !var->isInline() && !var->getDescribedVarTemplate() && + var->getStorageClass() != SC_Register && !isa(var) && !isTemplateInstantiation(var->getTemplateSpecializationKind()) && !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations, Index: clang/docs/ReleaseNotes.rst === --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -123,6 +123,8 @@ template-specialization function calls. - Clang contexpr evaluator now displays notes as well as an error when a constructor of a base class is not called in the constructor of its derived class. +- Clang no longer emits `-Wmissing-variable-declarations` for variables declared + with the `register` storage class. Bug Fixes in This Version - Index: clang/test/Sema/warn-missing-variable-declarations-register.c === --- /dev/null +++ clang/test/Sema/warn-missing-variable-declarations-register.c @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -Wmissing-variable-declarations -fsyntax-only -verify %s +// REQUIRES: x86-registered-target +// expected-no-diagnostics + +register unsigned long current_stack_pointer asm("rsp"); Index: clang/lib/Sema/SemaDecl.cpp === --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -14144,6 +14144,7 @@ var->getDeclContext()->getRedeclContext()->isFileContext() && var->isExternallyVisible() && var->hasLinkage() && !var->isInline() && !var->getDescribedVarTemplate() && + var->getStorageClass() != SC_Register && !isa(var) && !isTemplateInstantiation(var->getTemplateSpecializationKind()) && !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations, Index: clang/docs/ReleaseNotes.rst === --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -123,6 +123,8 @@ template-specialization function calls. - Clang contexpr evaluator now displays notes as well as an error when a constructor of a base class is not called in the constructor of its derived class. +- Clang no longer emits `-Wmissing-variable-declarations` for variables declared + with the `register` storage class. Bug Fixes in This Version - ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits