Skip to content

Commit b6cb1c5

Browse files
committed
[Clang] Fix some assertions not looking through type sugar
Fixes #92284
1 parent d92c677 commit b6cb1c5

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11420,7 +11420,7 @@ bool ArrayExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E,
1142011420

1142111421
bool ArrayExprEvaluator::VisitCXXParenListInitExpr(
1142211422
const CXXParenListInitExpr *E) {
11423-
assert(dyn_cast<ConstantArrayType>(E->getType()) &&
11423+
assert(E->getType()->isConstantArrayType() &&
1142411424
"Expression result is not a constant array type");
1142511425

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

clang/lib/Sema/SemaInit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5511,7 +5511,7 @@ static void TryOrBuildParenListInitialization(
55115511
<< SE->getSourceRange();
55125512
return;
55135513
} else {
5514-
assert(isa<IncompleteArrayType>(Entity.getType()));
5514+
assert(Entity.getType()->isIncompleteArrayType());
55155515
ArrayLength = Args.size();
55165516
}
55175517
EntityIndexToProcess = ArrayLength;

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,3 +313,19 @@ namespace GH63903 {
313313
constexpr S s(0); // beforecxx20-warning {{aggregate initialization of type 'const S' from a parenthesized list of values is a C++20 extension}} \
314314
// expected-error {{constexpr variable 's' must be initialized by a constant expression}}
315315
}
316+
317+
namespace GH92284 {
318+
using T = int[1]; T x(42);
319+
// beforecxx20-warning@-1 {{aggregate initialization of type 'T' (aka 'int[1]') from a parenthesized list of values is a C++20 extension}}
320+
using Ta = int[2]; Ta a(42);
321+
// beforecxx20-warning@-1 {{aggregate initialization of type 'Ta' (aka 'int[2]') from a parenthesized list of values is a C++20 extension}}
322+
using Tb = int[2]; Tb b(42,43);
323+
// beforecxx20-warning@-1 {{aggregate initialization of type 'Tb' (aka 'int[2]') from a parenthesized list of values is a C++20 extension}}
324+
using Tc = int[]; Tc c(42);
325+
// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a parenthesized list of values is a C++20 extension}}
326+
using Td = int[]; Td d(42,43);
327+
// beforecxx20-warning@-1 {{aggregate initialization of type 'int[2]' from a parenthesized list of values is a C++20 extension}}
328+
template<typename T, int Sz> using ThroughAlias = T[Sz];
329+
ThroughAlias<int, 1> e(42);
330+
// beforecxx20-warning@-1 {{aggregate initialization of type 'ThroughAlias<int, 1>' (aka 'int[1]') from a parenthesized list of values is a C++20 extension}}
331+
}

0 commit comments

Comments
 (0)