Skip to content

Commit 554febd

Browse files
MitalAshokcor3ntin
andauthored
[Clang] Fix some assertions not looking through type sugar (#92299)
Fixes #92284 Co-authored-by: cor3ntin <[email protected]>
1 parent c5c1bd1 commit 554febd

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

clang/lib/AST/ExprConstant.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -11478,7 +11478,7 @@ bool ArrayExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E,
1147811478

1147911479
bool ArrayExprEvaluator::VisitCXXParenListInitExpr(
1148011480
const CXXParenListInitExpr *E) {
11481-
assert(dyn_cast<ConstantArrayType>(E->getType()) &&
11481+
assert(E->getType()->isConstantArrayType() &&
1148211482
"Expression result is not a constant array type");
1148311483

1148411484
return VisitCXXParenListOrInitListExpr(E, E->getInitExprs(),

clang/lib/Sema/SemaInit.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5621,7 +5621,7 @@ static void TryOrBuildParenListInitialization(
56215621
<< SE->getSourceRange();
56225622
return;
56235623
} else {
5624-
assert(isa<IncompleteArrayType>(Entity.getType()));
5624+
assert(Entity.getType()->isIncompleteArrayType());
56255625
ArrayLength = Args.size();
56265626
}
56275627
EntityIndexToProcess = ArrayLength;

clang/test/SemaCXX/paren-list-agg-init.cpp

+20-1
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ namespace GH63903 {
314314
// expected-error {{constexpr variable 's' must be initialized by a constant expression}}
315315
}
316316

317-
318317
namespace gh62863 {
318+
319319
int (&&arr)[] = static_cast<int[]>(42);
320320
// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a parenthesized list of values is a C++20 extension}}
321321
int (&&arr1)[1] = static_cast<int[]>(42);
@@ -333,4 +333,23 @@ int (&&arr6)[2] = (int[])(42); // expected-error {{reference to type 'int[2]' co
333333
// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a parenthesized list of values is a C++20 extension}}
334334
int (&&arr7)[3] = (int[3])(42);
335335
// beforecxx20-warning@-1 {{aggregate initialization of type 'int[3]' from a parenthesized list of values is a C++20 extension}}
336+
337+
}
338+
339+
namespace GH92284 {
340+
341+
using T = int[1]; T x(42);
342+
// beforecxx20-warning@-1 {{aggregate initialization of type 'T' (aka 'int[1]') from a parenthesized list of values is a C++20 extension}}
343+
using Ta = int[2]; Ta a(42);
344+
// beforecxx20-warning@-1 {{aggregate initialization of type 'Ta' (aka 'int[2]') from a parenthesized list of values is a C++20 extension}}
345+
using Tb = int[2]; Tb b(42,43);
346+
// beforecxx20-warning@-1 {{aggregate initialization of type 'Tb' (aka 'int[2]') from a parenthesized list of values is a C++20 extension}}
347+
using Tc = int[]; Tc c(42);
348+
// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a parenthesized list of values is a C++20 extension}}
349+
using Td = int[]; Td d(42,43);
350+
// beforecxx20-warning@-1 {{aggregate initialization of type 'int[2]' from a parenthesized list of values is a C++20 extension}}
351+
template<typename T, int Sz> using ThroughAlias = T[Sz];
352+
ThroughAlias<int, 1> e(42);
353+
// beforecxx20-warning@-1 {{aggregate initialization of type 'ThroughAlias<int, 1>' (aka 'int[1]') from a parenthesized list of values is a C++20 extension}}
354+
336355
}

0 commit comments

Comments
 (0)