llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

Fixes https://github.com/llvm/llvm-project/issues/177587

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.h (+2-2) 
- (modified) clang/test/AST/ByteCode/c.c (+8) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 3313e819e694b..ca5b1fd6bf072 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -1164,14 +1164,14 @@ inline bool CmpHelperEQ<Pointer>(InterpState &S, 
CodePtr OpPC, CompareFn Fn) {
 
   // Otherwise we need to do a bunch of extra checks before returning 
Unordered.
   if (LHS.isOnePastEnd() && !RHS.isOnePastEnd() && !RHS.isZero() &&
-      RHS.getOffset() == 0) {
+      RHS.isBlockPointer() && RHS.getOffset() == 0) {
     const SourceInfo &Loc = S.Current->getSource(OpPC);
     S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_past_end)
         << LHS.toDiagnosticString(S.getASTContext());
     return false;
   }
   if (RHS.isOnePastEnd() && !LHS.isOnePastEnd() && !LHS.isZero() &&
-      LHS.getOffset() == 0) {
+      LHS.isBlockPointer() && LHS.getOffset() == 0) {
     const SourceInfo &Loc = S.Current->getSource(OpPC);
     S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_past_end)
         << RHS.toDiagnosticString(S.getASTContext());
diff --git a/clang/test/AST/ByteCode/c.c b/clang/test/AST/ByteCode/c.c
index 7b98aa84a482c..9496f8060884a 100644
--- a/clang/test/AST/ByteCode/c.c
+++ b/clang/test/AST/ByteCode/c.c
@@ -425,3 +425,11 @@ int complexMul[2 * (22222222222wb + 2i) == 2]; // 
all-warning {{'_BitInt' suffix
 int complexDiv[2 / (22222222222wb + 2i) == 2]; // all-warning {{'_BitInt' 
suffix for literals is a C23 extension}} \
                                                // pedantic-warning {{imaginary 
constants are a C2y extension}} \
                                                // all-warning {{variable 
length array folded to constant array as an extension}}
+
+
+
+int i = 0;
+void intPtrCmp1(void) { &i + 1 == 2; } // all-warning {{comparison between 
pointer and integer}} \
+                                       // all-warning {{equality comparison 
result unused}}
+void intPtrCmp2(void) { 2 == &i + 1; } // all-warning {{comparison between 
pointer and integer}} \
+                                       // all-warning {{equality comparison 
result unused}}

``````````

</details>


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

Reply via email to