Skip to content

Commit faaf03b

Browse files
author
git apple-llvm automerger
committed
Merge commit 'f6fb6a996c7f' from llvm.org/release/17.x into stable/20230725
2 parents 5b654b3 + f6fb6a9 commit faaf03b

File tree

6 files changed

+27
-6
lines changed

6 files changed

+27
-6
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,8 @@ Bug Fixes in This Version
725725
points (i.e., uses function descriptor objects instead).
726726
- Fixes a ``clang-17`` regression where ``LLVM_UNREACHABLE_OPTIMIZE=OFF``
727727
cannot be used with ``Release`` mode builds. (`#68237 <https://github.com/llvm/llvm-project/issues/68237>`_).
728+
- Fix crash from constexpr evaluator evaluating uninitialized arrays as rvalue.
729+
Fixes (`#67317 <https://github.com/llvm/llvm-project/issues/67317>`_)
728730
- No longer use C++ ``thread_local`` semantics in C23 when using
729731
``thread_local`` instead of ``_Thread_local``.
730732
Fixes (`#70068 <https://github.com/llvm/llvm-project/issues/70068>`_) and

clang/include/clang/Basic/DiagnosticASTKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def note_consteval_address_accessible : Note<
6969
"%select{pointer|reference}0 to a consteval declaration "
7070
"is not a constant expression">;
7171
def note_constexpr_uninitialized : Note<
72-
"subobject %0 is not initialized">;
72+
"subobject %select{of type |}0%1 is not initialized">;
7373
def note_constexpr_uninitialized_base : Note<
7474
"constructor of base class %0 is not called">;
7575
def note_constexpr_static_local : Note<

clang/lib/AST/ExprConstant.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2381,10 +2381,15 @@ static bool CheckEvaluationResult(CheckEvaluationResultKind CERK,
23812381
const FieldDecl *SubobjectDecl,
23822382
CheckedTemporaries &CheckedTemps) {
23832383
if (!Value.hasValue()) {
2384-
assert(SubobjectDecl && "SubobjectDecl shall be non-null");
2385-
Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized) << SubobjectDecl;
2386-
Info.Note(SubobjectDecl->getLocation(),
2387-
diag::note_constexpr_subobject_declared_here);
2384+
if (SubobjectDecl) {
2385+
Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized)
2386+
<< /*(name)*/ 1 << SubobjectDecl;
2387+
Info.Note(SubobjectDecl->getLocation(),
2388+
diag::note_constexpr_subobject_declared_here);
2389+
} else {
2390+
Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized)
2391+
<< /*of type*/ 0 << Type;
2392+
}
23882393
return false;
23892394
}
23902395

clang/lib/AST/Interp/Interp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ bool CheckPure(InterpState &S, CodePtr OpPC, const CXXMethodDecl *MD) {
382382
static void DiagnoseUninitializedSubobject(InterpState &S, const SourceInfo &SI,
383383
const FieldDecl *SubObjDecl) {
384384
assert(SubObjDecl && "Subobject declaration does not exist");
385-
S.FFDiag(SI, diag::note_constexpr_uninitialized) << SubObjDecl;
385+
S.FFDiag(SI, diag::note_constexpr_uninitialized)
386+
<< /*(name)*/ 1 << SubObjDecl;
386387
S.Note(SubObjDecl->getLocation(),
387388
diag::note_constexpr_subobject_declared_here);
388389
}

clang/test/SemaCXX/constant-expression-cxx2a.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,3 +1492,9 @@ class B{
14921492
class D : B{}; // expected-error {{deleted function '~D' cannot override a non-deleted function}}
14931493
// expected-note@-1 {{destructor of 'D' is implicitly deleted because base class 'B' has an inaccessible destructor}}
14941494
}
1495+
1496+
namespace GH67317 {
1497+
constexpr unsigned char a = // expected-error {{constexpr variable 'a' must be initialized by a constant expression}} \
1498+
// expected-note {{subobject of type 'const unsigned char' is not initialized}}
1499+
__builtin_bit_cast(unsigned char, *new char[3][1]);
1500+
};

clang/test/SemaCXX/eval-crashes.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,10 @@ namespace pr33140_10 {
5454
int a(const int &n = 0);
5555
bool b() { return a() == a(); }
5656
}
57+
58+
namespace GH67317 {
59+
struct array {
60+
int (&data)[2];
61+
array() : data(*new int[1][2]) {}
62+
};
63+
}

0 commit comments

Comments
 (0)