]> git.ozlabs.org Git - ccan/commitdiff
cast: test/compile_fail-cast_static.c should fail without COMPOUND_LITERALS.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 27 Mar 2012 05:10:45 +0000 (15:40 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 27 Mar 2012 05:10:45 +0000 (15:40 +1030)
It still gave a warning on gcc, because casting a char to a char* gives a warning.  Not so on sun CC.

ccan/cast/test/compile_fail-cast_static.c

index 0f9e4780470a267dbf4573b76bd4791ba58f70b3..a4ebf61b1ae66549a792771ca1085701b9efce0b 100644 (file)
@@ -3,15 +3,21 @@
 
 int main(int argc, char *argv[])
 {
-       char c;
+       long c;
 #ifdef FAIL
        char *
 #else
-       long
+       char
 #endif
                x = 0;
 
-       c = cast_static(char, x);
+       c = cast_static(long, x);
        (void) c; /* Suppress unused-but-set-variable warning. */
        return 0;
 }
+
+#ifdef FAIL
+#if !HAVE_COMPOUND_LITERALS
+#error "Unfortunately we don't fail if cast_static without compound literals"
+#endif
+#endif