Don't warn when alignment of global common data exceeds maximum alignment.
[official-gcc.git] / gcc / testsuite / jit.dg / test-long-string-literal.c
blob6caaa781c0b97f05488c29be4649b6887224db28
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <assert.h>
6 #include "libgccjit.h"
8 #include "harness.h"
10 const char very_long_string[] =
11 "abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc"
12 "abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc"
13 "abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc"
14 "abcabcabcabcabcabcabcabcabcabca";
16 void
17 create_code (gcc_jit_context *ctxt, void *user_data)
19 /* Build the test_fn. */
20 gcc_jit_function *f =
21 gcc_jit_context_new_function (
22 ctxt, NULL,
23 GCC_JIT_FUNCTION_EXPORTED,
24 gcc_jit_context_get_type(ctxt,
25 GCC_JIT_TYPE_CONST_CHAR_PTR),
26 "test_long_string_literal",
27 0, NULL, 0);
28 gcc_jit_block *blk =
29 gcc_jit_function_new_block (f, "init_block");
31 /* very_long_string is longer than 200 characters to specifically
32 check that the previous limitation no longer apply. */
34 assert (sizeof (very_long_string) > 200);
35 gcc_jit_rvalue *res =
36 gcc_jit_context_new_string_literal (ctxt, very_long_string);
38 gcc_jit_block_end_with_return (blk, NULL, res);
41 void
42 verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
44 typedef const char *(*fn_type) (void);
45 CHECK_NON_NULL (result);
46 fn_type test_long_string_literal =
47 (fn_type)gcc_jit_result_get_code (result, "test_long_string_literal");
48 CHECK_NON_NULL (test_long_string_literal);
50 /* Call the JIT-generated function. */
51 const char *str = test_long_string_literal ();
52 CHECK_NON_NULL (str);
53 CHECK_VALUE (strcmp (str, very_long_string), 0);