[all-commits] [llvm/llvm-project] f779eb: [clang][ExprConst] Add "declared here" notes to un...

Timm Baeder via All-commits all-commits at lists.llvm.org
Thu Apr 16 01:39:11 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f779ebce55bc5d325bbc985fed3d7b214142af08
      https://github.com/llvm/llvm-project/commit/f779ebce55bc5d325bbc985fed3d7b214142af08
  Author: Timm Baeder <tbaeder at redhat.com>
  Date:   2026-04-16 (Thu, 16 Apr 2026)

  Changed paths:
    M clang/lib/AST/ByteCode/Interp.cpp
    M clang/lib/AST/ByteCode/Interp.h
    M clang/lib/AST/ExprConstant.cpp
    M clang/test/AST/ByteCode/builtin-bit-cast-bitfields.cpp
    M clang/test/AST/ByteCode/builtin-bit-cast-long-double.cpp
    M clang/test/AST/ByteCode/builtin-functions.cpp
    M clang/test/AST/ByteCode/constexpr-nqueens.cpp
    M clang/test/AST/ByteCode/cxx11.cpp
    M clang/test/AST/ByteCode/cxx17.cpp
    M clang/test/AST/ByteCode/cxx20.cpp
    M clang/test/AST/ByteCode/cxx2a.cpp
    M clang/test/AST/ByteCode/lifetimes.cpp
    M clang/test/AST/ByteCode/lifetimes26.cpp
    M clang/test/AST/ByteCode/literals.cpp
    M clang/test/AST/ByteCode/new-delete.cpp
    M clang/test/AST/ByteCode/placement-new.cpp
    M clang/test/AST/ByteCode/records.cpp
    M clang/test/AST/ByteCode/unions.cpp
    M clang/test/C/C23/n3006.c
    M clang/test/CXX/dcl.decl/dcl.decomp/p3.cpp
    M clang/test/CXX/drs/cwg2026.cpp
    M clang/test/CXX/drs/cwg3xx.cpp
    M clang/test/CXX/expr/expr.const/p2-0x.cpp
    M clang/test/Sema/constexpr.c
    M clang/test/SemaCXX/builtin-is-within-lifetime.cpp
    M clang/test/SemaCXX/constant-expression-cxx11.cpp
    M clang/test/SemaCXX/constant-expression-cxx14.cpp
    M clang/test/SemaCXX/constant-expression-cxx2a.cpp
    M clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
    M clang/test/SemaCXX/constexpr-printing.cpp
    M clang/test/SemaCXX/constexpr-value-init.cpp
    M clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
    M clang/test/SemaCXX/cxx2c-constexpr-placement-new.cpp
    M clang/test/SemaCXX/static-assert-cxx26.cpp

  Log Message:
  -----------
  [clang][ExprConst] Add "declared here" notes to uninitialized read diagnostics (#192206)

E.g. for

```c++
constexpr int unInitLocal() {
  int a;
  return a; // both-note {{read of uninitialized object}}
}
static_assert(unInitLocal() == 0, ""); // both-error {{not an integral constant expression}} \
                                       // both-note {{in call to 'unInitLocal()'}}
```

we now diagnose:
```console
array.cpp:896:15: error: static assertion expression is not an integral constant expression
  896 | static_assert(unInitLocal() == 0, ""); // both-error {{not an integral constant expression}} \
      |               ^~~~~~~~~~~~~~~~~~
array.cpp:894:10: note: read of uninitialized object is not allowed in a constant expression
  894 |   return a; // both-note {{read of uninitialized object}}
      |          ^
array.cpp:896:15: note: in call to 'unInitLocal()'
  896 | static_assert(unInitLocal() == 0, ""); // both-error {{not an integral constant expression}} \
      |               ^~~~~~~~~~~~~
array.cpp:893:7: note: declared here
  893 |   int a;
      |       ^
1 warning and 1 error generated.
```
and point at the object that we were trying to read from. This adds an
`NoteLValueLocation()` call to the emission of
`note_constexpr_access_uninit`, which is already done in other places:


https://github.com/llvm/llvm-project/blob/7ae5fe63dd979eae13ea04e166f94056ec1306ca/clang/lib/AST/ExprConstant.cpp#L4565-L4570



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list