Skip to content

Commit d972d4c

Browse files
committed
Revert "[clang] Suppress "follow-up" diagnostics on recovery call expressions."
This reverts commit efa9aaa and adds a crash test. The commit caused a crash in CodeGen with -fms-compatibility, see https://bugs.llvm.org/show_bug.cgi?id=48690.
1 parent def99ad commit d972d4c

File tree

4 files changed

+22
-34
lines changed

4 files changed

+22
-34
lines changed

clang/lib/Sema/SemaOverload.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12923,7 +12923,7 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
1292312923
return ExprError();
1292412924
}
1292512925

12926-
// Build an implicit member access expression if appropriate. Just drop the
12926+
// Build an implicit member call if appropriate. Just drop the
1292712927
// casts and such from the call, we don't really care.
1292812928
ExprResult NewFn = ExprError();
1292912929
if ((*R.begin())->isCXXClassMember())
@@ -12938,19 +12938,12 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
1293812938
if (NewFn.isInvalid())
1293912939
return ExprError();
1294012940

12941-
auto CallE =
12942-
SemaRef.BuildCallExpr(/*Scope*/ nullptr, NewFn.get(), LParenLoc,
12943-
MultiExprArg(Args.data(), Args.size()), RParenLoc);
12944-
if (CallE.isInvalid())
12945-
return ExprError();
12946-
// We now have recovered a callee. However, building a real call may lead to
12947-
// incorrect secondary diagnostics if our recovery wasn't correct.
12948-
// We keep the recovery behavior but suppress all following diagnostics by
12949-
// using RecoveryExpr. We deliberately drop the return type of the recovery
12950-
// function, and rely on clang's dependent mechanism to suppress following
12951-
// diagnostics.
12952-
return SemaRef.CreateRecoveryExpr(CallE.get()->getBeginLoc(),
12953-
CallE.get()->getEndLoc(), {CallE.get()});
12941+
// This shouldn't cause an infinite loop because we're giving it
12942+
// an expression with viable lookup results, which should never
12943+
// end up here.
12944+
return SemaRef.BuildCallExpr(/*Scope*/ nullptr, NewFn.get(), LParenLoc,
12945+
MultiExprArg(Args.data(), Args.size()),
12946+
RParenLoc);
1295412947
}
1295512948

1295612949
/// Constructs and populates an OverloadedCandidateSet from

clang/test/AST/ast-dump-recovery.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,3 @@ void InvalidCondition() {
296296
// CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 2
297297
invalid() ? 1 : 2;
298298
}
299-
300-
void abcc();
301-
void TypoCorrection() {
302-
// RecoveryExpr is always dependent-type in this case in order to suppress
303-
// following diagnostics.
304-
// CHECK: RecoveryExpr {{.*}} '<dependent type>'
305-
// CHECK-NEXT: `-CallExpr {{.*}} 'void'
306-
// CHECK-NEXT: `-ImplicitCastExpr
307-
// CHECK-NEXT: `-DeclRefExpr {{.*}} 'abcc'
308-
abc();
309-
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-obj -fms-compatibility %s -o -
2+
// CHECK that we don't crash.
3+
4+
struct Base {
5+
void b(int, int);
6+
};
7+
8+
template <typename Base> struct Derived : Base {
9+
void d() { b(1, 2); }
10+
};
11+
12+
void use() {
13+
Derived<Base> d;
14+
d.d();
15+
}

clang/test/SemaCXX/typo-correction-delayed.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,6 @@ int z = 1 ? N : ; // expected-error {{expected expression}}
209209
// expected-error-re@-1 {{use of undeclared identifier 'N'{{$}}}}
210210
}
211211

212-
namespace noSecondaryDiags {
213-
void abcc(); // expected-note {{'abcc' declared here}}
214-
215-
void test() {
216-
// Verify the secondary diagnostic ".. convertible to 'bool'" is suppressed.
217-
if (abc()) {} // expected-error {{use of undeclared identifier 'abc'; did you mean 'abcc'?}}
218-
}
219-
}
220-
221212
// PR 23285. This test must be at the end of the file to avoid additional,
222213
// unwanted diagnostics.
223214
// expected-error-re@+2 {{use of undeclared identifier 'uintmax_t'{{$}}}}

0 commit comments

Comments
 (0)