================
@@ -11541,30 +11541,33 @@ static void diagnoseSubtractionOnNullPointer(Sema &S, 
SourceLocation Loc,
 
 /// Diagnose invalid arithmetic on two function pointers.
 static void diagnoseArithmeticOnTwoFunctionPointers(Sema &S, SourceLocation 
Loc,
-                                                    Expr *LHS, Expr *RHS) {
-  assert(LHS->getType()->isAnyPointerType());
-  assert(RHS->getType()->isAnyPointerType());
+                                                    Expr *LHS, Expr *RHS,
+                                                    QualType LHSType,
+                                                    QualType RHSType) {
----------------
Kristianerik wrote:

I investigated the pre/post conversion split by creating a 
`diagnosePointerArithmeticOnFunctionPointer` function to handle the 
function/void pointer diagnostics before conversion, and slimmed 
`checkArithmeticOpPointerOperand` to only do the post-conversion 
incomplete-type check.

This caused 34 test failures. The root issue is that the checks in 
`checkArithmeticOpPointerOperand` aren't independent. For example, the void 
pointer diagnostic fires first and returns early in C++, which prevents the 
incomplete-type check from also firing on the same void pointer. Splitting them 
into separate functions breaks this ordering, causing duplicate or incorrect 
diagnostics downstream.

A clean split would require restructuring 
`checkArithmeticBinOpPointerOperands`, `CheckAdditionOperands`, and 
`CheckSubtractionOperands` as well. 

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

Reply via email to