[PATCH] D108211: Emit sizeof/alignof values as notes when a static_assert fails

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 17 11:23:24 PDT 2021


aaron.ballman added a reviewer: rsmith.
aaron.ballman added inline comments.


================
Comment at: clang/lib/Sema/SemaTemplate.cpp:3598
       return true;
+    } else if (auto *UE = dyn_cast<UnaryExprOrTypeTraitExpr>(E)) {
+      Expr::EvalResult Result;
----------------



================
Comment at: clang/test/SemaCXX/static-assert.cpp:218
+// expected-note at -2{{with 'alignof(IntAndPointer)' equal to 8}}
+// expected-note at -3{{with 'sizeof(IntAndPointer)' equal to 16}}
----------------
Can you also add a test where the unary expression isn't the reason for the failure? e.g.,
```
static_assert(is_same_v<float, decltype(sizeof(int))>);
```
Perhaps we'd want to silence the notes if the expression context for the call to `sizeof` is itself unevaluated?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108211/new/

https://reviews.llvm.org/D108211



More information about the cfe-commits mailing list