Skip to content

Conversation

@tbaederr
Copy link
Contributor

... for composite element types. Looks like I forgot this in e6030d3

... for composite element types. Looks like I forgot this in
e6030d3
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Feb 12, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 12, 2025

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

... for composite element types. Looks like I forgot this in e6030d3


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

2 Files Affected:

  • (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+1-1)
  • (modified) clang/test/AST/ByteCode/new-delete.cpp (+10-2)
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 0e586725b5869..55ac41736344d 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1683,7 +1683,7 @@ static bool interp__builtin_operator_new(InterpState &S, CodePtr OpPC,
   assert(!ElemT);
   // Structs etc.
   const Descriptor *Desc = S.P.createDescriptor(
-      Call, ElemType.getTypePtr(), Descriptor::InlineDescMD,
+      NewCall, ElemType.getTypePtr(), Descriptor::InlineDescMD,
       /*IsConst=*/false, /*IsTemporary=*/false, /*IsMutable=*/false,
       /*Init=*/nullptr);
 
diff --git a/clang/test/AST/ByteCode/new-delete.cpp b/clang/test/AST/ByteCode/new-delete.cpp
index e60ff894c9715..31f066b37858d 100644
--- a/clang/test/AST/ByteCode/new-delete.cpp
+++ b/clang/test/AST/ByteCode/new-delete.cpp
@@ -840,10 +840,17 @@ template <typename T>
 struct SS {
     constexpr SS(unsigned long long N)
     : data(nullptr){
-        data = alloc.allocate(N);  // #call
+        data = alloc.allocate(N);
         for(std::size_t i = 0; i < N; i ++)
-            std::construct_at<T>(data + i, i); // #construct_call
+            std::construct_at<T>(data + i, i);
     }
+
+    constexpr SS()
+    : data(nullptr){
+        data = alloc.allocate(1);
+        std::construct_at<T>(data);
+    }
+
     constexpr T operator[](std::size_t i) const {
       return data[i];
     }
@@ -855,6 +862,7 @@ struct SS {
     T* data;
 };
 constexpr unsigned short ssmall = SS<unsigned short>(100)[42];
+constexpr auto Ss = SS<S>()[0];
 
 
 

@tbaederr tbaederr merged commit 20506a0 into llvm:main Feb 12, 2025
11 checks passed
flovent pushed a commit to flovent/llvm-project that referenced this pull request Feb 13, 2025
... for composite element types. Looks like I forgot this in
e6030d3
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
... for composite element types. Looks like I forgot this in
e6030d3
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
... for composite element types. Looks like I forgot this in
e6030d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants