llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

Add the base class offset so they don't all compare equal.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Pointer.cpp (+1-2) 
- (modified) clang/test/AST/ByteCode/cxx11.cpp (+2-2) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/Pointer.cpp 
b/clang/lib/AST/ByteCode/Pointer.cpp
index 9e91b1461fda9..995a4495f1438 100644
--- a/clang/lib/AST/ByteCode/Pointer.cpp
+++ b/clang/lib/AST/ByteCode/Pointer.cpp
@@ -392,8 +392,7 @@ Pointer::computeOffsetForComparison(const ASTContext 
&ASTCtx) const {
     }
 
     if (P.isBaseClass()) {
-      if (P.getRecord()->getNumVirtualBases() > 0)
-        Result += P.getInlineDesc()->Offset;
+      Result += P.getInlineDesc()->Offset - sizeof(InlineDescriptor);
       P = P.getBase();
       continue;
     }
diff --git a/clang/test/AST/ByteCode/cxx11.cpp 
b/clang/test/AST/ByteCode/cxx11.cpp
index 5d217f0bdd6cc..ffe2f3c67c511 100644
--- a/clang/test/AST/ByteCode/cxx11.cpp
+++ b/clang/test/AST/ByteCode/cxx11.cpp
@@ -469,8 +469,8 @@ namespace SubobjectCompare {
   constexpr Z z{};
   static_assert(&z.x < &z.y, ""); // both-error {{not an integral constant 
expression}} \
                                   // both-note {{comparison of addresses of 
subobjects of different base classes has unspecified value}}
-  static_assert(&z.x != &z.y, ""); // expected-error {{failed}} FIXME
+  static_assert(&z.x != &z.y, "");
   static_assert((void*)(X*)&z < (void*)(Y*)&z, ""); // both-error {{not an 
integral constant expression}} \
                                                     // both-note {{comparison 
of addresses of subobjects of different base classes has unspecified value}}
-  static_assert((void*)(X*)&z != (void*)(Y*)&z, ""); // expected-error 
{{failed}} FIXME
+  static_assert((void*)(X*)&z != (void*)(Y*)&z, "");
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/204052
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to