[PATCH] D84387: [AST][RecoveryExpr] Suppress spurious "err_typecheck_expect_scalar_operand" diagnostic
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 23 00:12:12 PDT 2020
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D84387
Files:
clang/lib/Sema/SemaCast.cpp
clang/test/Sema/error-dependence.c
Index: clang/test/Sema/error-dependence.c
===================================================================
--- clang/test/Sema/error-dependence.c
+++ clang/test/Sema/error-dependence.c
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify -frecovery-ast -fno-recovery-ast-type -fc-dependence %s
-int call(int); // expected-note {{'call' declared here}}
+int call(int); // expected-note 2{{'call' declared here}}
void test1(int s) {
// verify "assigning to 'int' from incompatible type '<dependent type>'" is
@@ -12,8 +12,14 @@
(*__builtin_classify_type)(1); // expected-error {{builtin functions must be directly called}}
}
-void test2(int* ptr, float f) {
+void test2(int *ptr, float f) {
// verify diagnostic "used type '<dependent type>' where arithmetic or pointer
// type is required" is not emitted.
ptr > f ? ptr : f; // expected-error {{invalid operands to binary expression}}
}
+
+void test3(float f) {
+ // verify diagnostic "operand of type '<dependent type>' where arithmetic or
+ // pointer type is required" is not emitted.
+ f = (float)call(); // expected-error {{too few arguments to function call}}
+}
Index: clang/lib/Sema/SemaCast.cpp
===================================================================
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2690,6 +2690,16 @@
return;
}
+ if (Self.getLangOpts().CDependence &&
+ (DestType->isDependentType() || SrcExpr.get()->isTypeDependent() ||
+ SrcExpr.get()->isValueDependent())) {
+ assert((DestType->containsErrors() || SrcExpr.get()->containsErrors() ||
+ SrcExpr.get()->containsErrors()) &&
+ "should only occur in error-recovery path.");
+ assert(Kind == CK_Dependent);
+ return;
+ }
+
// Overloads are allowed with C extensions, so we need to support them.
if (SrcExpr.get()->getType() == Self.Context.OverloadTy) {
DeclAccessPair DAP;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84387.280038.patch
Type: text/x-patch
Size: 1927 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200723/78194342/attachment.bin>
More information about the cfe-commits
mailing list