[PATCH] D73996: [Sema] Demote 'alignment is not a power of two' error into a warning

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 4 14:32:50 PST 2020


lebedev.ri created this revision.
lebedev.ri added reviewers: rsmith, erichkeane.
lebedev.ri added a project: clang.
lebedev.ri added a parent revision: D73020: [Sema] Perform call checking when building CXXNewExpr.

As @rsmith notes in https://reviews.llvm.org/D73020#inline-672219
while that is certainly UB land, it may not be actually reachable at runtime, e.g.:

  template<int N> void *make() {
    if ((N & (N-1)) == 0)
      return operator new(N, std::align_val_t(N));
    else
      return operator new(N);
  }
  void *p = make<7>();

and we shouldn't really error-out there.

That being said, i'm not really following the logic here.
Which ones of these cases should remain being an error?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73996

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
  clang/test/Sema/align_value.c
  clang/test/Sema/alignas.c
  clang/test/Sema/alloc-align-attr.c
  clang/test/Sema/attr-aligned.c
  clang/test/Sema/builtin-align.c
  clang/test/Sema/builtin-alloca-with-align.c
  clang/test/Sema/builtin-assume-aligned.c
  clang/test/SemaCXX/align_value.cpp
  clang/test/SemaCXX/alloc-align-attr.cpp
  clang/test/SemaCXX/attr-cxx0x.cpp
  clang/test/SemaCXX/builtin-align-cxx.cpp
  clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
  clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
  clang/test/SemaTemplate/attributes.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73996.242429.patch
Type: text/x-patch
Size: 21263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200204/f848a22f/attachment-0001.bin>


More information about the cfe-commits mailing list