Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12710,11 +12710,13 @@ static bool determineEndOffset(EvalInfo &Info, SourceLocation ExprLoc,
bool DetermineForCompleteObject = refersToCompleteObject(LVal);

auto CheckedHandleSizeof = [&](QualType Ty, CharUnits &Result) {
if (Ty.isNull() || Ty->isIncompleteType() || Ty->isFunctionType())
if (Ty.isNull())
return false;

if (Ty->isReferenceType())
Ty = Ty.getNonReferenceType();
Ty = Ty.getNonReferenceType();

if (Ty->isIncompleteType() || Ty->isFunctionType())
return false;

return HandleSizeof(Info, ExprLoc, Ty, Result);
};
Expand Down
12 changes: 12 additions & 0 deletions clang/test/SemaCXX/builtin-object-size-cxx14.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx14 -std=c++14 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2a %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2b %s


typedef __SIZE_TYPE__ size_t;

Expand Down Expand Up @@ -119,3 +121,13 @@ constexpr int bos_new() { // cxx14-error {{constant expression}}
void *p = new int; // cxx14-note {{until C++20}}
return __builtin_object_size(p, 0);
}


namespace GH129397 {

struct incomplete;
void test(incomplete &ref) {
__builtin_object_size(&ref, 1);
}

}
Loading