Skip to content

Commit d3b9b6e

Browse files
committed
[clang] Check for null TypeSourceInfo in Sema::CreateUnaryExprOrTypeTraitExpr
1 parent c13f806 commit d3b9b6e

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ Bug Fixes to C++ Support
505505
- Fix a crash when parsing a pseudo destructor involving an invalid type. (#GH111460)
506506
- Fixed an assertion failure when invoking recovery call expressions with explicit attributes
507507
and undeclared templates. (#GH107047, #GH49093)
508+
- Fixed a compiler crash that occurred when processing malformed code involving `sizeof` with
509+
an invalid type argument. (#GH111594)
508510

509511
Bug Fixes to AST Handling
510512
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaExpr.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4629,6 +4629,9 @@ ExprResult Sema::CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
46294629
TInfo->getType()->isVariablyModifiedType())
46304630
TInfo = TransformToPotentiallyEvaluated(TInfo);
46314631

4632+
if (!TInfo)
4633+
return ExprError();
4634+
46324635
// C99 6.5.3.4p4: the type (an unsigned integer type) is size_t.
46334636
return new (Context) UnaryExprOrTypeTraitExpr(
46344637
ExprKind, TInfo, Context.getSizeType(), OpLoc, R.getEnd());
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-value %s
2+
//
3+
// Note: This test is ensure the code does not cause a crash as previously
4+
// reported in (#GH111594). The specific diagnostics are unimportant.
5+
6+
a() {struct b c (sizeof(b * [({ {tree->d* next)} 0
7+
8+
// expected-error@6 0+{{}}
9+
// expected-error@11 0+{{}}
10+
// expected-note@6 0+{{}}
11+

0 commit comments

Comments
 (0)