This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG40c26ec48c8a: [clang][Interp] Fix diagnosing uninitialized 
ctor record arrays (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D143334?vs=494879&id=526970#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143334/new/

https://reviews.llvm.org/D143334

Files:
  clang/lib/AST/Interp/Interp.cpp
  clang/test/AST/Interp/cxx20.cpp


Index: clang/test/AST/Interp/cxx20.cpp
===================================================================
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -138,8 +138,8 @@
 namespace UninitializedFields {
   class A {
   public:
-    int a; // expected-note 2{{subobject declared here}} \
-           // ref-note 2{{subobject declared here}}
+    int a; // expected-note 3{{subobject declared here}} \
+           // ref-note 3{{subobject declared here}}
     constexpr A() {}
   };
   constexpr A a; // expected-error {{must be initialized by a constant 
expression}} \
@@ -174,19 +174,15 @@
                    // ref-error {{must be initialized by a constant 
expression}} \
                    // ref-note {{subobject 'a' is not initialized}}
 
-
-  // FIXME: These two are currently disabled because the array fields
-  //   cannot be initialized.
-#if 0
   class C3 {
   public:
     A a[2];
     constexpr C3() {}
   };
   constexpr C3 c3; // expected-error {{must be initialized by a constant 
expression}} \
-                   // expected-note {{subobject of type 'int' is not 
initialized}} \
+                   // expected-note {{subobject 'a' is not initialized}} \
                    // ref-error {{must be initialized by a constant 
expression}} \
-                   // ref-note {{subobject of type 'int' is not initialized}}
+                   // ref-note {{subobject 'a' is not initialized}}
 
   class C4 {
   public:
@@ -195,10 +191,9 @@
     constexpr C4(){}
   };
   constexpr C4 c4; // expected-error {{must be initialized by a constant 
expression}} \
-                   // expected-note {{subobject of type 'bool' is not 
initialized}} \
+                   // expected-note {{subobject 'B' is not initialized}} \
                    // ref-error {{must be initialized by a constant 
expression}} \
-                   // ref-note {{subobject of type 'bool' is not initialized}}
-#endif
+                   // ref-note {{subobject 'B' is not initialized}}
 };
 
 namespace ConstThis {
Index: clang/lib/AST/Interp/Interp.cpp
===================================================================
--- clang/lib/AST/Interp/Interp.cpp
+++ clang/lib/AST/Interp/Interp.cpp
@@ -386,7 +386,7 @@
   size_t NumElems = CAT->getSize().getZExtValue();
   QualType ElemType = CAT->getElementType();
 
-  if (isa<RecordType>(ElemType.getTypePtr())) {
+  if (ElemType->isRecordType()) {
     const Record *R = BasePtr.getElemRecord();
     for (size_t I = 0; I != NumElems; ++I) {
       Pointer ElemPtr = BasePtr.atIndex(I).narrow();


Index: clang/test/AST/Interp/cxx20.cpp
===================================================================
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -138,8 +138,8 @@
 namespace UninitializedFields {
   class A {
   public:
-    int a; // expected-note 2{{subobject declared here}} \
-           // ref-note 2{{subobject declared here}}
+    int a; // expected-note 3{{subobject declared here}} \
+           // ref-note 3{{subobject declared here}}
     constexpr A() {}
   };
   constexpr A a; // expected-error {{must be initialized by a constant expression}} \
@@ -174,19 +174,15 @@
                    // ref-error {{must be initialized by a constant expression}} \
                    // ref-note {{subobject 'a' is not initialized}}
 
-
-  // FIXME: These two are currently disabled because the array fields
-  //   cannot be initialized.
-#if 0
   class C3 {
   public:
     A a[2];
     constexpr C3() {}
   };
   constexpr C3 c3; // expected-error {{must be initialized by a constant expression}} \
-                   // expected-note {{subobject of type 'int' is not initialized}} \
+                   // expected-note {{subobject 'a' is not initialized}} \
                    // ref-error {{must be initialized by a constant expression}} \
-                   // ref-note {{subobject of type 'int' is not initialized}}
+                   // ref-note {{subobject 'a' is not initialized}}
 
   class C4 {
   public:
@@ -195,10 +191,9 @@
     constexpr C4(){}
   };
   constexpr C4 c4; // expected-error {{must be initialized by a constant expression}} \
-                   // expected-note {{subobject of type 'bool' is not initialized}} \
+                   // expected-note {{subobject 'B' is not initialized}} \
                    // ref-error {{must be initialized by a constant expression}} \
-                   // ref-note {{subobject of type 'bool' is not initialized}}
-#endif
+                   // ref-note {{subobject 'B' is not initialized}}
 };
 
 namespace ConstThis {
Index: clang/lib/AST/Interp/Interp.cpp
===================================================================
--- clang/lib/AST/Interp/Interp.cpp
+++ clang/lib/AST/Interp/Interp.cpp
@@ -386,7 +386,7 @@
   size_t NumElems = CAT->getSize().getZExtValue();
   QualType ElemType = CAT->getElementType();
 
-  if (isa<RecordType>(ElemType.getTypePtr())) {
+  if (ElemType->isRecordType()) {
     const Record *R = BasePtr.getElemRecord();
     for (size_t I = 0; I != NumElems; ++I) {
       Pointer ElemPtr = BasePtr.atIndex(I).narrow();
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to