diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -413,6 +413,9 @@ - Fix a crash when an enum constant has a dependent-type recovery expression for C. (`#62446 `_). +- Propagate the value-dependent bit for VAArgExpr. Fixes a crash where a + __builtin_va_arg call has invalid arguments. + (`#62711 `_). Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/AST/ComputeDependence.cpp b/clang/lib/AST/ComputeDependence.cpp --- a/clang/lib/AST/ComputeDependence.cpp +++ b/clang/lib/AST/ComputeDependence.cpp @@ -227,7 +227,7 @@ auto D = toExprDependenceAsWritten( E->getWrittenTypeInfo()->getType()->getDependence()) | (E->getSubExpr()->getDependence() & ~ExprDependence::Type); - return D & ~ExprDependence::Value; + return D; } ExprDependence clang::computeDependence(NoInitExpr *E) { diff --git a/clang/test/AST/ast-dump-recovery.c b/clang/test/AST/ast-dump-recovery.c --- a/clang/test/AST/ast-dump-recovery.c +++ b/clang/test/AST/ast-dump-recovery.c @@ -109,3 +109,11 @@ b, }; } + +// Verify no crash +void test5_GH62711() { + // CHECK: VAArgExpr {{.*}} 'int' contains-errors + // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '' contains-errors + // CHECK-NEXT: | `-RecoveryExpr {{.*}} '' contains-errors + if (__builtin_va_arg(undef, int) << 1); +}