Skip to content

Commit 027b32a

Browse files
author
git apple-llvm automerger
committed
Merge commit 'dc90bf032925' from llvm.org/release/21.x into stable/21.x
2 parents 724f1e0 + dc90bf0 commit 027b32a

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15006,7 +15006,9 @@ EvaluateComparisonBinaryOperator(EvalInfo &Info, const BinaryOperator *E,
1500615006
if (!LHSDesignator.Invalid && !RHSDesignator.Invalid && IsRelational) {
1500715007
bool WasArrayIndex;
1500815008
unsigned Mismatch = FindDesignatorMismatch(
15009-
getType(LHSValue.Base), LHSDesignator, RHSDesignator, WasArrayIndex);
15009+
LHSValue.Base.isNull() ? QualType()
15010+
: getType(LHSValue.Base).getNonReferenceType(),
15011+
LHSDesignator, RHSDesignator, WasArrayIndex);
1501015012
// At the point where the designators diverge, the comparison has a
1501115013
// specified value if:
1501215014
// - we are comparing array indices
@@ -15050,7 +15052,7 @@ EvaluateComparisonBinaryOperator(EvalInfo &Info, const BinaryOperator *E,
1505015052
// compare pointers within the object in question; otherwise, the result
1505115053
// depends on where the object is located in memory.
1505215054
if (!LHSValue.Base.isNull() && IsRelational) {
15053-
QualType BaseTy = getType(LHSValue.Base);
15055+
QualType BaseTy = getType(LHSValue.Base).getNonReferenceType();
1505415056
if (BaseTy->isIncompleteType())
1505515057
return Error(E);
1505615058
CharUnits Size = Info.Ctx.getTypeSizeInChars(BaseTy);

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,3 +383,17 @@ namespace enable_if_2 {
383383
}
384384
}
385385
}
386+
387+
namespace GH150015 {
388+
extern int (& c)[8]; // interpreter-note {{declared here}}
389+
constexpr int x = c <= c+8; // interpreter-error {{constexpr variable 'x' must be initialized by a constant expression}} \
390+
// interpreter-note {{initializer of 'c' is unknown}}
391+
392+
struct X {};
393+
struct Y {};
394+
struct Z : X, Y {};
395+
extern Z &z; // interpreter-note{{declared here}}
396+
constexpr int bases = (void*)(X*)&z <= (Y*)&z; // expected-error {{constexpr variable 'bases' must be initialized by a constant expression}} \
397+
// nointerpreter-note {{comparison of addresses of subobjects of different base classes has unspecified value}} \
398+
// interpreter-note {{initializer of 'z' is unknown}}
399+
}

0 commit comments

Comments
 (0)