[clang] 9b2ab41 - Revert "[MS] Fix assert handling enum forward decls in hasVisibleDefinition"

Rumeet Dhindsa via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 20 10:41:27 PDT 2020


Author: Rumeet Dhindsa
Date: 2020-04-20T10:40:27-07:00
New Revision: 9b2ab41037f45ad92ab4e850591093ffc45d3e10

URL: https://github.com/llvm/llvm-project/commit/9b2ab41037f45ad92ab4e850591093ffc45d3e10
DIFF: https://github.com/llvm/llvm-project/commit/9b2ab41037f45ad92ab4e850591093ffc45d3e10.diff

LOG: Revert "[MS] Fix assert handling enum forward decls in hasVisibleDefinition"

This reverts commit e62dc1f6252c1dcdcc2a64e8e3b07a32412e9d89.

Reverting as per discussion with the patch author.
This patch causes module import error, but there was no intended
behavior change for code that does not use Microsoft extensions.

Added: 
    

Modified: 
    clang/lib/Sema/SemaType.cpp

Removed: 
    clang/test/Modules/Inputs/ms-enums/A.h
    clang/test/Modules/Inputs/ms-enums/B.h
    clang/test/Modules/Inputs/ms-enums/module.map
    clang/test/Modules/ms-enums.cpp


################################################################################
diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 4ecd36209e5b..075c30f88b3f 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8120,10 +8120,10 @@ bool Sema::hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested,
   } else if (auto *ED = dyn_cast<EnumDecl>(D)) {
     if (auto *Pattern = ED->getTemplateInstantiationPattern())
       ED = Pattern;
-    if (OnlyNeedComplete && !ED->getIntegerType().isNull()) {
-      // If the enum has an integer type, it may have been forward declared.
-      // Since we're only looking for a complete type (not a definition), any
-      // visible declaration of it will do.
+    if (OnlyNeedComplete && ED->isFixed()) {
+      // If the enum has a fixed underlying type, and we're only looking for a
+      // complete type (not a definition), any visible declaration of it will
+      // do.
       *Suggested = nullptr;
       for (auto *Redecl : ED->redecls()) {
         if (isVisible(Redecl))

diff  --git a/clang/test/Modules/Inputs/ms-enums/A.h b/clang/test/Modules/Inputs/ms-enums/A.h
deleted file mode 100644
index 168445221c03..000000000000
--- a/clang/test/Modules/Inputs/ms-enums/A.h
+++ /dev/null
@@ -1 +0,0 @@
-enum fwd_enum;

diff  --git a/clang/test/Modules/Inputs/ms-enums/B.h b/clang/test/Modules/Inputs/ms-enums/B.h
deleted file mode 100644
index 7a13ba4d72d4..000000000000
--- a/clang/test/Modules/Inputs/ms-enums/B.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "A.h"

diff  --git a/clang/test/Modules/Inputs/ms-enums/module.map b/clang/test/Modules/Inputs/ms-enums/module.map
deleted file mode 100644
index d9aed01430c4..000000000000
--- a/clang/test/Modules/Inputs/ms-enums/module.map
+++ /dev/null
@@ -1,2 +0,0 @@
-module A { header "A.h" }
-module B { header "B.h" }

diff  --git a/clang/test/Modules/ms-enums.cpp b/clang/test/Modules/ms-enums.cpp
deleted file mode 100644
index b3a377c6fa63..000000000000
--- a/clang/test/Modules/ms-enums.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -fms-compatibility -x c++ -std=c++20 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/ms-enums %s -verify -fno-modules-error-recovery
-
-#include "B.h"
-// expected-note at A.h:1 {{previous declaration is here}}
-// expected-note at A.h:1 2 {{previous definition is here}}
-
-fwd_enum gv_enum; // expected-error {{must be imported}}
-
-struct Foo {
-  enum fwd_enum enum_field; // expected-error 2 {{must be imported}}
-};


        


More information about the cfe-commits mailing list