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;
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;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits