Skip to content

Commit d7a37cb

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

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,9 @@ New features
683683
Crash and bug fixes
684684
^^^^^^^^^^^^^^^^^^^
685685

686+
- Check for a null ``TypeSourceInfo *`` when creating a ``UnaryExprOrTypeTraitExpr``.
687+
Fixes (#GH111594)
688+
686689
Improvements
687690
^^^^^^^^^^^^
688691

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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify %s
2+
3+
a() {struct b c (sizeof(b * [({ {tree->d* next)} 0
4+
5+
// expected-error@3 {{a type specifier is required for all declarations}}
6+
// expected-error@3 {{use of undeclared identifier 'tree'; did you mean 'true'?}}
7+
// expected-error@3 {{member reference type 'bool' is not a pointer}}
8+
// expected-error@3 {{expected ';' after expression}}
9+
// expected-error@3 {{use of undeclared identifier 'next'; did you mean 'new'?}}
10+
// expected-error@3 {{expected expression}}
11+
// expected-error@3 {{expected ';' after expression}}
12+
// expected-error@26 {{expected '}'}}
13+
// expected-note@3 {{to match this '{'}}
14+
// expected-error@26 {{expected ')'}}
15+
// expected-note@3 {{to match this '('}}
16+
// expected-error@26 {{expected ']'}}
17+
// expected-note@3 {{to match this '['}}
18+
// expected-error@26 {{expected ')'}}
19+
// expected-note@3 {{to match this '('}}
20+
// expected-error@3 {{using declaration 'exp' instantiates to an empty pack}}
21+
// expected-error@3 {{variable has incomplete type 'struct b'}}
22+
// expected-note@3 {{forward declaration of 'b'}}
23+
// expected-error@3 {{expected ';' at end of declaration}}
24+
// expected-error@26 {{expected '}'}}
25+
// expected-note@3 {{to match this '{'}}
26+
// expected-warning@3 {{expression result unused}}

0 commit comments

Comments
 (0)