llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

We shouldn't abort here when compiling, this is happening (and properly 
diagnosed) when interpreting the bytecode.

---
Full diff: https://github.com/llvm/llvm-project/pull/127448.diff


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+1-1) 
- (modified) clang/test/AST/ByteCode/new-delete.cpp (+11-1) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index c8ace39d56fd0..59c236c9da8c8 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -3029,7 +3029,7 @@ bool Compiler<Emitter>::VisitCXXConstructExpr(const 
CXXConstructExpr *E) {
 
     size_t NumElems = CAT->getZExtSize();
     const Function *Func = getFunction(E->getConstructor());
-    if (!Func || !Func->isConstexpr())
+    if (!Func)
       return false;
 
     // FIXME(perf): We're calling the constructor once per array element here,
diff --git a/clang/test/AST/ByteCode/new-delete.cpp 
b/clang/test/AST/ByteCode/new-delete.cpp
index 31f066b37858d..e9850d27666e5 100644
--- a/clang/test/AST/ByteCode/new-delete.cpp
+++ b/clang/test/AST/ByteCode/new-delete.cpp
@@ -865,7 +865,6 @@ constexpr unsigned short ssmall = SS<unsigned 
short>(100)[42];
 constexpr auto Ss = SS<S>()[0];
 
 
-
 namespace IncompleteArray {
   struct A {
     int b = 10;
@@ -908,8 +907,19 @@ namespace IncompleteArray {
     return c;
   }
   static_assert(test4() == 12);
+}
 
+namespace NonConstexprArrayCtor {
+  struct S {
+    S() {} // both-note 2{{declared here}}
+  };
 
+  constexpr bool test() { // both-error {{never produces a constant 
expression}}
+     auto s = new S[1]; // both-note 2{{non-constexpr constructor}}
+     return true;
+  }
+  static_assert(test()); // both-error {{not an integral constant expression}} 
\
+                         // both-note {{in call to}}
 }
 
 #else

``````````

</details>


https://github.com/llvm/llvm-project/pull/127448
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to