From: Dmitri Gribenko Date: Tue, 13 Aug 2019 19:07:28 +0000 (+0000) Subject: Revert "Fix crash on switch conditions of non-integer types in templates" X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9cd89a1a8c51349102855d92d68c6f1f80a1cc35;p=clang Revert "Fix crash on switch conditions of non-integer types in templates" This reverts commit r368706. It broke ClangTidy tests. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368738 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 70bd42cfa5..d2730d3e26 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -1669,15 +1669,6 @@ MemberExpr *MemberExpr::Create( MemberExpr *E = new (Mem) MemberExpr(Base, IsArrow, OperatorLoc, MemberDecl, NameInfo, T, VK, OK, NOUR); - if (FieldDecl *Field = dyn_cast(MemberDecl)) { - DeclContext *DC = MemberDecl->getDeclContext(); - // dyn_cast_or_null is used to handle objC variables which do not - // have a declaration context. - CXXRecordDecl *RD = dyn_cast_or_null(DC); - if (RD && RD->isDependentContext() && RD->isCurrentInstantiation(DC)) - E->setTypeDependent(T->isDependentType()); - } - if (HasQualOrFound) { // FIXME: Wrong. We should be looking at the member declaration we found. if (QualifierLoc && QualifierLoc.getNestedNameSpecifier()->isDependent()) { diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 9df5599728..3225dffe92 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -14288,8 +14288,6 @@ void Sema::RefersToMemberWithReducedAlignment( bool AnyIsPacked = false; do { QualType BaseType = ME->getBase()->getType(); - if (BaseType->isDependentType()) - return; if (ME->isArrow()) BaseType = BaseType->getPointeeType(); RecordDecl *RD = BaseType->getAs()->getDecl(); diff --git a/test/SemaTemplate/dependent-names.cpp b/test/SemaTemplate/dependent-names.cpp index a8de159a1d..67ef238083 100644 --- a/test/SemaTemplate/dependent-names.cpp +++ b/test/SemaTemplate/dependent-names.cpp @@ -273,6 +273,9 @@ namespace PR10187 { } int e[10]; }; + void g() { + S().f(); // expected-note {{here}} + } } namespace A2 { diff --git a/test/SemaTemplate/enum-argument.cpp b/test/SemaTemplate/enum-argument.cpp index a79ed8403e..7ff4196139 100644 --- a/test/SemaTemplate/enum-argument.cpp +++ b/test/SemaTemplate/enum-argument.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// expected-no-diagnostics enum Enum { val = 1 }; template struct C { @@ -30,7 +31,7 @@ namespace rdar8020920 { unsigned long long bitfield : e0; void f(int j) { - bitfield + j; // expected-warning {{expression result unused}} + bitfield + j; } }; } diff --git a/test/SemaTemplate/member-access-expr.cpp b/test/SemaTemplate/member-access-expr.cpp index ef10d72a0e..8dba2e68d6 100644 --- a/test/SemaTemplate/member-access-expr.cpp +++ b/test/SemaTemplate/member-access-expr.cpp @@ -156,7 +156,7 @@ namespace test6 { void get(B **ptr) { // It's okay if at some point we figure out how to diagnose this // at instantiation time. - *ptr = field; // expected-error {{assigning to 'test6::B *' from incompatible type 'test6::A *}} + *ptr = field; } }; } diff --git a/test/SemaTemplate/non-integral-switch-cond.cpp b/test/SemaTemplate/non-integral-switch-cond.cpp deleted file mode 100644 index 23c8e0ef8d..0000000000 --- a/test/SemaTemplate/non-integral-switch-cond.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct NOT_AN_INTEGRAL_TYPE {}; - -template -struct foo { - NOT_AN_INTEGRAL_TYPE Bad; - void run() { - switch (Bad) { // expected-error {{statement requires expression of integer type ('NOT_AN_INTEGRAL_TYPE' invalid)}} - case 0: - break; - } - } -};