[clang] 6479e3c - [clang][Interp] Use proper type for non-primitive reference dummies

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Wed May 15 01:17:39 PDT 2024


Author: Timm Bäder
Date: 2024-05-15T10:17:09+02:00
New Revision: 6479e3cb66895754089dc017a33478e9eb4b8d65

URL: https://github.com/llvm/llvm-project/commit/6479e3cb66895754089dc017a33478e9eb4b8d65
DIFF: https://github.com/llvm/llvm-project/commit/6479e3cb66895754089dc017a33478e9eb4b8d65.diff

LOG: [clang][Interp] Use proper type for non-primitive reference dummies

Added: 
    

Modified: 
    clang/lib/AST/Interp/Program.cpp
    clang/test/AST/Interp/bitfields.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/Program.cpp b/clang/lib/AST/Interp/Program.cpp
index 31a64e13d2b15..e3d48d5a8ddb4 100644
--- a/clang/lib/AST/Interp/Program.cpp
+++ b/clang/lib/AST/Interp/Program.cpp
@@ -152,8 +152,7 @@ std::optional<unsigned> Program::getOrCreateDummy(const ValueDecl *VD) {
   if (std::optional<PrimType> T = Ctx.classify(QT))
     Desc = createDescriptor(VD, *T, std::nullopt, true, false);
   else
-    Desc = createDescriptor(VD, VD->getType().getTypePtr(), std::nullopt, true,
-                            false);
+    Desc = createDescriptor(VD, QT.getTypePtr(), std::nullopt, true, false);
   if (!Desc)
     Desc = allocateDescriptor(VD);
 

diff  --git a/clang/test/AST/Interp/bitfields.cpp b/clang/test/AST/Interp/bitfields.cpp
index d3a8a083063ab..5fc34bb1229d9 100644
--- a/clang/test/AST/Interp/bitfields.cpp
+++ b/clang/test/AST/Interp/bitfields.cpp
@@ -102,3 +102,24 @@ namespace Compound {
   }
   static_assert(div() == 1, "");
 }
+
+namespace test0 {
+  extern int int_source();
+  struct A {
+    int aField;
+    int bField;
+  };
+
+  struct B {
+    int onebit : 2;
+    int twobit : 6;
+    int intField;
+  };
+
+  struct C : A, B {
+  };
+
+  void b(C &c) {
+    c.onebit = int_source();
+  }
+}


        


More information about the cfe-commits mailing list