[all-commits] [llvm/llvm-project] b44351: Diagnose problematic uses of constructor/destructo...

Aaron Ballman via All-commits all-commits at lists.llvm.org
Tue Sep 26 09:54:44 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b4435104ca3904529723b0673cc0f624cf8c54e6
      https://github.com/llvm/llvm-project/commit/b4435104ca3904529723b0673cc0f624cf8c54e6
  Author: Aaron Ballman <aaron at aaronballman.com>
  Date:   2023-09-26 (Tue, 26 Sep 2023)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/AttrDocs.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Sema/SemaDeclAttr.cpp
    M clang/test/CodeGen/PowerPC/aix-destructor-attribute.c
    M clang/test/CodeGenCXX/aix-destructor-attribute.cpp
    M clang/test/Sema/constructor-attribute.c

  Log Message:
  -----------
  Diagnose problematic uses of constructor/destructor attribute (#67360)

Functions with these attributes will be automatically called before
`main()` or after `main()` exits gracefully, which means the functions
should not accept arguments or have a returned value (nothing can
provide an argument to the call in these cases, and nothing can use the
returned value), nor should they be allowed on a non-static member
function or consteval function in C++. We allow 'int' as a return type for
the function due to finding a significant amount of historical code using
`int(void)` as a signature.

Additionally, these reuse the same priority logic as the init_priority
attribute which explicitly reserved priorty values <= 100 or > 65535. So
we now diagnose use of reserved priorities the same as we do for the
init_priority attribute.




More information about the All-commits mailing list