From: Antoni Boucher <[email protected]>

gcc/analyzer/ChangeLog:
        PR analyzer/113923
        * checker-event.h: Add assertions.

gcc/jit/ChangeLog:
        PR analyzer/113923
        * jit-playback.cc: Specify BLOCK_SUPERCONTEXT.

gcc/testsuite/ChangeLog:
        PR analyzer/113923
        * jit.dg/all-non-failing-tests.h: Mention new test.
        * jit.dg/test-fanalyzer.c: New test.
---
 gcc/analyzer/checker-event.h                 |  2 +
 gcc/jit/jit-playback.cc                      |  1 +
 gcc/testsuite/jit.dg/all-non-failing-tests.h |  3 ++
 gcc/testsuite/jit.dg/test-fanalyzer.c        | 52 ++++++++++++++++++++
 4 files changed, 58 insertions(+)
 create mode 100644 gcc/testsuite/jit.dg/test-fanalyzer.c

diff --git a/gcc/analyzer/checker-event.h b/gcc/analyzer/checker-event.h
index 909e3889e28..27acef937a3 100644
--- a/gcc/analyzer/checker-event.h
+++ b/gcc/analyzer/checker-event.h
@@ -640,6 +640,8 @@ public:
     m_apparent_callee_fndecl (apparent_callee_fndecl),
     m_apparent_caller_fndecl (apparent_caller_fndecl)
   {
+    gcc_assert (apparent_callee_fndecl != NULL);
+    gcc_assert (apparent_caller_fndecl != NULL);
     gcc_assert (LOCATION_BLOCK (loc) == NULL);
   }
 
diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc
index 291ddeb2cca..8978d9cad20 100644
--- a/gcc/jit/jit-playback.cc
+++ b/gcc/jit/jit-playback.cc
@@ -2125,6 +2125,7 @@ function (context *ctxt,
       m_stmt_list = alloc_stmt_list ();
       m_stmt_iter = tsi_start (m_stmt_list);
       m_inner_block = make_node (BLOCK);
+      BLOCK_SUPERCONTEXT (m_inner_block) = m_inner_fndecl;
       m_inner_bind_expr =
 	build3 (BIND_EXPR, void_type_node, NULL, m_stmt_list, m_inner_block);
     }
diff --git a/gcc/testsuite/jit.dg/all-non-failing-tests.h b/gcc/testsuite/jit.dg/all-non-failing-tests.h
index 4aa18e3b767..de68ec6136c 100644
--- a/gcc/testsuite/jit.dg/all-non-failing-tests.h
+++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h
@@ -467,6 +467,9 @@
 #undef create_code
 #undef verify_code
 
+/* test-fanalyzer.c: We don't use this one, since the use of
+   gcc_jit_context_add_command_line_option affects the whole context.  */
+
 /* test-ggc-bugfix.c: We don't use this once, since the use of
    gcc_jit_context_add_command_line_option and
    gcc_jit_context_add_driver_option affects the whole context.  */
diff --git a/gcc/testsuite/jit.dg/test-fanalyzer.c b/gcc/testsuite/jit.dg/test-fanalyzer.c
new file mode 100644
index 00000000000..b761edf48e4
--- /dev/null
+++ b/gcc/testsuite/jit.dg/test-fanalyzer.c
@@ -0,0 +1,52 @@
+#include "libgccjit.h"
+
+#include "harness.h"
+
+void
+create_code (gcc_jit_context *ctxt, void *user_data)
+{
+  gcc_jit_context_add_command_line_option (ctxt, "-fanalyzer");
+
+  gcc_jit_type *type___int8_t = gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT8_T);
+  gcc_jit_type *type___int64_t = gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT64_T);
+  gcc_jit_type *type_void = gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID);
+  gcc_jit_type *type___int8_t__ =
+    gcc_jit_type_get_pointer (type___int8_t);
+  gcc_jit_type *type_void__ =
+    gcc_jit_type_get_pointer (type_void);
+
+  gcc_jit_function *maybe_uninit_func =
+    gcc_jit_context_new_function (ctxt, NULL, GCC_JIT_FUNCTION_INTERNAL, 
+                                  type___int8_t__, "maybe_uninit", 0, NULL, 0);
+  gcc_jit_function_add_attribute (maybe_uninit_func, GCC_JIT_FN_ATTRIBUTE_INLINE);
+  gcc_jit_function_add_attribute (maybe_uninit_func, GCC_JIT_FN_ATTRIBUTE_ALWAYS_INLINE);
+  gcc_jit_block *block_start1 = gcc_jit_function_new_block (maybe_uninit_func, "start");
+  gcc_jit_lvalue *undefined_var =
+    gcc_jit_function_new_local (maybe_uninit_func, NULL, type_void__, "undefined");
+  gcc_jit_rvalue *rvalue_bitcast_undefined____int8_t___ =
+    gcc_jit_context_new_bitcast (ctxt, NULL, gcc_jit_lvalue_as_rvalue (undefined_var),
+                                 type___int8_t__);
+  gcc_jit_block_end_with_return (block_start1, NULL, rvalue_bitcast_undefined____int8_t___);
+
+  gcc_jit_function *func_main =
+    gcc_jit_context_new_function (ctxt, NULL, GCC_JIT_FUNCTION_EXPORTED,
+                                  type___int64_t, "main", 0, NULL, 0);
+  gcc_jit_block *block_start2 =
+    gcc_jit_function_new_block (func_main, "start");
+
+  gcc_jit_rvalue *call_maybe_uninit =
+    gcc_jit_context_new_call (ctxt, NULL, maybe_uninit_func, 0, NULL);
+
+  gcc_jit_lvalue *local_ptrReturnValue1 =
+    gcc_jit_function_new_local (func_main, NULL, type___int8_t__, "ptrReturnValue1");
+  gcc_jit_block_add_assignment (block_start2, NULL, local_ptrReturnValue1, call_maybe_uninit);
+
+  gcc_jit_rvalue *zero = gcc_jit_context_zero (ctxt, type___int64_t);
+  gcc_jit_block_end_with_return (block_start2, NULL, zero);
+}
+
+void
+verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
+{
+  CHECK_NON_NULL (result);
+}

Reply via email to