Skip to content

Commit 27fe526

Browse files
authored
[Clang] Fix crash on improper use of __array_extent (#94173)
Check whether parsing of the argument failed before attempting to build the expression. Fixes #80474.
1 parent 7952720 commit 27fe526

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

clang/docs/ReleaseNotes.rst

+1
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ Bug Fixes to C++ Support
823823
differering by their constraints when only one of these function was variadic.
824824
- Fix a crash when a variable is captured by a block nested inside a lambda. (Fixes #GH93625).
825825
- Fixed a type constraint substitution issue involving a generic lambda expression. (#GH93821)
826+
- Fix a crash caused by improper use of ``__array_extent``. (#GH80474)
826827

827828
Bug Fixes to AST Handling
828829
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Parse/ParseExprCXX.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -4011,6 +4011,9 @@ ExprResult Parser::ParseArrayTypeTrait() {
40114011
ExprResult DimExpr = ParseExpression();
40124012
T.consumeClose();
40134013

4014+
if (DimExpr.isInvalid())
4015+
return ExprError();
4016+
40144017
return Actions.ActOnArrayTypeTrait(ATT, Loc, Ty.get(), DimExpr.get(),
40154018
T.getCloseLocation());
40164019
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %clang_cc1 -verify -std=c++14 %s
2+
3+
auto f() {
4+
return __array_extent(int, ); // expected-error {{expected expression}}
5+
}

0 commit comments

Comments
 (0)