================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:4246-4248
@@ -4245,2 +4245,5 @@
"pointers to incompatible types}0,1">;
+def err_sub_ptr_zero_size_types : Error<
+ "subtraction of pointers to types of zero length (%diff{$ and $)|}0,1 "
+ "is not allowed">;
def ext_typecheck_ordered_comparison_of_pointer_integer : ExtWarn<
----------------
This should be a warning, not an error. GCC accepts this code.
================
Comment at: lib/Sema/SemaExpr.cpp:6733
@@ +6732,3 @@
+ // If pointee type is a structure or union of zero size (GCC
extension),
+ // the subtraction does not have a sense.
+ CharUnits ElementSize = Context.getTypeSizeInChars(rpointee);
----------------
... does not *make* sense.
================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:4247
@@ +4246,3 @@
+def err_sub_ptr_zero_size_types : Error<
+ "subtraction of pointers to types of zero length (%diff{$ and $)|}0,1 "
+ "is not allowed">;
----------------
The pointee types must be the same modulo cv-qualifiers (which are irrelevant),
so there's no point naming both types. How about "subtraction of pointers to
type %0 with zero size has undefined behavior"?
http://llvm-reviews.chandlerc.com/D637
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits