From 6b1463c4de3ae182fac6b5f2d15248d87c2f9613 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Thu, 29 Mar 2018 18:12:21 +0200 Subject: Reject casts to struct/union types (#68) The ISO C99 standard allows cast only if the type name involved is either a void type or a scalar type. For compatibility with GCC and Clang we used to support casting a struct or union to exactly the same struct or union type. That does not seem useful in practice and complicates conformance testing. This commit gets rid of this exception to the C99 rule. Bug 23310 --- cparser/Cutil.ml | 3 --- 1 file changed, 3 deletions(-) (limited to 'cparser/Cutil.ml') diff --git a/cparser/Cutil.ml b/cparser/Cutil.ml index 4a5c9427..f3cd5d14 100644 --- a/cparser/Cutil.ml +++ b/cparser/Cutil.ml @@ -1035,9 +1035,6 @@ let valid_cast env tfrom tto = (TInt _ | TPtr _ | TEnum _) -> true (* between int and float types *) | (TInt _ | TFloat _ | TEnum _), (TInt _ | TFloat _ | TEnum _) -> true - (* between identical composites *) - | TStruct(s1, _), TStruct(s2, _) -> s1 = s2 - | TUnion(s1, _), TUnion(s2, _) -> s1 = s2 | _, _ -> false (* Check that the cast from tfrom to tto is an integer to pointer conversion *) -- cgit