r368738 - Revert "Fix crash on switch conditions of non-integer types in templates"

Dmitri Gribenko via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 13 12:07:28 PDT 2019


Author: gribozavr
Date: Tue Aug 13 12:07:28 2019
New Revision: 368738

URL: http://llvm.org/viewvc/llvm-project?rev=368738&view=rev
Log:
Revert "Fix crash on switch conditions of non-integer types in templates"

This reverts commit r368706. It broke ClangTidy tests.

Removed:
    cfe/trunk/test/SemaTemplate/non-integral-switch-cond.cpp
Modified:
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/test/SemaTemplate/dependent-names.cpp
    cfe/trunk/test/SemaTemplate/enum-argument.cpp
    cfe/trunk/test/SemaTemplate/member-access-expr.cpp

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=368738&r1=368737&r2=368738&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Aug 13 12:07:28 2019
@@ -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<FieldDecl>(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<CXXRecordDecl>(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()) {

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=368738&r1=368737&r2=368738&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Aug 13 12:07:28 2019
@@ -14288,8 +14288,6 @@ void Sema::RefersToMemberWithReducedAlig
   bool AnyIsPacked = false;
   do {
     QualType BaseType = ME->getBase()->getType();
-    if (BaseType->isDependentType())
-      return;
     if (ME->isArrow())
       BaseType = BaseType->getPointeeType();
     RecordDecl *RD = BaseType->getAs<RecordType>()->getDecl();

Modified: cfe/trunk/test/SemaTemplate/dependent-names.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/dependent-names.cpp?rev=368738&r1=368737&r2=368738&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/dependent-names.cpp (original)
+++ cfe/trunk/test/SemaTemplate/dependent-names.cpp Tue Aug 13 12:07:28 2019
@@ -273,6 +273,9 @@ namespace PR10187 {
       }
       int e[10];
     };
+    void g() {
+      S<int>().f(); // expected-note {{here}}
+    }
   }
 
   namespace A2 {

Modified: cfe/trunk/test/SemaTemplate/enum-argument.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/enum-argument.cpp?rev=368738&r1=368737&r2=368738&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/enum-argument.cpp (original)
+++ cfe/trunk/test/SemaTemplate/enum-argument.cpp Tue Aug 13 12:07:28 2019
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
 
 enum Enum { val = 1 };
 template <Enum v> 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;
     }
   };
 }

Modified: cfe/trunk/test/SemaTemplate/member-access-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/member-access-expr.cpp?rev=368738&r1=368737&r2=368738&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/member-access-expr.cpp (original)
+++ cfe/trunk/test/SemaTemplate/member-access-expr.cpp Tue Aug 13 12:07:28 2019
@@ -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;
     }
   };
 }

Removed: cfe/trunk/test/SemaTemplate/non-integral-switch-cond.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/non-integral-switch-cond.cpp?rev=368737&view=auto
==============================================================================
--- cfe/trunk/test/SemaTemplate/non-integral-switch-cond.cpp (original)
+++ cfe/trunk/test/SemaTemplate/non-integral-switch-cond.cpp (removed)
@@ -1,14 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-struct NOT_AN_INTEGRAL_TYPE {};
-
-template <typename T>
-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;
-    }
-  }
-};




More information about the cfe-commits mailing list