Skip to content

Commit 2f9a122

Browse files
committed
remove ub in libc++ tests
1 parent b36d728 commit 2f9a122

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5280,7 +5280,8 @@ static bool EvaluateVarDecl(EvalInfo &Info, const VarDecl *VD) {
52805280
if (InitE->isValueDependent())
52815281
return false;
52825282

5283-
if (VD->getType()->isReferenceType()) {
5283+
if (VD->getType()->isReferenceType() &&
5284+
!VD->getType()->isFunctionReferenceType()) {
52845285
return EvaluateInitForDeclOfReferenceType(Info, VD, InitE, Result, Val);
52855286
} else if (!EvaluateInPlace(Val, Info, Result, InitE)) {
52865287
// Wipe out any partially-computed value, to allow tracking that this
@@ -6924,7 +6925,8 @@ static bool HandleConstructorCall(const Expr *E, const LValue &This,
69246925
isa<CXXDefaultInitExpr>(Init));
69256926
FullExpressionRAII InitScope(Info);
69266927

6927-
if (FD && FD->getType()->isReferenceType()) {
6928+
if (FD && FD->getType()->isReferenceType() &&
6929+
!FD->getType()->isFunctionReferenceType()) {
69286930
LValue Result;
69296931
if (!EvaluateInitForDeclOfReferenceType(Info, FD, Init, Result,
69306932
*Value)) {
@@ -10962,7 +10964,8 @@ bool RecordExprEvaluator::VisitCXXParenListOrInitListExpr(
1096210964

1096310965
APValue &FieldVal = Result.getStructField(Field->getFieldIndex());
1096410966

10965-
if (Field->getType()->isReferenceType()) {
10967+
if (Field->getType()->isReferenceType() &&
10968+
!Field->getType()->isFunctionReferenceType()) {
1096610969
LValue Result;
1096710970
if (!EvaluateInitForDeclOfReferenceType(Info, Field, Init, Result,
1096810971
FieldVal)) {

libcxx/test/std/ranges/range.adaptors/range.zip/iterator/increment.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ constexpr bool test() {
5959

6060
{
6161
// bidi
62-
int buffer[2] = {1, 2};
62+
int buffer[3] = {1, 2, 3};
6363

6464
std::ranges::zip_view v(BidiCommonView{buffer});
6565
auto it = v.begin();
@@ -81,7 +81,7 @@ constexpr bool test() {
8181

8282
{
8383
// forward
84-
int buffer[2] = {1, 2};
84+
int buffer[3] = {1, 2, 3};
8585

8686
std::ranges::zip_view v(ForwardSizedView{buffer});
8787
auto it = v.begin();

0 commit comments

Comments
 (0)