Browse Source

cast: test/compile_fail-cast_static.c should fail without COMPOUND_LITERALS.

It still gave a warning on gcc, because casting a char to a char* gives a warning.  Not so on sun CC.
Rusty Russell 14 years ago
parent
commit
6569a707d1
1 changed files with 9 additions and 3 deletions
  1. 9 3
      ccan/cast/test/compile_fail-cast_static.c

+ 9 - 3
ccan/cast/test/compile_fail-cast_static.c

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