├── .gitignore ├── .readthedocs.yaml ├── Documentation ├── .gitignore ├── IR.rst ├── Makefile ├── TODO.md ├── annotations.rst ├── api.rst ├── arm64-detecting-tagged-addresses.txt ├── conf.py ├── data-structures.txt ├── dev-options.rst ├── doc-guide.rst ├── index.rst ├── logo.svg ├── release-notes │ ├── index.rst │ ├── v0.1.rst │ ├── v0.2.rst │ ├── v0.3.rst │ ├── v0.4.1.rst │ ├── v0.4.2.rst │ ├── v0.4.3.rst │ ├── v0.4.4.rst │ ├── v0.4.5-rc1.rst │ ├── v0.4.rst │ ├── v0.5.0.rst │ ├── v0.5.1.rst │ ├── v0.5.2.rst │ ├── v0.6.0.rst │ ├── v0.6.1.rst │ ├── v0.6.2.rst │ ├── v0.6.3.rst │ └── v0.6.4.rst ├── requirements.txt ├── smatch.rst ├── sparse-README.txt ├── sphinx │ ├── cdoc.py │ ├── ir.py │ └── static │ │ └── theme_overrides.css ├── submitting-patches.md ├── templates │ ├── breadcrumbs.html │ └── layout.html ├── test-suite.rst └── types.rst ├── FAQ ├── GPL-2 ├── LICENSE ├── Makefile ├── README ├── allocate.c ├── allocate.h ├── ast-inspect.c ├── ast-inspect.h ├── ast-model.c ├── ast-model.h ├── ast-view.c ├── ast-view.h ├── avl.c ├── avl.h ├── bitmap.h ├── bits.h ├── builtin.c ├── builtin.h ├── c2xml.c ├── cgcc ├── cgcc.1 ├── char.c ├── char.h ├── check_64bit_shift.c ├── check_access_ok_math.c ├── check_all_func_returns.c ├── check_allocating_enough_data.c ├── check_allocation_funcs.c ├── check_always_true.c ├── check_arm64_tagged.c ├── check_array_condition.c ├── check_assign_vs_compare.c ├── check_bit_shift.c ├── check_bogus_address_param.c ├── check_bogus_irqrestore.c ├── check_bogus_loop.c ├── check_buffer_too_small_for_struct.c ├── check_call_tree.c ├── check_capable.c ├── check_cast_assign.c ├── check_check_deref.c ├── check_checking_for_null_instead_of_err_ptr.c ├── check_cmn_err.c ├── check_container_of.c ├── check_continue_vs_break.c ├── check_debug.c ├── check_debug.h ├── check_deref.c ├── check_deref_check.c ├── check_dereferences_param.c ├── check_dev_queue_xmit.c ├── check_direct_return_instead_of_goto.c ├── check_dma_on_stack.c ├── check_do_while_loop_limit.c ├── check_double_checking.c ├── check_double_fget.c ├── check_err_ptr.c ├── check_err_ptr_deref.c ├── check_expects_err_ptr.c ├── check_free.c ├── check_free_strict.c ├── check_freeing_devm.c ├── check_freeing_null.c ├── check_frees_argument.c ├── check_frees_param.c ├── check_frees_param_strict.c ├── check_get_user_overflow.c ├── check_gfp_dma.c ├── check_host_input.c ├── check_ida_alloc.c ├── check_implicit_dependencies.c ├── check_implicit_dependencies_tester.c ├── check_impossible_compare.c ├── check_impossible_mask.c ├── check_inconsistent_locking.c ├── check_indenting.c ├── check_index_overflow.c ├── check_info_leak.c ├── check_input_free_device.c ├── check_integer_overflow_sizeof.c ├── check_iterator_outside_loop.c ├── check_kernel.c ├── check_kernel_printf.c ├── check_kmalloc_to_bugon.c ├── check_kmalloc_wrong_size.c ├── check_kunmap.c ├── check_kvmalloc_NOFS.c ├── check_kvmalloc_array_zero.c ├── check_leaks.c ├── check_list.h ├── check_list_add.c ├── check_logical_instead_of_bitwise.c ├── check_macro_side_effects.c ├── check_macros.c ├── check_memcpy_overflow.c ├── check_memset.c ├── check_min_t.c ├── check_missing_error_code.c ├── check_missing_error_code2.c ├── check_mixing_irq_and_irqsave.c ├── check_mod_timer.c ├── check_negative_error_code_type_promoted.c ├── check_netdev_priv.c ├── check_no_effect.c ├── check_no_if_block.c ├── check_no_increment.c ├── check_no_null_check_on_mixed.c ├── check_no_return.c ├── check_nospec.c ├── check_not_passing_gfp.c ├── check_off_by_one_relative.c ├── check_or_vs_and.c ├── check_param_mapper.c ├── check_passes_sizeof.c ├── check_platform_device_put.c ├── check_platform_get_irq_return.c ├── check_pm_runtime_get_sync.c ├── check_pointer_math.c ├── check_postop_timeout.c ├── check_precedence.c ├── check_preempt.c ├── check_preempt_info.c ├── check_proc_create.c ├── check_puts_argument.c ├── check_refcount_inconsistent_returns.c ├── check_release_resource.c ├── check_resource_size.c ├── check_return.c ├── check_return_cast.c ├── check_return_efault.c ├── check_return_enomem.c ├── check_return_negative_var.c ├── check_returns_negative_error_code.c ├── check_rosenberg.c ├── check_scheduling_in_atomic.c ├── check_select.c ├── check_select_type.c ├── check_sentinel_ctltable.c ├── check_shift_to_zero.c ├── check_signed.c ├── check_signed_integer_overflow_check.c ├── check_sizeof.c ├── check_sleep_info.c ├── check_snprintf.c ├── check_snprintf_overflow.c ├── check_spectre.c ├── check_spectre_second_half.c ├── check_sprintf_overflow.c ├── check_sscanf_return.c ├── check_stack.c ├── check_strcpy_overflow.c ├── check_string_len.c ├── check_struct_type.c ├── check_syscall_arg_type.c ├── check_template.c ├── check_test_bit.c ├── check_testing_index_after_use.c ├── check_type.c ├── check_unchecked_allocation.c ├── check_uninitialized.c ├── check_uninitialized_kobj.c ├── check_units.c ├── check_unlikely_parens.c ├── check_unreachable.c ├── check_unsigned_lt_zero.c ├── check_unused_ret.c ├── check_unwind.c ├── check_wait_for_common.c ├── check_wine.c ├── check_wine_WtoA.c ├── check_wine_filehandles.c ├── check_wrong_size_arg.c ├── check_zero_to_err_ptr.c ├── compat-bsd.c ├── compat-cygwin.c ├── compat-linux.c ├── compat-mingw.c ├── compat-solaris.c ├── compat.h ├── compat ├── bswap.h ├── mmap-blob.c └── strtold.c ├── compile-i386.c ├── compile.c ├── compile.h ├── cse.c ├── cse.h ├── ctags.c ├── cwchash ├── Makefile ├── hashtable.c ├── hashtable.h ├── hashtable_itr.c ├── hashtable_itr.h ├── hashtable_private.h ├── hashtable_utility.c ├── hashtable_utility.h └── tester.c ├── dissect.c ├── dissect.h ├── dominate.c ├── dominate.h ├── evaluate.c ├── evaluate.h ├── example.c ├── expand.c ├── expand.h ├── expression.c ├── expression.h ├── flow.c ├── flow.h ├── flowgraph.c ├── flowgraph.h ├── gcc-attr-list.h ├── gdbhelpers ├── graph.c ├── gvpr ├── return-paths ├── subg-fwd └── subg-rev ├── ident-list.h ├── inline.c ├── ir.c ├── ir.h ├── lib.c ├── lib.h ├── linearize.c ├── linearize.h ├── liveness.c ├── liveness.h ├── machine.h ├── macro_table.c ├── memops.c ├── obfuscate.c ├── opcode.c ├── opcode.def ├── opcode.h ├── optimize.c ├── optimize.h ├── options.c ├── options.h ├── parse.c ├── parse.dtd ├── parse.h ├── pre-process.c ├── predefine.c ├── ptrlist.c ├── ptrlist.h ├── ptrmap.c ├── ptrmap.h ├── scheck.c ├── scope.c ├── scope.h ├── semind.1 ├── semind.c ├── show-parse.c ├── simplify.c ├── simplify.h ├── sm_hash.c ├── smatch.c ├── smatch.h ├── smatch_about_fn_ptr_arg.c ├── smatch_address.c ├── smatch_allocations.c ├── smatch_annotate.c ├── smatch_array_values.c ├── smatch_assigned_expr.c ├── smatch_bits.c ├── smatch_buf_comparison.c ├── smatch_buf_comparison2.c ├── smatch_buf_size.c ├── smatch_capped.c ├── smatch_common_functions.c ├── smatch_comparison.c ├── smatch_conditions.c ├── smatch_constants.h ├── smatch_constraints.c ├── smatch_constraints_required.c ├── smatch_container_of.c ├── smatch_data ├── db │ ├── apply_return_fixes.sh │ ├── build_early_index.sh │ ├── build_late_index.sh │ ├── call_implies.schema │ ├── caller_info.schema │ ├── clear_user_data.sh │ ├── common_caller_info.schema │ ├── constraints.schema │ ├── constraints_required.schema │ ├── copy_function_pointers.pl │ ├── copy_required_constraints.pl │ ├── create_db.sh │ ├── data_info.schema │ ├── db.schema │ ├── delete_too_common_fn_ptr.sh │ ├── fill_db_caller_info.pl │ ├── fill_db_sql.pl │ ├── fill_db_type_size.pl │ ├── fill_db_type_value.pl │ ├── fixup_all.sh │ ├── fixup_kernel.sh │ ├── fixup_smatch_generic.sh │ ├── fn_data_link.schema │ ├── fn_ptr_data_link.schema │ ├── function_ptr.schema │ ├── function_type.schema │ ├── function_type_info.schema │ ├── function_type_size.schema │ ├── function_type_value.schema │ ├── hash_string.schema │ ├── init_constraints.pl │ ├── init_constraints_required.pl │ ├── insert_manual_states.pl │ ├── kernel.constraints │ ├── kernel.constraints_required │ ├── kernel.delete.return_states │ ├── kernel.forced_return_splits │ ├── kernel.insert.return_states │ ├── kernel.return_fixes │ ├── local_values.schema │ ├── mark_function_ptrs_searchable.pl │ ├── mtag_about.schema │ ├── mtag_alias.schema │ ├── mtag_data.schema │ ├── mtag_info.schema │ ├── mtag_map.schema │ ├── param_map.schema │ ├── parameter_name.schema │ ├── reload_partial.sh │ ├── remove_mixed_up_pointer_params.pl │ ├── return_implies.schema │ ├── return_states.schema │ ├── sink_info.schema │ ├── smdb.py │ ├── type_info.schema │ ├── type_size.schema │ ├── type_value.schema │ └── vim_smdb ├── kernel.allocation_funcs ├── kernel.allocation_funcs.remove ├── kernel.allocation_funcs_gfp ├── kernel.allocation_funcs_gfp.remove ├── kernel.bit_shifters ├── kernel.bit_shifters.remove ├── kernel.check_string_condition.ignore ├── kernel.clears_argument ├── kernel.common_functions ├── kernel.dev_queue_xmit ├── kernel.dma_funcs ├── kernel.expects_err_ptr ├── kernel.frees_argument ├── kernel.frees_argument.remove ├── kernel.gfp_flags ├── kernel.ignore_casted_params ├── kernel.ignore_macro_indenting ├── kernel.ignore_memcpy_struct_overflows ├── kernel.ignore_no_effect ├── kernel.ignore_side_effects ├── kernel.ignore_uninitialized_param ├── kernel.ignored_macros ├── kernel.ignored_warnings ├── kernel.implicit_dependencies.no_structs ├── kernel.implicit_dependencies.v1 ├── kernel.ioctls ├── kernel.macro_takes_sizeof_argument ├── kernel.must_check_funcs ├── kernel.no_inline_functions ├── kernel.no_return_funcs ├── kernel.no_return_funcs.add ├── kernel.no_return_funcs.remove ├── kernel.parameter_implications.add ├── kernel.puts_argument ├── kernel.returns_err_ptr ├── kernel.returns_err_ptr.remove ├── kernel.rosenberg_funcs ├── kernel.silenced_functions ├── kernel.sizeof_param ├── kernel.sizeof_param.remove ├── kernel.skipped_macros ├── kernel.unconstant_macros ├── kernel.unreachable.ignore ├── kernel.unreachable.turn_off ├── kernel.unwind_functions ├── no_return_funcs ├── no_return_funcs.remove ├── smatch.common_functions ├── smatch_generic.common_functions ├── wine.bit_shifters ├── wine.ignored_macros ├── wine.no_return_funcs ├── wine.no_return_funcs.add ├── wine.no_return_funcs.remove └── wine.sizeof_param ├── smatch_data_source.c ├── smatch_db.c ├── smatch_dereference.c ├── smatch_equiv.c ├── smatch_estate.c ├── smatch_expression_stacks.c ├── smatch_expression_stacks.h ├── smatch_expressions.c ├── smatch_extra.c ├── smatch_extra.h ├── smatch_files.c ├── smatch_flow.c ├── smatch_fn_arg_link.c ├── smatch_fresh_alloc.c ├── smatch_function_hashtable.h ├── smatch_function_hooks.c ├── smatch_function_info.c ├── smatch_function_ptrs.c ├── smatch_goto_tracker.c ├── smatch_hash.c ├── smatch_helper.c ├── smatch_hooks.c ├── smatch_ignore.c ├── smatch_imaginary_absolute.c ├── smatch_implied.c ├── smatch_impossible.c ├── smatch_integer_overflow.c ├── smatch_kernel_atomic_dec_test_path.c ├── smatch_kernel_err_ptr.c ├── smatch_kernel_has_devm_cleanup.c ├── smatch_kernel_host_data.c ├── smatch_kernel_irq_context.c ├── smatch_kernel_kref_put.c ├── smatch_kernel_netdev_priv.c ├── smatch_kernel_task_state.c ├── smatch_kernel_task_state_info.c ├── smatch_kernel_user_data.c ├── smatch_kernel_xa_err.c ├── smatch_leaf_fn.c ├── smatch_links.c ├── smatch_locking.c ├── smatch_locking_info.c ├── smatch_locking_type.c ├── smatch_math.c ├── smatch_mem_tracker.c ├── smatch_modification_hooks.c ├── smatch_mtag.c ├── smatch_mtag_data.c ├── smatch_mtag_map.c ├── smatch_nul_terminator.c ├── smatch_param_bits_clear.c ├── smatch_param_bits_set.c ├── smatch_param_cleared.c ├── smatch_param_compare_limit.c ├── smatch_param_filter.c ├── smatch_param_key.c ├── smatch_param_limit.c ├── smatch_param_set.c ├── smatch_param_to_mtag_data.c ├── smatch_param_used.c ├── smatch_parameter_names.c ├── smatch_parse_call_math.c ├── smatch_parsed_conditions.c ├── smatch_passes_array_size.c ├── smatch_points_to_container.c ├── smatch_points_to_host_data.c ├── smatch_points_to_user_data.c ├── smatch_power_of_two.c ├── smatch_project.c ├── smatch_ranges.c ├── smatch_real_absolute.c ├── smatch_recurse.c ├── smatch_refcount.c ├── smatch_refcount_info.c ├── smatch_return_to_param.c ├── smatch_returns.c ├── smatch_scope.c ├── smatch_scripts ├── add_gfp_to_allocations.sh ├── build_generic_data.sh ├── build_kernel_data.sh ├── call_tree.pl ├── filter_kernel_deref_check.sh ├── find_expanded_holes.pl ├── find_null_params.sh ├── follow_params.pl ├── gen_allocation_list.sh ├── gen_bit_shifters.sh ├── gen_dma_funcs.sh ├── gen_err_ptr_list.sh ├── gen_expects_err_ptr.sh ├── gen_frees_list.sh ├── gen_gfp_flags.sh ├── gen_implicit_dependencies.sh ├── gen_no_return_funcs.sh ├── gen_puts_list.sh ├── gen_rosenberg_funcs.sh ├── gen_sizeof_param.sh ├── gen_unwind_functions.sh ├── generisize.pl ├── implicit_dependencies │ ├── README │ ├── constants.py │ ├── main.py │ ├── parser.py │ ├── with_structs │ │ ├── implicit_dependencies │ │ ├── implicit_dependencies.json │ │ ├── implicit_dependencies.pretty │ │ ├── implicit_dependencies_verbose │ │ ├── implicit_dependencies_verbose.json │ │ └── implicit_dependencies_verbose.pretty │ └── without_structs │ │ ├── implicit_dependencies.json │ │ ├── implicit_dependencies.pretty │ │ ├── implicit_dependencies_verbose.json │ │ └── implicit_dependencies_verbose.pretty ├── kchecker ├── kpatch.sh ├── new_bugs.pl ├── show_errs.sh ├── show_ifs.sh ├── show_unreachable.sh ├── strip_whitespace.pl ├── summarize_errs.sh ├── test_generic.sh ├── test_kernel.sh ├── trace_params.pl ├── unlocked_paths.pl ├── whitespace_only.sh └── wine_checker.sh ├── smatch_simple_no_overflow.c ├── smatch_slist.c ├── smatch_slist.h ├── smatch_ssa.c ├── smatch_start_states.c ├── smatch_state_assigned.c ├── smatch_statement_count.c ├── smatch_states.c ├── smatch_stored_conditions.c ├── smatch_string_list.c ├── smatch_strings.c ├── smatch_strlen.c ├── smatch_struct_assignment.c ├── smatch_sval.c ├── smatch_tracker.c ├── smatch_type.c ├── smatch_type_links.c ├── smatch_type_val.c ├── smatch_unconstant_macros.c ├── smatch_units.c ├── smatch_unknown_value.c ├── smatch_untracked_param.c ├── smatch_untracked_var.c ├── smatch_var_sym.c ├── sort.c ├── sparse-llvm-dis ├── sparse-llvm.c ├── sparse.1 ├── sparse.c ├── sparsec ├── sparsei ├── ssa.c ├── ssa.h ├── stats.c ├── storage.c ├── storage.h ├── symbol.c ├── symbol.h ├── target-alpha.c ├── target-arm.c ├── target-arm64.c ├── target-bfin.c ├── target-default.c ├── target-h8300.c ├── target-m68k.c ├── target-microblaze.c ├── target-mips.c ├── target-nds32.c ├── target-nios2.c ├── target-openrisc.c ├── target-ppc.c ├── target-riscv.c ├── target-s390.c ├── target-sh.c ├── target-sparc.c ├── target-x86.c ├── target-xtensa.c ├── target.c ├── target.h ├── test-dissect.c ├── test-inspect.c ├── test-lexing.c ├── test-linearize.c ├── test-parsing.c ├── test-show-type.c ├── test-sort.c ├── test-unssa.c ├── token.h ├── token_store.c ├── tokenize.c ├── unssa.c ├── utils.c ├── utils.h ├── validation ├── .gitignore ├── Waddress-array.c ├── Waddress-function.c ├── Waddress-space-all-attr.c ├── Waddress-space-from.c ├── Waddress-space-strict.c ├── Waddress-weak.c ├── Waddress.c ├── Wcast-to-as.c ├── Woverride-init-def.c ├── Woverride-init-no.c ├── Woverride-init-yes.c ├── Wuniv-init-ko.c ├── Wuniv-init-ok.c ├── Wunknown-attribute-def.c ├── Wunknown-attribute-no.c ├── Wunknown-attribute-yes.c ├── __func__-scope.c ├── __func__.c ├── abi-integer.c ├── abstract-array-declarator-quals.c ├── abstract-array-declarator-star.c ├── abstract-array-declarator-static.c ├── abstract-array-declarator.c ├── address_space.c ├── alloc-align.c ├── alternate-keywords.c ├── anon-union.c ├── arch │ ├── arm-predef-float-abi-hard.c │ ├── arm-predef-float-abi-mixed.c │ ├── arm-predef-float-abi-soft.c │ ├── arm-predef-hard-float.c │ ├── arm-predef-soft-float.c │ ├── arm.c │ ├── arm64.c │ ├── mips32.c │ ├── riscv64.c │ └── short-wchar.c ├── array-implicit-size.c ├── as-name.c ├── asm-bad0.c ├── asm-empty-clobber.c ├── asm-goto-labels.c ├── asm-inline.c ├── attr-context.c ├── attr-inline.c ├── attr-no_sanitize_address.c ├── attr-noclone.c ├── attr-optimize.c ├── attr-visible.c ├── attr-visible2.c ├── attr-warning.c ├── attr_aligned.c ├── attr_in_parameter.c ├── attr_vector_size.c ├── autotype-ko.c ├── autotype.c ├── backend │ ├── arithmetic-ops.c │ ├── array.c │ ├── bitwise-ops.c │ ├── bool-test.c │ ├── call-variadic.c │ ├── cast.c │ ├── cmp-ops.c │ ├── compare-with-null.c │ ├── constant-pointer.c │ ├── degenerate-ptr.c │ ├── extern.c │ ├── fn-ref.c │ ├── function-ptr-xtype.c │ ├── function-ptr.c │ ├── hello.c │ ├── int-cond.c │ ├── label-as-value.c │ ├── load-global.c │ ├── load-type.c │ ├── logical-ops.c │ ├── loop.c │ ├── loop2.c │ ├── pointer-add.c │ ├── pointer-cmp.c │ ├── pointer-param.c │ ├── pointer-sub.c │ ├── ptrcast.c │ ├── setval.c │ ├── shift-special.c │ ├── store-type.c │ ├── store-x2.c │ ├── string-value.c │ ├── struct-access.c │ ├── struct.c │ ├── sum.c │ ├── switch.c │ ├── symaddr.c │ ├── type-constant.c │ ├── union.c │ └── void-return-type.c ├── bad-array-designated-initializer.c ├── bad-assignment.c ├── bad-cast.c ├── bad-check-access0.c ├── bad-return-type.c ├── bad-ternary-cond.c ├── bad-type-twice0.c ├── bad-type-twice1.c ├── bad-type-twice2.c ├── bad-typeof.c ├── badtype1.c ├── badtype2.c ├── badtype3.c ├── badtype4.c ├── badtype5.c ├── binary-constant.c ├── bitfield-bool-layout.c ├── bitfield-kr.c ├── bitfield-sizes.c ├── bitfields.c ├── bitwise-cast-ptr.c ├── bitwise-cast.c ├── bitwise-function-pointer.c ├── bool-array.c ├── bool-cast-bad.c ├── bool-cast-restricted.c ├── bool-float.c ├── bswap-constant-folding.c ├── bug-bad-type.c ├── bug-crash16.c ├── bug-rshift-ub.c ├── bug_inline_switch.c ├── build_smatch_db.sh ├── builtin-args-checking.c ├── builtin-arith.c ├── builtin-atomic-clear.c ├── builtin-bswap-constant.c ├── builtin-bswap-variable.c ├── builtin-fp-unop.c ├── builtin-objsize-dyn.c ├── builtin-objsize-self-init.c ├── builtin-objsize0.c ├── builtin-objsize1.c ├── builtin-overflow.c ├── builtin-prototype.c ├── builtin-sync-cas.c ├── builtin-sync-fetch.c ├── builtin_atomic.c ├── builtin_bswap.c ├── builtin_inf.c ├── builtin_safe1.c ├── builtin_unreachable.c ├── builtin_va_arg_pack.c ├── byte-count-max.c ├── c11-alignas.c ├── c11-alignof.c ├── c11-atomic.c ├── c11-noreturn.c ├── c11-stdc-version.c ├── c11-thread-local.c ├── c99-for-loop-decl.c ├── c99-for-loop.c ├── call-inlined.c ├── call-variadic.c ├── calling-convention-attributes.c ├── cast-bad-00.c ├── cast-bad-01.c ├── cast-kinds-check.c ├── cast-weirds.c ├── char-constant-signed.c ├── char-constant-unsigned.c ├── char-signed-native.c ├── char-signed.c ├── char-unsigned-native.c ├── char-unsigned.c ├── check_access-multi.c ├── check_access-store.c ├── check_byte_count-ice.c ├── choose_expr.c ├── comma.c ├── compare-null-to-int.c ├── compound-assign-type.c ├── compound-sizes.c ├── cond-address.c ├── cond-err-expand.c ├── cond_expr.c ├── cond_expr2.c ├── cond_expr3.c ├── conditional-type.c ├── constant-suffix-32.c ├── constant-suffix-64.c ├── constexpr-addr-of-static-member.c ├── constexpr-addr-of-static.c ├── constexpr-binop.c ├── constexpr-cast.c ├── constexpr-compound-literal.c ├── constexpr-conditional.c ├── constexpr-constcond.c ├── constexpr-init.c ├── constexpr-labelref.c ├── constexpr-offsetof.c ├── constexpr-pointer-arith.c ├── constexpr-pointer-cast.c ├── constexpr-preop.c ├── constexpr-pure-builtin.c ├── constexpr-shift.c ├── constexpr-string.c ├── constexpr-types-compatible-p.c ├── context-stmt.c ├── context-unreachable.c ├── context.c ├── crash-add-doms.c ├── crash-bb_target.c ├── crash-ep-active.c ├── crash-ptrlist.c ├── crash-rewrite-branch.c ├── crash-select.c ├── crash-undef-in-parens.c ├── crazy02-not-so.c ├── crazy03.c ├── declaration-after-statement-ansi.c ├── declaration-after-statement-c89.c ├── declaration-after-statement-c99.c ├── declaration-after-statement-default.c ├── definitions.c ├── designated-init.c ├── div.c ├── doc │ └── cdoc.cdoc ├── double-semicolon.c ├── dubious-bitwise-with-not.c ├── dup-defs-local.c ├── empty-assign.c ├── empty-char-constant.c ├── empty-expr.c ├── empty-file ├── empty-initializer.c ├── endian-big.c ├── endian-little.c ├── enum+mode.c ├── enum-base-type.c ├── enum-bitwise-bad.c ├── enum-bitwise-mixed.c ├── enum-bitwise.c ├── enum-bounds.c ├── enum-common.c ├── enum-from-int.c ├── enum-init-constness.c ├── enum-invalid.c ├── enum-min-size.c ├── enum-mismatch.c ├── enum-same-type.c ├── enum-sign-extend.c ├── enum-sign-gcc.c ├── enum-to-int.c ├── enum-type-dubious.c ├── enum-type-exotic.c ├── enum-typecheck.c ├── enum_scope.c ├── error-at-eof.c ├── escapes.c ├── eval-bad-assign1.c ├── eval-bad-assign2.c ├── eval-typeof-vla.c ├── eval │ ├── addressable-complex.c │ ├── addressable-degen.c │ ├── array-quals-node.c │ ├── array-quals0.c │ ├── array-quals1.c │ ├── asm-degen.c │ ├── asm-memop.c │ ├── assign-restricted-ok.c │ ├── not-cast-bool.c │ ├── not-cast-float.c │ ├── premature-examination.c │ ├── typeof0.c │ ├── undecl-no-indent.c │ ├── union-cast-no.c │ ├── union-cast.c │ ├── unqual-cast.c │ ├── unqual-comma.c │ ├── unqual-postop.c │ ├── unqual-stmt-expr.c │ └── unqual02.c ├── expand │ ├── asm0.c │ ├── bad-shift.c │ ├── builtin-expect.c │ ├── builtin_constant_inline0.c │ ├── builtin_constant_inline1.c │ ├── builtin_fpclassify.c │ ├── builtin_huge_val.c │ ├── builtin_isdigit.c │ ├── builtin_isinf.c │ ├── builtin_isnan.c │ ├── builtin_isnormal.c │ ├── builtin_nan.c │ ├── compound-literal.c │ ├── constant-init-array.c │ ├── constant-init-nested-array.c │ ├── constant-init-nested-struct.c │ ├── constant-init-string.c │ ├── constant-union-flt2int.c │ ├── constant-union-int2flt.c │ ├── constant-union-size.c │ ├── cost-deref-nested.c │ ├── default-init-array.c │ ├── default-init-struct.c │ ├── function-pointer.c │ └── union-cast.c ├── extern-array.c ├── extern-inline.c ├── fdiag-prefix.c ├── field-overlap.c ├── field-override.c ├── flex-array-align.c ├── flex-array-array.c ├── flex-array-error.c ├── flex-array-nested.c ├── flex-array-sizeof.c ├── flex-array-union-array-no.c ├── flex-array-union-array-yes.c ├── flex-array-union-array.h ├── fored_arg.c ├── foul-bitwise.c ├── foul-scalar.c ├── fp-ops.c ├── function-attribute-inner.c ├── function-attribute-pointer.c ├── function-attribute-void-ptr.c ├── function-attribute.c ├── function-pointer-inheritance.c ├── function-pointer-type.c ├── function-redecl-funattr.c ├── function-redecl.c ├── function-redecl2.c ├── generic-bad0.c ├── generic-dr481.c ├── generic-functions.c ├── generic-schar.c ├── generic-typename.c ├── goto-label.c ├── goto-reserved.c ├── identifier_list.c ├── implicit-KR-arg-type0.c ├── implicit-KR-arg-type1.c ├── implicit-ret-type.c ├── implicit-type.c ├── inc-dec-float.c ├── include-eval.c ├── include-eval.inc ├── incomplete-struct.c ├── infinite-loop0.c ├── infinite-loop01.c ├── infinite-loop02.c ├── infinite-loop03.c ├── infinite-loop04.c ├── init-char-array.c ├── init-char-array1.c ├── init-wstring.c ├── init_cstring.c ├── initializer-entry-defined-twice.c ├── inline-early │ ├── bug-bad-token.c │ ├── unreplaced-abstract.c │ └── variadic0.c ├── inline-generic.c ├── inline_base0.c ├── inline_compound_literals.c ├── inline_self.c ├── int128.c ├── integer-const-expr.c ├── integer-promotions.c ├── ioc-typecheck.c ├── kill-computedgoto.c ├── kill-cse.c ├── kill-insert-branch.c ├── kill-load.c ├── kill-phi-node.c ├── kill-phi-ttsbb.c ├── kill-phi-ttsbb2.c ├── kill-phisrc.c ├── kill-pure-call.c ├── kill-replaced-insn.c ├── kill-rewritten-load.c ├── kill-select.c ├── kill-slice.c ├── kill-store.c ├── kill-switch.c ├── kill-unreachable-phi.c ├── knr-attr-crash.c ├── label-asm.c ├── label-attr.c ├── label-positioning.c ├── label-redefined.c ├── label-scope-cgoto.c ├── label-scope.c ├── label-scope1.c ├── label-scope2.c ├── label-stmt-expr0.c ├── label-stmt-expr1.c ├── label-stmt-expr2.c ├── label-unused.c ├── linear │ ├── asm-memop.c │ ├── asm-out0.c │ ├── asm-toplevel.c │ ├── bitfield-expand-deref.c │ ├── bitfield-inc.c │ ├── bitfield-init-mask.c │ ├── bitfield-preinc.c │ ├── bitfield-sign-default.c │ ├── bitfield-sign-signed.c │ ├── bitfield-sign-unsigned.c │ ├── bitfield-size.c │ ├── bitfield-store.c │ ├── bool-cast-lp32.c │ ├── bool-cast-lp64.c │ ├── bool-cast.c │ ├── bug-assign-op0.c │ ├── builtin-fma.c │ ├── builtin_isdigit.c │ ├── builtin_unreachable0.c │ ├── builtin_unreachable1.c │ ├── call-basic.c │ ├── call-builtin.c │ ├── call-casted-pointer.c │ ├── call-complex-pointer.c │ ├── call-direct.c │ ├── call-indirect.c │ ├── call-inline.c │ ├── cast-constant-to-float.c │ ├── cast-constants.c │ ├── cast-volatile.c │ ├── compound-literal00.c │ ├── compound-literal01.c │ ├── compound-literal02.c │ ├── degen-array.c │ ├── degen-function.c │ ├── degen-log-not.c │ ├── deref-ptr-ptr.c │ ├── fp-vs-ptrcast.c │ ├── fp2i-cast.c │ ├── goto-invalid.c │ ├── goto-stmt-expr-conditional.c │ ├── goto-stmt-expr-short-circuit.c │ ├── inline-definition.c │ ├── join-cond-discard.c │ ├── label-scope-cgoto.c │ ├── label-stmt-dropped.c │ ├── label-stmt-expr0.c │ ├── label-unreachable.c │ ├── logical-phi0.c │ ├── logical.c │ ├── missing-insn-size.c │ ├── missing-return0.c │ ├── missing-return1.c │ ├── missing-return2.c │ ├── missing-return3.c │ ├── missing-return4.c │ ├── missing-return5.c │ ├── non-const-case.c │ ├── noreturn-unreachable0.c │ ├── phi-order01.c │ ├── phi-order02.c │ ├── phi-order03.c │ ├── phi-order04.c │ ├── pointer-arith32.c │ ├── pointer-arith64.c │ ├── range-op.c │ ├── shift-assign1.c │ ├── shift-assign2.c │ ├── struct-init-full.c │ ├── struct-init-partial.c │ └── unexamined-base-type.c ├── local-label.c ├── logical.c ├── mem2reg │ ├── address-used00.c │ ├── alias-distinct.c │ ├── alias-mixed.c │ ├── alias-same.c │ ├── asm-reload0.c │ ├── broken-phi02.c │ ├── broken-phi03.c │ ├── cond-expr.c │ ├── cond-expr5.c │ ├── dead-phisrc.c │ ├── global-direct-undef.c │ ├── global-direct.c │ ├── global-loop.c │ ├── global-noalias.c │ ├── global-pointer.c │ ├── if-direct.c │ ├── if-pointer.c │ ├── init-global-array.c │ ├── init-local-array.c │ ├── init-local-union0.c │ ├── init-local-union1.c │ ├── init-local32.c │ ├── init-local64.c │ ├── load-dead.c │ ├── load-deadborn.c │ ├── loop00.c │ ├── loop01-global.c │ ├── loop02-array.c │ ├── loop02-global.c │ ├── loop02-local.c │ ├── loop02-pointer.c │ ├── missing-return.c │ ├── not-same-memop0.c │ ├── packed-bitfield.c │ ├── quadra00.c │ ├── quadra01.c │ ├── quadra02.c │ ├── reload-aliasing.c │ ├── short-load.c │ ├── store-deadborn.c │ ├── stray-phisrc.c │ ├── struct.c │ ├── undef00.c │ ├── undef01.c │ ├── unused-var.c │ └── volatile-store00.c ├── member_of_typeof.c ├── memops-volatile.c ├── memops │ ├── kill-dead-loads00.c │ ├── kill-dead-store-parent0.c │ ├── kill-dead-store-parent2.c │ ├── kill-redundant-store0.c │ ├── partial-load00.c │ ├── type-punning-flt2int.c │ └── type-punning-int2flt.c ├── missing-ident.c ├── missing-return.c ├── multi-input.c ├── multi_typedef.c ├── nested-declarator.c ├── nested-declarator2.c ├── nested-functions.c ├── nocast.c ├── noderef.c ├── non-pointer-null.c ├── old-initializer-nowarn.c ├── old-initializer.c ├── old-style-definition0.c ├── old-style-definition1.c ├── optim │ ├── address-used01.c │ ├── and-extend.c │ ├── and-lsr.c │ ├── and-or-bf0.c │ ├── and-or-bf1.c │ ├── and-or-bf2.c │ ├── and-or-bfs.c │ ├── and-or-bfu.c │ ├── and-or-bfx.c │ ├── and-or-constant0.c │ ├── and-or-constant1.c │ ├── and-or-constant2.c │ ├── and-or-crash.c │ ├── and-or-lsr0.c │ ├── and-or-lsr1.c │ ├── and-or-lsr2.c │ ├── and-or-lsrx.c │ ├── and-or-mask.c │ ├── and-or-mask0.c │ ├── and-or-mask1.c │ ├── and-or-mask2.c │ ├── and-or-mask3s.c │ ├── and-or-mask3u.c │ ├── and-or-mask4.c │ ├── and-or-maskx.c │ ├── and-or-shl0.c │ ├── and-or-shl1.c │ ├── and-or-shl2.c │ ├── and-or-shlx.c │ ├── and-or-trunc0.c │ ├── and-or-trunc1.c │ ├── and-or-trunc2.c │ ├── and-or-truncx.c │ ├── and-trunc.c │ ├── bad-phisrc1.c │ ├── bad-phisrc1a.c │ ├── bad-phisrc2.c │ ├── bad-phisrc3.c │ ├── binops-same-args.c │ ├── bitfield-init-zero.c │ ├── bitfield-size.c │ ├── bitfield-store-load0.c │ ├── bitfield-store-loads.c │ ├── bitfield-store-loadu.c │ ├── bits-not-zero.c │ ├── bool-context-fp.c │ ├── bool-context.c │ ├── bool-eq0.c │ ├── bool-int-bool.c │ ├── bool-ne0.c │ ├── bool-neq0.c │ ├── bool-same-args.c │ ├── bool-sext-test.c │ ├── bool-simplify.c │ ├── bool-simplify2.c │ ├── bool-zext-test.c │ ├── call-complex-pointer.c │ ├── call-inlined.c │ ├── canonical-abs.c │ ├── canonical-add.c │ ├── canonical-arg.c │ ├── canonical-cmp-zero.c │ ├── canonical-cmp.c │ ├── canonical-cmpe-minmax.c │ ├── canonical-cmps-minmax.c │ ├── canonical-cmps-sel.c │ ├── canonical-cmps.c │ ├── canonical-cmpu.c │ ├── canonical-fcmp.c │ ├── canonical-mul.c │ ├── canonical-not.c │ ├── canonical-sub-cte.c │ ├── cast-kinds.c │ ├── cast-nop.c │ ├── cgoto01.c │ ├── cgoto02.c │ ├── cmp-and-pow2.c │ ├── cmp-op-type.c │ ├── cmp-sext-sext.c │ ├── cmp-sext-simm.c │ ├── cmp-sext-uimm.c │ ├── cmp-sext.c │ ├── cmp-type0.c │ ├── cmp-type1.c │ ├── cmp-zext-simm.c │ ├── cmp-zext-uimm0.c │ ├── cmp-zext-uimm1.c │ ├── cmp-zext-uimm2.c │ ├── cmp-zext-zext.c │ ├── cmp-zext.c │ ├── cmpe-and0.c │ ├── cmpe-or0.c │ ├── cmps-and0.c │ ├── cmps-minmax.c │ ├── cmps-or0.c │ ├── cmps0-and0.c │ ├── cmpu-and0.c │ ├── cmpu-or0.c │ ├── cse-arg01.c │ ├── cse-cmp-next.c │ ├── cse-commutativity.c │ ├── cse-dual-compare.c │ ├── cse-fcmp.c │ ├── cse-label.c │ ├── cse-not01.c │ ├── cse-not02.c │ ├── cse-reg01.c │ ├── cse-setfval.c │ ├── cse-size.c │ ├── devirtualize0.c │ ├── double-unop.c │ ├── dup-cond0.c │ ├── eqne-select.c │ ├── ext-trunc-greater.c │ ├── ext-trunc-same.c │ ├── ext-trunc-smaller.c │ ├── fact-add-mul.c │ ├── fact-and-ior.c │ ├── fact-and-shift.c │ ├── fact-ior-and.c │ ├── fact-ior-shift.c │ ├── fact-select01.c │ ├── fact-xor-and.c │ ├── fact-xor-shift.c │ ├── fpcast-constant.c │ ├── fpcast-nop.c │ ├── inline-return.c │ ├── kill-casts.c │ ├── kill-stores0.c │ ├── kill-stores1.c │ ├── kill-stores2.c │ ├── killed-insn.c │ ├── live-stores0.c │ ├── load-converted.c │ ├── load-dead.c │ ├── load-semi-volatile.c │ ├── lsr-and0.c │ ├── lsr-and1.c │ ├── lsr-asr.c │ ├── lsr-shl0.c │ ├── lsr-to-asr.c │ ├── mask-lsr.c │ ├── mask-out.c │ ├── mask1-setne0.c │ ├── memops-missed01.c │ ├── memops-missed02.c │ ├── merge_bbe-adjust_phi.c │ ├── missing-select.c │ ├── muldiv-by-one.c │ ├── muldiv-by-zero.c │ ├── muldiv-minus-one.c │ ├── multi-phisrc.c │ ├── null-phi.c │ ├── or-and-constant1.c │ ├── phi-count00.c │ ├── phi-ret.c │ ├── range-check1.c │ ├── range-check2.c │ ├── reassoc-op-op1.c │ ├── restrict.c │ ├── select-and-shift.c │ ├── select-constant-cond.c │ ├── select-same-args.c │ ├── select-select-true-false0.c │ ├── select-select-true-false1.c │ ├── select-select-true-true.c │ ├── select-self-zero.c │ ├── select-zero.c │ ├── set-uimm0.c │ ├── set-uimm1.c │ ├── set-uimm2.c │ ├── set-uimm3.c │ ├── setcc-mask.c │ ├── setcc-setcc.c │ ├── setcc-seteq.c │ ├── setcc-setne.c │ ├── setne0-sext.c │ ├── setne0-trunc.c │ ├── setne0-zext.c │ ├── sext-sext.c │ ├── sext.c │ ├── sh-or-and0.c │ ├── sh-or-and1.c │ ├── sh-or-and2.c │ ├── shift-big.c │ ├── shift-shift.c │ ├── shift-zext.c │ ├── shl-and0.c │ ├── shl-and1.c │ ├── shl-lsr0.c │ ├── simplify-add-neg.c │ ├── simplify-cte-sub-addl.c │ ├── simplify-cte-sub-addr.c │ ├── simplify-cte-sub-subr.c │ ├── simplify-neg-add-cte.c │ ├── simplify-neg-add.c │ ├── simplify-neg-not.c │ ├── simplify-neg-sub.c │ ├── simplify-not-add-cte.c │ ├── simplify-not-neg.c │ ├── simplify-not-sub-cte.c │ ├── simplify-not-xor-cte.c │ ├── simplify-same-add-subl.c │ ├── simplify-same-add-subr.c │ ├── simplify-same-addl-sub.c │ ├── simplify-same-sub-addl.c │ ├── simplify-same-subl-add.c │ ├── simplify-same-subr-add.c │ ├── simplify-sub-neg.c │ ├── simplify-zero-sub.c │ ├── store-dominated.c │ ├── testsuite.c │ ├── trivial-phi01.c │ ├── trivial-phis.c │ ├── trunc-mask-zext.c │ ├── trunc-not0.c │ ├── trunc-or-shl.c │ ├── trunc-seteq0.c │ ├── trunc-setne0.c │ ├── trunc-trunc.c │ ├── void-if-convert.c │ ├── volatile-bitfield.c │ ├── volatile-side-effect.c │ ├── volatile-store00.c │ ├── zext-and.c │ ├── zext-and1.c │ ├── zext-asr.c │ ├── zext-cmpu.c │ ├── zext-sext.c │ └── zext-zext.c ├── option-parsing-00.c ├── option-parsing-01.c ├── outer-scope.c ├── overflow.c ├── packed-bitfield0.c ├── packed-bitfield1.c ├── packed-bitfield2.c ├── packed-bitfield3.c ├── packed-bitfield4.c ├── packed-bitfield5.c ├── packed-deref0.c ├── packed-struct.c ├── parsing │ ├── attr-cleanup.c │ └── enum-attr.c ├── plain-char-compatibility.c ├── pragma-once.c ├── preprocessor │ ├── bad-cmdline-include.c │ ├── base-file.c │ ├── base-file.h │ ├── builtin.c │ ├── cli-D-arg.c │ ├── cli-D-space.c │ ├── counter1.c │ ├── counter2.c │ ├── counter2.h │ ├── counter3.c │ ├── directive-within-macro.c │ ├── dump-macros-empty.c │ ├── dump-macros-multi.c │ ├── dump-macros-only.c │ ├── dump-macros.c │ ├── dynamic.c │ ├── early-escape.c │ ├── empty-char-constant.c │ ├── expand-and-nl.c │ ├── expand-redef.c │ ├── extra-token.c │ ├── freestanding.c │ ├── has-attribute.c │ ├── has-builtin.c │ ├── has-feature.c │ ├── hosted.c │ ├── ident-pragma.c │ ├── ident.c │ ├── include-level.c │ ├── include-level.h │ ├── missing-delim.c │ ├── phase2-backslash.c │ ├── phase3-comments.c │ ├── predef-llp64.c │ ├── predef-lp32.c │ ├── predef-lp64.c │ ├── predef-token.c │ ├── predef-unsigned.c │ ├── predef.c │ ├── preprocessor1.c │ ├── preprocessor10.c │ ├── preprocessor11.c │ ├── preprocessor12.c │ ├── preprocessor13.c │ ├── preprocessor14.c │ ├── preprocessor15.c │ ├── preprocessor16.c │ ├── preprocessor17.c │ ├── preprocessor18.c │ ├── preprocessor19.c │ ├── preprocessor2.c │ ├── preprocessor20.c │ ├── preprocessor20.h │ ├── preprocessor21.c │ ├── preprocessor22.c │ ├── preprocessor23.c │ ├── preprocessor3.c │ ├── preprocessor4.c │ ├── preprocessor5.c │ ├── preprocessor6.c │ ├── preprocessor7.c │ ├── preprocessor8.c │ ├── preprocessor9.c │ ├── stringify.c │ └── wide.c ├── prototype.c ├── ptr-inherit.c ├── ptr-sub-blows.c ├── pure-function.c ├── range-syntax.c ├── reassoc │ └── bug-zephyr-63417.c ├── repeat.h ├── reserved.c ├── restrict-array.c ├── restrict.c ├── restricted-typeof.c ├── scheck │ ├── ko.c │ └── ok.c ├── self-quote-args.c ├── shift-negative.c ├── shift-undef-long.c ├── shift-undef.c ├── sizeof-bool.c ├── sizeof-builtin.c ├── sizeof-compound-postfix.c ├── sizeof-function.c ├── sizeof-incomplete-type.c ├── sizeof-void.c ├── sm_WtoA.c ├── sm_absolute1.c ├── sm_absolute2.c ├── sm_array_overflow.c ├── sm_array_overflow2.c ├── sm_array_overflow3.c ├── sm_array_overflow4.c ├── sm_array_overflow5.c ├── sm_bits1.c ├── sm_bitwise1.c ├── sm_bitwise2.c ├── sm_buf_size1.c ├── sm_buf_size2.c ├── sm_buf_size3.c ├── sm_buf_size4.c ├── sm_buf_size5.c ├── sm_buf_size6.c ├── sm_buf_size7.c ├── sm_buf_size8.c ├── sm_casts.c ├── sm_casts2.c ├── sm_casts3.c ├── sm_casts4.c ├── sm_casts5.c ├── sm_casts6.c ├── sm_casts7.c ├── sm_check_kunmap.c ├── sm_chunk1.c ├── sm_chunk2.c ├── sm_compare.c ├── sm_compare10.c ├── sm_compare11.c ├── sm_compare12.c ├── sm_compare13.c ├── sm_compare14.c ├── sm_compare15.c ├── sm_compare16.c ├── sm_compare17.c ├── sm_compare18.c ├── sm_compare2.c ├── sm_compare3.c ├── sm_compare4.c ├── sm_compare5.c ├── sm_compare6.c ├── sm_compare7.c ├── sm_compare8.c ├── sm_compare9.c ├── sm_compound_condition.c ├── sm_compound_conditions2.c ├── sm_compound_conditions3.c ├── sm_deref_check_deref.c ├── sm_double_free1.c ├── sm_double_free2.c ├── sm_efault.c ├── sm_equiv1.c ├── sm_equiv2.c ├── sm_equiv3.c ├── sm_equiv4.c ├── sm_err_ptr.c ├── sm_fake_assignment.c ├── sm_float1.c ├── sm_get_user1.c ├── sm_implied.c ├── sm_implied10.c ├── sm_implied11.c ├── sm_implied12.c ├── sm_implied13.c ├── sm_implied14.c ├── sm_implied15.c ├── sm_implied16.c ├── sm_implied17.c ├── sm_implied18.c ├── sm_implied19.c ├── sm_implied2.c ├── sm_implied3.c ├── sm_implied5.c ├── sm_implied7.c ├── sm_implied8.c ├── sm_implied9.c ├── sm_impossible1.c ├── sm_impossible2.c ├── sm_impossible3.c ├── sm_indirection1.c ├── sm_indirection2.c ├── sm_initializer.c ├── sm_inline1.c ├── sm_inline2.c ├── sm_inline3.c ├── sm_locking2.c ├── sm_locking3.c ├── sm_locking4.c ├── sm_locking6.c ├── sm_loops1.c ├── sm_loops2.c ├── sm_loops3.c ├── sm_loops4.c ├── sm_loops5.c ├── sm_loops6.c ├── sm_macros.c ├── sm_math1.c ├── sm_math2.c ├── sm_memleak2.c ├── sm_memory.c ├── sm_mod.c ├── sm_mtag1.c ├── sm_mtag2.c ├── sm_mtag3.c ├── sm_mtag4.c ├── sm_mtag5.c ├── sm_mtag6.c ├── sm_mtag7.c ├── sm_netdevice.c ├── sm_null_deref.c ├── sm_null_deref2.c ├── sm_overflow.c ├── sm_overflow3.c ├── sm_overflow4.c ├── sm_overflow5.c ├── sm_overflow6.c ├── sm_pointer_assign.c ├── sm_precedence.c ├── sm_range1.c ├── sm_range2.c ├── sm_range3.c ├── sm_range4.c ├── sm_range5.c ├── sm_range6.c ├── sm_real_absolute1.c ├── sm_rosenberg.c ├── sm_select.c ├── sm_select3.c ├── sm_select4.c ├── sm_select5.c ├── sm_select_assign.c ├── sm_skb.c ├── sm_skb2.c ├── sm_skb3.c ├── sm_strlen.c ├── sm_strlen2.c ├── sm_strlen3.c ├── sm_struct_assign1.c ├── sm_switch3.c ├── sm_user_data1.c ├── sm_user_data2.c ├── sm_user_data3.c ├── sm_user_data4.c ├── sm_val_parse1.c ├── sm_wine_filehandles.c ├── smatch_db_test.sh ├── specifiers1.c ├── specifiers2.c ├── static-forward-decl.c ├── static_assert.c ├── storage-struct-member.c ├── strict-prototypes0.c ├── strict-prototypes1.c ├── struct-as.c ├── struct-attribute-placement.c ├── struct-ns1.c ├── struct-ns2.c ├── struct-size1.c ├── switch-long.c ├── tautological-compare.c ├── test-suite ├── transparent-union.c ├── type-attribute-align.c ├── type-attribute-as.c ├── type-attribute-mod.c ├── type-attribute-qual.c ├── type-compare.c ├── type1.c ├── typedef-redef-c89.c ├── typedef-redef.c ├── typedef_shadow.c ├── typediff-arraysize.c ├── typediff-enum.c ├── typeof-addresspace.c ├── typeof-attribute.c ├── typeof-bad.c ├── typeof-mods.c ├── typeof-noderef.c ├── typeof-safe.c ├── typesign.c ├── usual-conv-lp32.c ├── var-undef-partial.c ├── varargs1.c ├── vla-sizeof-ice.c ├── vla-sizeof.c ├── vla-sizeof0.c ├── vla-sizeof1.c ├── vla-sizeof2.c ├── vla-sizeof3.c ├── vla-sizeof4.c └── wide.c └── version.c /Documentation/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | dev-options.1 3 | -------------------------------------------------------------------------------- /Documentation/release-notes/index.rst: -------------------------------------------------------------------------------- 1 | ************* 2 | Release Notes 3 | ************* 4 | 5 | .. toctree:: 6 | :maxdepth: 1 7 | 8 | v0.6.4 9 | v0.6.3 10 | v0.6.2 11 | v0.6.1 12 | v0.6.0 13 | v0.5.2 14 | v0.5.1 15 | v0.5.0 16 | v0.4.5-rc1 17 | v0.4.4 18 | v0.4.3 19 | v0.4.2 20 | v0.4.1 21 | v0.4 22 | v0.3 23 | v0.2 24 | v0.1 25 | -------------------------------------------------------------------------------- /Documentation/release-notes/v0.4.5-rc1.rst: -------------------------------------------------------------------------------- 1 | v0.4.5-rc1 (2013-05-09) 2 | ======================= 3 | 4 | I just push the tag for sparse 0.4.5-rc1 5 | 6 | It is about time to cut a new release. There have been a lot of 7 | small improvements. It produces less warning on the recent kernel 8 | check. 9 | 10 | Please give it a good test. 11 | 12 | Chris 13 | -------------------------------------------------------------------------------- /Documentation/requirements.txt: -------------------------------------------------------------------------------- 1 | recommonmark 2 | -------------------------------------------------------------------------------- /Documentation/templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "!layout.html" %} 2 | {% block menu %} 3 | {{ super() }} 4 |

Index

5 | 8 | {% endblock %} 9 | -------------------------------------------------------------------------------- /ast-inspect.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _AST_INSPECT_H_ 3 | #define _AST_INSPECT_H_ 4 | 5 | #include "ast-model.h" 6 | 7 | void inspect_symbol(AstNode *node); 8 | void inspect_symbol_list(AstNode *node); 9 | 10 | void inspect_statement(AstNode *node); 11 | void inspect_statement_list(AstNode *node); 12 | 13 | void inspect_expression(AstNode *node); 14 | void inspect_expression_list(AstNode *node); 15 | 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /ast-view.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "lib.h" 4 | 5 | extern void treeview_main(struct symbol_list *syms); 6 | 7 | 8 | -------------------------------------------------------------------------------- /char.h: -------------------------------------------------------------------------------- 1 | extern void get_char_constant(struct token *, unsigned long long *); 2 | extern struct token *get_string_constant(struct token *, struct expression *); 3 | -------------------------------------------------------------------------------- /compat-linux.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | 3 | #include "lib.h" 4 | #include "allocate.h" 5 | 6 | #include "compat/mmap-blob.c" 7 | #include "compat/strtold.c" 8 | -------------------------------------------------------------------------------- /compat-solaris.c: -------------------------------------------------------------------------------- 1 | #include "compat-linux.c" 2 | -------------------------------------------------------------------------------- /compat/strtold.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long double string_to_ld(const char *nptr, char **endptr) 4 | { 5 | return strtold(nptr, endptr); 6 | } 7 | -------------------------------------------------------------------------------- /compile.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPILE_H 2 | #define COMPILE_H 3 | 4 | struct symbol; 5 | 6 | extern void emit_one_symbol(struct symbol *); 7 | extern void emit_unit_begin(const char *); 8 | extern void emit_unit_end(void); 9 | 10 | #endif /* COMPILE_H */ 11 | -------------------------------------------------------------------------------- /cse.h: -------------------------------------------------------------------------------- 1 | #ifndef CSE_H 2 | #define CSE_H 3 | 4 | struct instruction; 5 | struct entrypoint; 6 | 7 | /* cse.c */ 8 | void cse_collect(struct instruction *insn); 9 | void cse_eliminate(struct entrypoint *ep); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /dominate.h: -------------------------------------------------------------------------------- 1 | #ifndef DOMINATE_H 2 | #define DOMINATE_H 3 | 4 | struct entrypoint; 5 | struct basic_block_list; 6 | 7 | void idf_compute(struct entrypoint *ep, struct basic_block_list **idf, struct basic_block_list *alpha); 8 | 9 | 10 | // For debugging only 11 | void idf_dump(struct entrypoint *ep); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /ir.h: -------------------------------------------------------------------------------- 1 | #ifndef _IR_H 2 | #define _IR_H 3 | 4 | #include "linearize.h" 5 | 6 | int ir_validate(struct entrypoint *ep); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /liveness.h: -------------------------------------------------------------------------------- 1 | #ifndef LIVENESS_H 2 | #define LIVENESS_H 3 | 4 | struct entrypoint; 5 | 6 | /* liveness.c */ 7 | void clear_liveness(struct entrypoint *ep); 8 | void track_pseudo_liveness(struct entrypoint *ep); 9 | void track_pseudo_death(struct entrypoint *ep); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /optimize.h: -------------------------------------------------------------------------------- 1 | #ifndef OPTIMIZE_H 2 | #define OPTIMIZE_H 3 | 4 | struct entrypoint; 5 | 6 | /* optimize.c */ 7 | void optimize(struct entrypoint *ep); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /simplify.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMPLIFY_H 2 | #define SIMPLIFY_H 3 | 4 | #include "linearize.h" 5 | 6 | int simplify_instruction(struct instruction *insn); 7 | 8 | int replace_with_pseudo(struct instruction *insn, pseudo_t pseudo); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /smatch_data/db/call_implies.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE call_implies ( 2 | file big int, 3 | function varchar(64), 4 | call_id integer, 5 | static boolean, 6 | type integer, 7 | parameter integer, 8 | key varchar(256), 9 | value varchar(256), 10 | 11 | CONSTRAINT implies_row UNIQUE (file, function, call_id, static, type, parameter, key, value) 12 | ); 13 | -------------------------------------------------------------------------------- /smatch_data/db/caller_info.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE caller_info (file big int, caller varchar(64), function varchar(64), call_id integer, static boolean, type integer, parameter integer, key varchar(256), value varchar(256)); 2 | -------------------------------------------------------------------------------- /smatch_data/db/common_caller_info.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE common_caller_info (file big int, caller varchar(64), function varchar(64), call_id integer, static boolean, type integer, parameter integer, key varchar(256), value varchar(256)); 2 | -------------------------------------------------------------------------------- /smatch_data/db/constraints.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE constraints ( 2 | id integer primary key, 3 | str varchar(256), 4 | 5 | CONSTRAINT constraint_name UNIQUE (str) 6 | ); 7 | -------------------------------------------------------------------------------- /smatch_data/db/constraints_required.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE constraints_required ( 2 | data varchar(256), 3 | op integer, 4 | bound varchar(256), 5 | 6 | CONSTRAINT unique_row UNIQUE (data, op, bound) 7 | ); 8 | -------------------------------------------------------------------------------- /smatch_data/db/data_info.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE data_info (file big int, data varchar(80), type integer, value varchar(80)); 2 | -------------------------------------------------------------------------------- /smatch_data/db/db.schema: -------------------------------------------------------------------------------- 1 | PRAGMA max_page_count = 2147483646; 2 | -------------------------------------------------------------------------------- /smatch_data/db/fixup_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | db_file=$1 6 | cat << EOF | sqlite3 $db_file 7 | 8 | EOF 9 | 10 | -------------------------------------------------------------------------------- /smatch_data/db/fixup_smatch_generic.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/error27/smatch/e1d933013098891462291a29c4cb664b3dc16522/smatch_data/db/fixup_smatch_generic.sh -------------------------------------------------------------------------------- /smatch_data/db/fn_data_link.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE fn_data_link (file big int, function varchar(64), static boolean, type integer, parameter integer, key varchar(256), value varchar(256)); 2 | -------------------------------------------------------------------------------- /smatch_data/db/fn_ptr_data_link.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE fn_ptr_data_link (fn_ptr varchar(80), data varchar(80), CONSTRAINT unique_row UNIQUE (fn_ptr, data)); 2 | -------------------------------------------------------------------------------- /smatch_data/db/function_ptr.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE function_ptr ( 2 | file big int, 3 | function varchar(64), 4 | ptr varchar(256), 5 | searchable integer, 6 | 7 | CONSTRAINT function_ptr_constraint UNIQUE (file, function, ptr) 8 | ); 9 | 10 | -------------------------------------------------------------------------------- /smatch_data/db/function_type.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE function_type (file big int, function varchar(80), static boolean, parameter integer, value varchar(80)); 2 | -------------------------------------------------------------------------------- /smatch_data/db/function_type_info.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE function_type_info (file big int, function varchar(80), type integer, struct varchar(80), member varchar(80), value varchar(80)); 2 | -------------------------------------------------------------------------------- /smatch_data/db/function_type_size.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE function_type_size (file big int, function varchar(80), type varchar(80), size varchar(80)); 2 | -------------------------------------------------------------------------------- /smatch_data/db/function_type_value.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE function_type_value (file big int, function varchar(80), type varchar(80), value varchar(80)); 2 | -------------------------------------------------------------------------------- /smatch_data/db/hash_string.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE hash_string ( 2 | hash big int, 3 | value varchar(80), 4 | 5 | CONSTRAINT mtag_info_row UNIQUE (hash) 6 | ); 7 | -------------------------------------------------------------------------------- /smatch_data/db/kernel.constraints: -------------------------------------------------------------------------------- 1 | trusted 2 | -------------------------------------------------------------------------------- /smatch_data/db/kernel.constraints_required: -------------------------------------------------------------------------------- 1 | (struct seq_oss_devinfo)->synths, <, (struct seq_oss_devinfo)->max_synthdev 2 | (struct hid_report)->field, <, (struct hid_report)->maxfield 3 | (struct pidff_device)->pid_id, <, (struct ff_device)->max_effects 4 | (struct usb_mixer_elem_info)->cache_val, <, (struct snd_ctl_elem_id)->index 5 | (struct usb_mixer_elem_info)->cache_val, <, kctl->id.index + kctl->count 6 | -------------------------------------------------------------------------------- /smatch_data/db/kernel.forced_return_splits: -------------------------------------------------------------------------------- 1 | copy_from_user 0 2 | -------------------------------------------------------------------------------- /smatch_data/db/local_values.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE local_values (file big int, variable varchar(64), value varchar(256)); 2 | -------------------------------------------------------------------------------- /smatch_data/db/mtag_about.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE mtag_about ( 2 | tag big int, 3 | file big int, 4 | function varchar(80), 5 | line integer, 6 | left_name varchar(80), 7 | right_name varchar(80), 8 | 9 | CONSTRAINT mtag_about_row UNIQUE (tag, file, function, line, left_name, right_name) 10 | ); 11 | -------------------------------------------------------------------------------- /smatch_data/db/mtag_alias.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE mtag_alias (orig big int, new big int); 2 | -------------------------------------------------------------------------------- /smatch_data/db/mtag_data.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE mtag_data ( 2 | tag big int, 3 | offset integer, 4 | type integer, 5 | value varchar(80), 6 | 7 | CONSTRAINT mtag_data_row UNIQUE (tag, offset, type, value) 8 | ); 9 | 10 | -------------------------------------------------------------------------------- /smatch_data/db/mtag_info.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE mtag_info ( 2 | file big int, 3 | tag big int, 4 | type integer, 5 | value varchar(80), 6 | 7 | CONSTRAINT mtag_info_row UNIQUE (file, tag, type, value) 8 | ); 9 | -------------------------------------------------------------------------------- /smatch_data/db/mtag_map.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE mtag_map (container big int, container_offset int, tag big int, tag_offset int); 2 | -------------------------------------------------------------------------------- /smatch_data/db/param_map.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE param_map (file big int, to_from bool, fn_ptr varchar(80), parameter integer, source varchar(80)); 2 | -------------------------------------------------------------------------------- /smatch_data/db/parameter_name.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE parameter_name (file big int, function varchar(80), static boolean, parameter integer, value varchar(80)); 2 | -------------------------------------------------------------------------------- /smatch_data/db/return_implies.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE return_implies ( 2 | file big int, 3 | function varchar(64), 4 | call_id integer, 5 | static boolean, 6 | type integer, 7 | parameter integer, 8 | key varchar(256), 9 | value varchar(256), 10 | 11 | CONSTRAINT implies_row UNIQUE (file, function, call_id, static, type, parameter, key, value) 12 | ); 13 | -------------------------------------------------------------------------------- /smatch_data/db/return_states.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE return_states (file big int, function varchar(64), call_id big int, return_id integer, return varchar(256), static boolean, type integer, parameter integer, key varchar(256), value varchar(256)); 2 | -------------------------------------------------------------------------------- /smatch_data/db/sink_info.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE sink_info (file big int, static boolean, sink_name varchar(64), type integer, key varchar(256), value varchar(256)); 2 | -------------------------------------------------------------------------------- /smatch_data/db/type_info.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE type_info ( 2 | file big int, 3 | type integer, 4 | key varchar(80), 5 | value varchar(80), 6 | 7 | CONSTRAINT type_info_constraint UNIQUE (type, key, value) 8 | ); 9 | 10 | -------------------------------------------------------------------------------- /smatch_data/db/type_size.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE type_size (type varchar(80), size integer); 2 | -------------------------------------------------------------------------------- /smatch_data/db/type_value.schema: -------------------------------------------------------------------------------- 1 | CREATE TABLE type_value (type varchar(80), value varchar(80)); 2 | -------------------------------------------------------------------------------- /smatch_data/kernel.allocation_funcs.remove: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/error27/smatch/e1d933013098891462291a29c4cb664b3dc16522/smatch_data/kernel.allocation_funcs.remove -------------------------------------------------------------------------------- /smatch_data/kernel.allocation_funcs_gfp.remove: -------------------------------------------------------------------------------- 1 | acquire_group 2 | acquire_group 2 3 | acquire_group X 4 | -------------------------------------------------------------------------------- /smatch_data/kernel.bit_shifters.remove: -------------------------------------------------------------------------------- 1 | // tvaudio.c deliberately reuses these in a non conventional way 2 | V4L2_TUNER_MODE_MONO 0 3 | V4L2_TUNER_MODE_STEREO 1 4 | V4L2_TUNER_MODE_LANG2 2 5 | V4L2_TUNER_MODE_SAP 2 6 | V4L2_TUNER_MODE_LANG1 3 7 | V4L2_TUNER_MODE_LANG1_LANG2 4 8 | MBX_INTERRUPT 1 9 | HWTSTAMP_TX_ON 1 10 | LOCK_USAGE_READ_MASK 1 11 | LOCK_USAGE_DIR_MASK 2 12 | -------------------------------------------------------------------------------- /smatch_data/kernel.check_string_condition.ignore: -------------------------------------------------------------------------------- 1 | acpi_dev_hid_uid_match 2 | TRACE_EVENT 3 | WARN_ON_ONCE 4 | -------------------------------------------------------------------------------- /smatch_data/kernel.clears_argument: -------------------------------------------------------------------------------- 1 | copy_from_user 0 2 | __copy_from_user 0 3 | copy_user_generic 0 4 | copy_from_iter_full 0 5 | loop_get_status 1 6 | loop_info64_to_old 1 7 | ib_copy_qp_attr_to_user 0 8 | tcp_get_info 1 9 | snd_rawmidi_info_select 1 10 | t3e3_if_config 3 11 | __kfifo_out_r 1 12 | __kfifo_out 1 13 | -------------------------------------------------------------------------------- /smatch_data/kernel.frees_argument.remove: -------------------------------------------------------------------------------- 1 | free_cell 0 2 | free_scq 0 3 | free_scq 1 4 | setup_card 0 5 | krealloc 0 6 | free_urbs 0 7 | free_area 0 8 | -------------------------------------------------------------------------------- /smatch_data/kernel.ignore_macro_indenting: -------------------------------------------------------------------------------- 1 | while_each_pid_thread 2 | while_each_pid_task 3 | LOCKDEP_STATE 4 | get_user_catch 5 | put_user_catch 6 | tcp_skb_tsorted_restore 7 | -------------------------------------------------------------------------------- /smatch_data/kernel.ignore_memcpy_struct_overflows: -------------------------------------------------------------------------------- 1 | /* list for struct types to ignore */ 2 | lpfc_fdmi_attr_entry 3 | be_cmd_req_hdr 4 | -------------------------------------------------------------------------------- /smatch_data/kernel.ignore_no_effect: -------------------------------------------------------------------------------- 1 | write_seqcount_begin 2 | -------------------------------------------------------------------------------- /smatch_data/kernel.ignored_macros: -------------------------------------------------------------------------------- 1 | /* 2 | * These macros are actively misleading to smatch so 3 | * it's best to ignore them. 4 | */ 5 | WARN_ON 6 | B43legacy_WARN_ON 7 | B43_WARN_ON 8 | ASSERT 9 | HPI_DEBUG_ASSERT 10 | snd_BUG_ON 11 | WARN_ON_ONCE 12 | ubi_assert 13 | bfa_assert 14 | ZD_ASSERT 15 | ubifs_assert 16 | AR_DEBUG_ASSERT 17 | RT_ASSERT 18 | SKD_ASSERT 19 | SNIC_BUG_ON 20 | LASSERT 21 | AA_BUG 22 | -------------------------------------------------------------------------------- /smatch_data/kernel.ignored_warnings: -------------------------------------------------------------------------------- 1 | check_shift_to_zero overflows_type 2 | -------------------------------------------------------------------------------- /smatch_data/kernel.macro_takes_sizeof_argument: -------------------------------------------------------------------------------- 1 | BNX2FC_RQ_BUF_LOG_SZ 2 | BNX2FC_NUM_MAX_SESS_LOG 3 | ilog2 4 | FP_XSTATE_MAGIC2_SIZE 5 | -------------------------------------------------------------------------------- /smatch_data/kernel.must_check_funcs: -------------------------------------------------------------------------------- 1 | ERR_PTR 2 | PTR_ERR 3 | IS_ERR 4 | IS_ERR_OR_NULL 5 | ERR_CAST 6 | -------------------------------------------------------------------------------- /smatch_data/kernel.no_inline_functions: -------------------------------------------------------------------------------- 1 | __fswab16 2 | __fswab32 3 | __fswab64 4 | __builtin_bswap16 5 | __builtin_bswap32 6 | __builtin_bswap64 7 | __arch_hweight8 8 | __arch_hweight16 9 | __arch_hweight32 10 | __arch_hweight64 11 | __write_once_size 12 | atomic_set 13 | atomic_read 14 | notifier_to_errno 15 | ipmi_ssif_lock_cond 16 | smc_connect_abort 17 | -------------------------------------------------------------------------------- /smatch_data/kernel.no_return_funcs.add: -------------------------------------------------------------------------------- 1 | YY_FATAL_ERROR 2 | malformed_line 3 | kunit_do_failed_assertion 4 | -------------------------------------------------------------------------------- /smatch_data/kernel.no_return_funcs.remove: -------------------------------------------------------------------------------- 1 | watchdog 2 | -------------------------------------------------------------------------------- /smatch_data/kernel.returns_err_ptr.remove: -------------------------------------------------------------------------------- 1 | jedec_probe 2 | find_inode 3 | lookup_extent_mapping 4 | -------------------------------------------------------------------------------- /smatch_data/kernel.silenced_functions: -------------------------------------------------------------------------------- 1 | /* Don't print anything from these functions */ 2 | atomic_dec_and_test 3 | atomic_inc_and_test 4 | atomic64_dec_and_test 5 | atomic_sub_and_test 6 | test_and_clear_bit 7 | __copy_to_user_nocheck 8 | __copy_from_user_nocheck 9 | arch_static_branch 10 | __static_cpu_has 11 | __read_once_size 12 | -------------------------------------------------------------------------------- /smatch_data/kernel.sizeof_param.remove: -------------------------------------------------------------------------------- 1 | printk 2 | find_first_zero_bit 3 | dvb_usb_generic_rw 4 | __dynamic_pr_debug 5 | strncmp 6 | strncpy 2 1 7 | strlcpy 2 1 8 | strncat 2 1 9 | snprintf 10 | copy_from_user 2 1 11 | copy_to_user 2 0 12 | read_rom 2 3 13 | skb_pull 1 -1 14 | -------------------------------------------------------------------------------- /smatch_data/kernel.skipped_macros: -------------------------------------------------------------------------------- 1 | DECLARE_EVENT_CLASS 2 | -------------------------------------------------------------------------------- /smatch_data/kernel.unreachable.turn_off: -------------------------------------------------------------------------------- 1 | BUG 2 | panic 3 | LBUG 4 | ASSERT 5 | KUNIT_FAIL 6 | kunit_err 7 | DEFINE_TEST_ALLOC 8 | -------------------------------------------------------------------------------- /smatch_data/no_return_funcs: -------------------------------------------------------------------------------- 1 | __assert_fail 2 | exit 3 | __builtin_unreachable 4 | __builtin_trap 5 | -------------------------------------------------------------------------------- /smatch_data/no_return_funcs.remove: -------------------------------------------------------------------------------- 1 | main 2 | reserve_bootmem 3 | reserve_bootmem_node 4 | smp_reboot_interrupt 5 | xfs_fs_alloc_inode 6 | -------------------------------------------------------------------------------- /smatch_data/smatch.common_functions: -------------------------------------------------------------------------------- 1 | printf 2 | get_lineno 3 | fprintf 4 | snprintf 5 | strip_expr 6 | add_hook 7 | get_argument_from_call_expr 8 | print_implied_debug_msg 9 | is_silenced_function 10 | sval_cast 11 | expr_to_str 12 | get_type 13 | get_filename 14 | add_function_hook 15 | set_state 16 | get_function 17 | sm_prefix 18 | strcmp 19 | INT_PTR 20 | free_string 21 | type_bits 22 | -------------------------------------------------------------------------------- /smatch_data/smatch_generic.common_functions: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/error27/smatch/e1d933013098891462291a29c4cb664b3dc16522/smatch_data/smatch_generic.common_functions -------------------------------------------------------------------------------- /smatch_data/wine.ignored_macros: -------------------------------------------------------------------------------- 1 | /* 2 | * These macros are actively misleading to smatch so 3 | * it's best to ignore them. 4 | */ 5 | ok 6 | -------------------------------------------------------------------------------- /smatch_data/wine.no_return_funcs.add: -------------------------------------------------------------------------------- 1 | ExitProcess 2 | RaiseException 3 | -------------------------------------------------------------------------------- /smatch_data/wine.no_return_funcs.remove: -------------------------------------------------------------------------------- 1 | usage 2 | -------------------------------------------------------------------------------- /smatch_expression_stacks.h: -------------------------------------------------------------------------------- 1 | void push_expression(struct expression_list **estack, struct expression *expr); 2 | struct expression *pop_expression(struct expression_list **estack); 3 | struct expression *top_expression(struct expression_list *estack); 4 | void free_expression_stack(struct expression_list **estack); 5 | -------------------------------------------------------------------------------- /smatch_scripts/find_expanded_holes.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | 5 | my $cur_struct = ""; 6 | my $printed = 0; 7 | 8 | while (<>) { 9 | if ($_ =~ /^struct (\w+) {/) { 10 | $cur_struct = $1; 11 | $printed = 0; 12 | next; 13 | } 14 | if ($_ =~ /.* hole,.*/ && !$printed) { 15 | print "$cur_struct\n"; 16 | $printed = 1; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /smatch_scripts/implicit_dependencies/README: -------------------------------------------------------------------------------- 1 | Python module for parsing kernel.implicit_dependencies 2 | 3 | `python main.py -h` for usage. 4 | run `python main.py -v -p` to generate verbose and pretty print. 5 | 6 | To generate kernel.implicit_dependencies, run `smatch_scripts/build_kernel_data.sh` 7 | -------------------------------------------------------------------------------- /sparse-llvm-dis: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # For testing sparse-llvm emitted bytecode 4 | 5 | set +e 6 | 7 | DIS=$("${LLVM_CONFIG:-llvm-config}" --bindir)/llvm-dis 8 | 9 | if [ $# -eq 0 ]; then 10 | echo "$(basename $0): no input files" 11 | exit 1 12 | fi 13 | 14 | DIRNAME=$(dirname $0) 15 | $DIRNAME/sparse-llvm "$@" | "$DIS" | grep -v '^target ' 16 | -------------------------------------------------------------------------------- /ssa.h: -------------------------------------------------------------------------------- 1 | #ifndef SSA_H 2 | #define SSA_H 3 | 4 | struct entrypoint; 5 | 6 | void ssa_convert(struct entrypoint *ep); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /target-default.c: -------------------------------------------------------------------------------- 1 | #include "symbol.h" 2 | #include "target.h" 3 | #include "machine.h" 4 | 5 | 6 | const struct target target_default = { 7 | .mach = MACH_UNKNOWN, 8 | .bitness = ARCH_LP64, 9 | .big_endian = 0, 10 | .unsigned_char = 0, 11 | }; 12 | -------------------------------------------------------------------------------- /validation/.gitignore: -------------------------------------------------------------------------------- 1 | # test-suite 2 | *.diff 3 | *.got 4 | *.expected 5 | -------------------------------------------------------------------------------- /validation/Waddress-function.c: -------------------------------------------------------------------------------- 1 | extern void func(void); 2 | 3 | int global_function(void) 4 | { 5 | if (func) 6 | return 1; 7 | return 0; 8 | } 9 | 10 | /* 11 | * check-name: Waddress-function 12 | * check-command: sparse -Wno-decl -Waddress $file 13 | * 14 | * check-error-start 15 | Waddress-function.c:5:13: warning: the address of a function will always evaluate as true 16 | * check-error-end 17 | */ 18 | -------------------------------------------------------------------------------- /validation/Woverride-init-def.c: -------------------------------------------------------------------------------- 1 | static int array[] = { 2 | [1] = 3, 3 | [1] = 1, /* check-should-warn */ 4 | }; 5 | 6 | /* 7 | * check-name: Woverride-init-def 8 | * check-command: sparse $file 9 | * 10 | * check-error-start 11 | Woverride-init-def.c:2:10: warning: Initializer entry defined twice 12 | Woverride-init-def.c:3:10: also defined here 13 | * check-error-end 14 | */ 15 | -------------------------------------------------------------------------------- /validation/Woverride-init-no.c: -------------------------------------------------------------------------------- 1 | static int array[] = { 2 | [1] = 3, 3 | [1] = 1, /* check-should-warn */ 4 | }; 5 | 6 | /* 7 | * check-name: Woverride-init-no 8 | * check-command: sparse -Wno-override-init $file 9 | * 10 | * check-error-start 11 | * check-error-end 12 | */ 13 | -------------------------------------------------------------------------------- /validation/Woverride-init-yes.c: -------------------------------------------------------------------------------- 1 | static int array[] = { 2 | [1] = 3, 3 | [1] = 1, /* check-should-warn */ 4 | }; 5 | 6 | /* 7 | * check-name: Woverride-init-yes 8 | * check-command: sparse -Woverride-init $file 9 | * 10 | * check-error-start 11 | Woverride-init-yes.c:2:10: warning: Initializer entry defined twice 12 | Woverride-init-yes.c:3:10: also defined here 13 | * check-error-end 14 | */ 15 | -------------------------------------------------------------------------------- /validation/Wunknown-attribute-def.c: -------------------------------------------------------------------------------- 1 | static int foo(void) __attribute__((unknown_attribute)); 2 | 3 | /* 4 | * check-name: warn-unknown-attribute 5 | */ 6 | -------------------------------------------------------------------------------- /validation/Wunknown-attribute-no.c: -------------------------------------------------------------------------------- 1 | static int foo(void) __attribute__((unknown_attribute)); 2 | 3 | /* 4 | * check-name: warn-unknown-attribute-no 5 | * check-command: sparse -Wno-unknown-attribute $file 6 | * 7 | * check-error-start 8 | * check-error-end 9 | */ 10 | -------------------------------------------------------------------------------- /validation/Wunknown-attribute-yes.c: -------------------------------------------------------------------------------- 1 | static int foo(void) __attribute__((unknown_attribute)); 2 | 3 | /* 4 | * check-name: warn-unknown-attribute-yes 5 | * check-command: sparse -Wunknown-attribute $file 6 | * 7 | * check-error-start 8 | Wunknown-attribute-yes.c:1:37: warning: unknown attribute 'unknown_attribute' 9 | * check-error-end 10 | */ 11 | -------------------------------------------------------------------------------- /validation/__func__-scope.c: -------------------------------------------------------------------------------- 1 | static void foo(void) 2 | { 3 | const char *name = ({ __func__; }); 4 | } 5 | /* 6 | * check-name: __func__'s scope 7 | * check-command: sparse -Wall $file 8 | */ 9 | -------------------------------------------------------------------------------- /validation/__func__.c: -------------------------------------------------------------------------------- 1 | static void f(void) 2 | { 3 | char *s1 = __func__; 4 | char arr[2 * (sizeof __func__ == 2) - 1]; 5 | char *s2 = __func__ __func__; 6 | } 7 | /* 8 | * check-name: __func__ 9 | * check-command: sparse -Wall $file 10 | * 11 | * check-error-start 12 | __func__.c:5:29: error: Expected ; at end of declaration 13 | __func__.c:5:29: error: got __func__ 14 | * check-error-end 15 | */ 16 | -------------------------------------------------------------------------------- /validation/abstract-array-declarator-star.c: -------------------------------------------------------------------------------- 1 | void ok8(int [*]); 2 | 3 | void ok8(int a[*]); 4 | void ok9(int a[const volatile restrict *]); 5 | 6 | /* 7 | * check-name: abstract-array-declarator-star 8 | */ 9 | -------------------------------------------------------------------------------- /validation/abstract-array-declarator.c: -------------------------------------------------------------------------------- 1 | void f77(int a[1, 2]); 2 | void c99(int a[(1, 2)]); 3 | 4 | /* 5 | * check-name: abstract-array-declarator 6 | * 7 | * check-error-start 8 | abstract-array-declarator.c:1:17: error: Expected ] in abstract_array_declarator 9 | abstract-array-declarator.c:1:17: error: got , 10 | * check-error-end 11 | */ 12 | -------------------------------------------------------------------------------- /validation/anon-union.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | union { 3 | int val; 4 | }; 5 | }; 6 | 7 | static struct s foo = { .val = 5, }; 8 | /* 9 | * check-name: test anonymous union initializer 10 | */ 11 | 12 | -------------------------------------------------------------------------------- /validation/arch/arm-predef-float-abi-hard.c: -------------------------------------------------------------------------------- 1 | #if !defined(__ARM_PCS_VFP) || defined(__SOFTFP__) || defined(__ARM_PCS) 2 | #error 3 | #endif 4 | 5 | /* 6 | * check-name: arm-predef-float-abi-hard 7 | * check-command: sparse --arch=arm -mfloat-abi=hard $file 8 | */ 9 | -------------------------------------------------------------------------------- /validation/arch/arm-predef-float-abi-mixed.c: -------------------------------------------------------------------------------- 1 | #if defined(__ARM_PCS_VFP) || defined(__SOFTFP__) || !defined(__ARM_PCS) 2 | #error 3 | #endif 4 | 5 | /* 6 | * check-name: arm-predef-float-abi-mixed 7 | * check-command: sparse --arch=arm -mfloat-abi=softfp $file 8 | */ 9 | -------------------------------------------------------------------------------- /validation/arch/arm-predef-float-abi-soft.c: -------------------------------------------------------------------------------- 1 | #if defined(__ARM_PCS_VFP) || !defined(__SOFTFP__) || !defined(__ARM_PCS) 2 | #error 3 | #endif 4 | 5 | /* 6 | * check-name: arm-predef-float-abi-soft 7 | * check-command: sparse --arch=arm -mfloat-abi=soft $file 8 | */ 9 | -------------------------------------------------------------------------------- /validation/arch/arm-predef-hard-float.c: -------------------------------------------------------------------------------- 1 | #if !defined(__ARM_PCS_VFP) || defined(__SOFTFP__) || defined(__ARM_PCS) 2 | #error 3 | #endif 4 | 5 | /* 6 | * check-name: arm-predef-hard-float 7 | * check-command: sparse --arch=arm -mhard-float $file 8 | */ 9 | -------------------------------------------------------------------------------- /validation/arch/arm-predef-soft-float.c: -------------------------------------------------------------------------------- 1 | #if defined(__ARM_PCS_VFP) || !defined(__SOFTFP__) || !defined(__ARM_PCS) 2 | #error 3 | #endif 4 | 5 | /* 6 | * check-name: arm-predef-soft-float 7 | * check-command: sparse --arch=arm -msoft-float $file 8 | */ 9 | -------------------------------------------------------------------------------- /validation/arch/arm64.c: -------------------------------------------------------------------------------- 1 | __aarch64__ 2 | __x86_64__ 3 | __LP64__ 4 | __BYTE_ORDER__ 5 | __SIZEOF_INT__ 6 | __SIZEOF_LONG__ 7 | __SIZE_TYPE__ 8 | 9 | /* 10 | * check-name: arch/arm64 11 | * check-command: sparse --arch=arm64 -E $file 12 | * 13 | * check-output-start 14 | 15 | 1 16 | __x86_64__ 17 | 1 18 | 1234 19 | 4 20 | 8 21 | unsigned long 22 | * check-output-end 23 | */ 24 | -------------------------------------------------------------------------------- /validation/arch/short-wchar.c: -------------------------------------------------------------------------------- 1 | _Static_assert([__WCHAR_TYPE__] == [unsigned short], "short wchar"); 2 | 3 | /* 4 | * check-name: short-wchar 5 | * check-command: sparse -fshort-wchar $file 6 | */ 7 | -------------------------------------------------------------------------------- /validation/attr-no_sanitize_address.c: -------------------------------------------------------------------------------- 1 | #define __no_sanitize_address __attribute__((no_sanitize_address)) 2 | 3 | static void __no_sanitize_address bar(void) 4 | { 5 | } 6 | 7 | /* 8 | * check-name: attribute no_sanitize_address 9 | */ 10 | -------------------------------------------------------------------------------- /validation/attr-noclone.c: -------------------------------------------------------------------------------- 1 | #define noclone __attribute__((__noclone__)) 2 | 3 | static void noclone bar(void) 4 | { 5 | } 6 | 7 | /* 8 | * check-name: attribute noclone 9 | */ 10 | -------------------------------------------------------------------------------- /validation/attr-optimize.c: -------------------------------------------------------------------------------- 1 | 2 | #define __noclone __attribute__((__noclone__, __optimize__("no-tracer"))) 3 | 4 | struct kvm_vcpu; 5 | 6 | static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) 7 | { 8 | __asm__(""); 9 | } 10 | 11 | extern void *run; 12 | void *run = vmx_vcpu_run; 13 | 14 | /* 15 | * check-name: optimize attributes 16 | */ 17 | -------------------------------------------------------------------------------- /validation/attr-visible.c: -------------------------------------------------------------------------------- 1 | #define __visible __attribute__((externally_visible)) 2 | 3 | __visible void foo(void) 4 | { 5 | } 6 | 7 | int flag __visible; 8 | 9 | /* 10 | * check-name: attr-visible 11 | * check-command: sparse -Wdecl $file 12 | */ 13 | -------------------------------------------------------------------------------- /validation/attr-visible2.c: -------------------------------------------------------------------------------- 1 | #define __visible __attribute__((externally_visible)) 2 | 3 | int flag __visible; 4 | int arr[2] __visible; 5 | 6 | /* 7 | * check-name: attr-visible-after 8 | * check-command: sparse -Wdecl $file 9 | */ 10 | -------------------------------------------------------------------------------- /validation/attr-warning.c: -------------------------------------------------------------------------------- 1 | # define __warndecl(name, msg) \ 2 | extern void name (void) __attribute__((__warning__ (msg))) 3 | 4 | __warndecl (__warn_func, "warn message"); 5 | 6 | /* 7 | * check-name: attribute warning 8 | */ 9 | -------------------------------------------------------------------------------- /validation/attr_aligned.c: -------------------------------------------------------------------------------- 1 | void *foo(void) __attribute__((__assume_aligned__(4096))); 2 | void *foo(void) __attribute__((assume_aligned(4096))); 3 | /* 4 | * check-name: attribute assume_aligned 5 | */ 6 | 7 | -------------------------------------------------------------------------------- /validation/attr_in_parameter.c: -------------------------------------------------------------------------------- 1 | #define A __attribute__((address_space(1))) 2 | static int (A *p); 3 | static int A *q; 4 | static void (*f)(A int *x, A int *y) = (void *)0; 5 | static void g(int A *x) 6 | { 7 | f(x, x); 8 | p = q; 9 | } 10 | /* 11 | * check-name: attribute after ( in direct-declarator 12 | */ 13 | -------------------------------------------------------------------------------- /validation/attr_vector_size.c: -------------------------------------------------------------------------------- 1 | typedef unsigned int u32; 2 | typedef u32 __attribute__((vector_size(16))) sse128_t; 3 | 4 | /* 5 | * check-name: attribute vector_size 6 | */ 7 | 8 | -------------------------------------------------------------------------------- /validation/backend/array.c: -------------------------------------------------------------------------------- 1 | static char array[128]; 2 | 3 | /* 4 | * check-name: Array code generation 5 | * check-command: sparsec -c $file -o tmp.o 6 | */ 7 | -------------------------------------------------------------------------------- /validation/backend/bool-test.c: -------------------------------------------------------------------------------- 1 | static _Bool return_false(void) 2 | { 3 | return 0; 4 | } 5 | 6 | /* 7 | * check-name: Boolean type code generation 8 | * check-command: sparsec -c $file -o tmp.o 9 | */ 10 | -------------------------------------------------------------------------------- /validation/backend/compare-with-null.c: -------------------------------------------------------------------------------- 1 | int tstv(void *p) { return !p; } 2 | int cmpv(void *p) { return p == ((void*)0); } 3 | 4 | int tsti(int *p) { return !p; } 5 | int cmpi(int *p) { return p == ((int *)0); } 6 | int cmpx(int *p) { return p == ((void*)0); } 7 | 8 | /* 9 | * check-name: compare-with-null 10 | * check-command: sparsec -Wno-decl -c $file -o tmp.o 11 | * check-output-ignore 12 | */ 13 | -------------------------------------------------------------------------------- /validation/backend/extern.c: -------------------------------------------------------------------------------- 1 | extern unsigned long foo; 2 | 3 | static unsigned long bar(void) 4 | { 5 | return foo; 6 | } 7 | 8 | /* 9 | * check-name: Extern symbol code generation 10 | * check-command: sparsec -c $file -o tmp.o 11 | */ 12 | -------------------------------------------------------------------------------- /validation/backend/hello.c: -------------------------------------------------------------------------------- 1 | int puts(const char *s); 2 | 3 | int main(int argc, char *argv[]) 4 | { 5 | puts("hello, world"); 6 | 7 | return 0; 8 | } 9 | 10 | /* 11 | * check-name: 'hello, world' code generation 12 | * check-command: sparsec -c $file -o tmp.o 13 | */ 14 | -------------------------------------------------------------------------------- /validation/backend/label-as-value.c: -------------------------------------------------------------------------------- 1 | void *foo(void *def); 2 | void *foo(void *def) 3 | { 4 | if (!def) 5 | yes: return &&yes; 6 | 7 | return def; 8 | } 9 | 10 | /* 11 | * check-name: label-as-value 12 | * check-command: sparsec -c $file -o tmp.o 13 | */ 14 | -------------------------------------------------------------------------------- /validation/backend/load-type.c: -------------------------------------------------------------------------------- 1 | extern struct _IO_FILE *stdin; 2 | 3 | static void sub(struct _IO_FILE *in) {} 4 | 5 | static void test(void) { 6 | sub(stdin); 7 | } 8 | 9 | /* 10 | * check-name: Type of loaded objects 11 | * check-command: sparsec -c $file -o tmp.o 12 | */ 13 | -------------------------------------------------------------------------------- /validation/backend/loop.c: -------------------------------------------------------------------------------- 1 | 2 | extern int bar (int); 3 | 4 | extern int foo (int); 5 | 6 | int foo (int x) 7 | { 8 | int y = 0; 9 | 10 | while (y < 1000) { 11 | y += bar(x); 12 | } 13 | 14 | return y; 15 | } 16 | 17 | 18 | /* 19 | * check-name: Loops 20 | * check-command: sparsec -c $file -o tmp.o 21 | */ 22 | -------------------------------------------------------------------------------- /validation/backend/loop2.c: -------------------------------------------------------------------------------- 1 | extern int op(void); 2 | 3 | static void test(void) 4 | { 5 | int i; 6 | for (i = 0; ; i++) { 7 | op(); 8 | } 9 | } 10 | 11 | /* 12 | * check-name: Loops with unused counter 13 | * check-command: sparsec -c $file -o tmp.o 14 | */ 15 | -------------------------------------------------------------------------------- /validation/backend/ptrcast.c: -------------------------------------------------------------------------------- 1 | static char *ptrcast(unsigned long *x) 2 | { 3 | return (unsigned char *) x; 4 | } 5 | 6 | /* 7 | * check-name: Pointer cast code generation 8 | * check-command: sparsec -c $file -o tmp.o 9 | */ 10 | -------------------------------------------------------------------------------- /validation/backend/setval.c: -------------------------------------------------------------------------------- 1 | double setfval64(void) { return 1.23; } 2 | float setfval32(void) { return 1.23F; } 3 | 4 | /* 5 | * check-name: setval-float 6 | * check-command: sparsec -Wno-decl -c $file -o tmp.o 7 | */ 8 | -------------------------------------------------------------------------------- /validation/backend/shift-special.c: -------------------------------------------------------------------------------- 1 | long shift(long a, short b); 2 | long shift(long a, short b) 3 | { 4 | long r1 = a << b; 5 | long r2 = b << a; 6 | 7 | return r1 + r2; 8 | } 9 | 10 | /* 11 | * check-name: shift-special 12 | * check-command: sparsec -c $file -o tmp.o 13 | */ 14 | -------------------------------------------------------------------------------- /validation/backend/store-type.c: -------------------------------------------------------------------------------- 1 | struct foo; 2 | static struct foo *var; 3 | 4 | static void set(struct foo *f) 5 | { 6 | var = f; 7 | } 8 | 9 | /* 10 | * check-name: Type of stored objects 11 | * check-command: sparsec -c $file -o tmp.o 12 | */ 13 | -------------------------------------------------------------------------------- /validation/backend/string-value.c: -------------------------------------------------------------------------------- 1 | extern void use(const char *); 2 | 3 | const char *ret(void) 4 | { 5 | return "abc"; 6 | } 7 | 8 | const char *add(void) 9 | { 10 | return "def" + 1; 11 | } 12 | 13 | void call(void) 14 | { 15 | use("ijk"); 16 | } 17 | 18 | /* 19 | * check-name: string-value 20 | * check-command: sparsec -Wno-decl -c $file -o tmp.o 21 | */ 22 | -------------------------------------------------------------------------------- /validation/backend/union.c: -------------------------------------------------------------------------------- 1 | union foo { 2 | unsigned long x; 3 | unsigned char y; 4 | char buf[128]; 5 | }; 6 | 7 | static union foo foo; 8 | 9 | /* 10 | * check-name: Union code generation 11 | * check-command: sparsec -c $file -o tmp.o 12 | */ 13 | -------------------------------------------------------------------------------- /validation/backend/void-return-type.c: -------------------------------------------------------------------------------- 1 | static void foo(void) 2 | { 3 | } 4 | 5 | static void *bar(void *p) 6 | { 7 | return p; 8 | } 9 | 10 | /* 11 | * check-name: void return type code generation 12 | * check-command: sparsec -c $file -o tmp.o 13 | */ 14 | -------------------------------------------------------------------------------- /validation/bad-assignment.c: -------------------------------------------------------------------------------- 1 | static int foo(int a) 2 | { 3 | a |=\1; 4 | 5 | return a; 6 | } 7 | /* 8 | * check-name: bad assignment 9 | * 10 | * check-error-start 11 | bad-assignment.c:3:11: error: expression expected before '\' 12 | bad-assignment.c:3:13: error: Expected ; at end of statement 13 | bad-assignment.c:3:13: error: got \ 14 | * check-error-end 15 | */ 16 | -------------------------------------------------------------------------------- /validation/bad-cast.c: -------------------------------------------------------------------------------- 1 | struct st; 2 | 3 | static int foo(int a) 4 | { 5 | return (struct/st *) a; 6 | } 7 | /* 8 | * check-name: Bad cast syntax 9 | * 10 | * check-error-start 11 | bad-cast.c:5:23: error: expected declaration 12 | bad-cast.c:5:23: error: Expected ) at end of cast operator 13 | bad-cast.c:5:23: error: got / 14 | * check-error-end 15 | */ 16 | -------------------------------------------------------------------------------- /validation/bad-return-type.c: -------------------------------------------------------------------------------- 1 | void foo(int a) 2 | { 3 | return a; 4 | } 5 | 6 | int bar(void) 7 | { 8 | return; 9 | } 10 | 11 | /* 12 | * check-name: bad return type 13 | * check-command: sparse -Wno-decl $file 14 | * 15 | * check-error-start 16 | bad-return-type.c:3:16: error: return expression in void function 17 | bad-return-type.c:8:9: error: return with no return value 18 | * check-error-end 19 | */ 20 | -------------------------------------------------------------------------------- /validation/bad-ternary-cond.c: -------------------------------------------------------------------------------- 1 | static int foo(int a) 2 | { 3 | return a ?? 1 : 0; 4 | } 5 | /* 6 | * check-name: Bad ternary syntax 7 | * check-description: Once caused Sparse to segfault 8 | * check-error-start 9 | bad-ternary-cond.c:3:19: error: Expected : in conditional expression 10 | bad-ternary-cond.c:3:19: error: got ? 11 | * check-error-end 12 | */ 13 | -------------------------------------------------------------------------------- /validation/bad-type-twice0.c: -------------------------------------------------------------------------------- 1 | static int foo(a) 2 | { 3 | return a ? : 1; 4 | } 5 | 6 | /* 7 | * check-name: bad-type-twice0 8 | * 9 | * check-error-start 10 | bad-type-twice0.c:1:16: error: missing type declaration for parameter 'a' 11 | * check-error-end 12 | */ 13 | -------------------------------------------------------------------------------- /validation/bad-type-twice1.c: -------------------------------------------------------------------------------- 1 | static unsigned long foo(unsigned long val, void *ref) 2 | { 3 | if (val >= ref) 4 | val = 0; 5 | return val; 6 | } 7 | 8 | /* 9 | * check-name: bad-type-twice1 10 | * 11 | * check-error-start 12 | bad-type-twice1.c:3:17: error: incompatible types for operation (>=): 13 | bad-type-twice1.c:3:17: unsigned long val 14 | bad-type-twice1.c:3:17: void *ref 15 | * check-error-end 16 | */ 17 | -------------------------------------------------------------------------------- /validation/bad-typeof.c: -------------------------------------------------------------------------------- 1 | static int fun(void) 2 | { 3 | typeof() a; 4 | int b; 5 | 6 | a = b; 7 | } 8 | /* 9 | * check-name: Bad typeof syntax segfault 10 | * 11 | * check-error-start 12 | bad-typeof.c:3:16: error: expected expression after the '(' token 13 | * check-error-end 14 | */ 15 | -------------------------------------------------------------------------------- /validation/badtype1.c: -------------------------------------------------------------------------------- 1 | static void foo(enum bar baz); 2 | 3 | /* 4 | * check-name: enum not in scope 5 | * check-known-to-fail 6 | * 7 | * check-error-start 8 | badtype1.c:1:22: warning: bad scope for 'enum bar' 9 | * check-error-end 10 | */ 11 | -------------------------------------------------------------------------------- /validation/badtype4.c: -------------------------------------------------------------------------------- 1 | void a(void) 2 | { 3 | switch(x) { 4 | case 1: 5 | break; 6 | } 7 | } 8 | /* 9 | * check-name: switch(bad_type) {...} segfault 10 | * 11 | * check-error-start 12 | badtype4.c:3:16: error: undefined identifier 'x' 13 | badtype4.c:4:14: error: incompatible types for 'case' statement 14 | * check-error-end 15 | */ 16 | -------------------------------------------------------------------------------- /validation/binary-constant.c: -------------------------------------------------------------------------------- 1 | extern int x; 2 | 3 | int x = 0b11; 4 | 5 | /* 6 | * check-name: binary constant 7 | */ 8 | -------------------------------------------------------------------------------- /validation/bitfield-kr.c: -------------------------------------------------------------------------------- 1 | static int foo(b) 2 | int b: 4; 3 | { 4 | return 0; 5 | } 6 | 7 | /* 8 | * check-name: bitfield in K&R 9 | * 10 | * check-known-to-fail 11 | * check-error-start 12 | bitfield-kr.c:2:9: error: bitfield in K&R declaration of 'foo' 13 | * check-error-end 14 | */ 15 | -------------------------------------------------------------------------------- /validation/bitfields.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Al Viro points out that we don't 3 | * do bitfield -> integer promotions 4 | * for array dereferences 5 | * 6 | * "warning: a.c:16:10: incompatible types for operation" 7 | */ 8 | static struct { 9 | int x:4; 10 | } y; 11 | 12 | extern int a[]; 13 | 14 | static int b(void) 15 | { 16 | return a[y.x]; 17 | } 18 | 19 | /* 20 | * check-name: bitfield to integer promotion 21 | */ 22 | -------------------------------------------------------------------------------- /validation/bool-float.c: -------------------------------------------------------------------------------- 1 | int ftst(double a) { return !a; } 2 | 3 | /* 4 | * check-name: not-operator on float 5 | * check-command: test-linearize -Wno-decl $file 6 | * check-output-ignore 7 | * 8 | * check-output-excludes: \\$0 9 | */ 10 | -------------------------------------------------------------------------------- /validation/bug-bad-type.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | int i; 3 | }; 4 | 5 | long a; 6 | void foo(void) 7 | { 8 | (struct s) { .i = (foo - a), }; 9 | } 10 | 11 | /* 12 | * check-name: bug-bad-type 13 | * 14 | * check-error-start 15 | bug-bad-type.c:5:6: warning: symbol 'a' was not declared. Should it be static? 16 | bug-bad-type.c:8:32: error: arithmetics on pointers to functions 17 | * check-error-end 18 | */ 19 | -------------------------------------------------------------------------------- /validation/bug-crash16.c: -------------------------------------------------------------------------------- 1 | static void foo(void) 2 | { 3 | int b[] = { 8 }; 4 | int c; 5 | for (;;) 6 | b[c] = b[0]; 7 | } 8 | 9 | /* 10 | * check-name: bug-crash16 11 | */ 12 | -------------------------------------------------------------------------------- /validation/build_smatch_db.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ../smatch --info $* > warns.txt 4 | ../smatch_data/db/create_db.sh warns.txt > /dev/null 2>&1 5 | 6 | -------------------------------------------------------------------------------- /validation/builtin-objsize-self-init.c: -------------------------------------------------------------------------------- 1 | static void f(void) 2 | { 3 | void *param = param; 4 | __builtin_object_size(param, 0); 5 | } 6 | 7 | /* 8 | * check-name: builtin-objsize-self-init 9 | * check-timeout: 10 | * check-error-end 11 | */ 12 | -------------------------------------------------------------------------------- /validation/builtin-prototype.c: -------------------------------------------------------------------------------- 1 | void memcpy(void *dst, const void *src, unsigned int size); 2 | void memcpy(void *dst, const void *src, unsigned int size) 3 | { 4 | __builtin_memcpy(dst, src, size); 5 | } 6 | 7 | unsigned int strlen(const char *src); 8 | unsigned int strlen(const char *src) 9 | { 10 | return __builtin_strlen(src); 11 | } 12 | 13 | /* 14 | * check-name: builtin-prototype 15 | */ 16 | -------------------------------------------------------------------------------- /validation/builtin_bswap.c: -------------------------------------------------------------------------------- 1 | static unsigned short x = __builtin_bswap16(0); 2 | static unsigned int y = __builtin_bswap32(0); 3 | static unsigned long long z = __builtin_bswap64(0); 4 | 5 | /* 6 | * check-name: __builtin_bswap 7 | * check-error-start 8 | * check-error-end 9 | */ 10 | -------------------------------------------------------------------------------- /validation/builtin_unreachable.c: -------------------------------------------------------------------------------- 1 | /* example from gcc documents */ 2 | 3 | void function_that_never_returns (void); 4 | 5 | static int g (int c) 6 | { 7 | if (c) 8 | return 1; 9 | function_that_never_returns (); 10 | __builtin_unreachable (); 11 | } 12 | 13 | /* 14 | * check-name: __builtin_unreachable() 15 | */ 16 | -------------------------------------------------------------------------------- /validation/c11-alignof.c: -------------------------------------------------------------------------------- 1 | static int foo(void) 2 | { 3 | return _Alignof(short); 4 | } 5 | 6 | /* 7 | * check-name: c11-alignof 8 | * check-command: test-linearize -std=c11 $file 9 | * 10 | * check-output-ignore 11 | * check-output-contains: ret\\.32 *\\$2 12 | */ 13 | -------------------------------------------------------------------------------- /validation/c11-noreturn.c: -------------------------------------------------------------------------------- 1 | static _Noreturn void foo(void) { while (1) ; } 2 | 3 | /* 4 | * check-name: c11-noreturn 5 | * check-command: test-parsing -std=c11 $file 6 | * 7 | * check-output-ignore 8 | * check-output-contains: \\[noreturn\\] 9 | */ 10 | -------------------------------------------------------------------------------- /validation/c11-stdc-version.c: -------------------------------------------------------------------------------- 1 | __STDC_VERSION__ 2 | 3 | /* 4 | * check-name: c11-stdc-version 5 | * check-command: sparse -E -std=c11 $file 6 | * 7 | * check-output-start 8 | 9 | 201112L 10 | * check-output-end 11 | */ 12 | -------------------------------------------------------------------------------- /validation/c11-thread-local.c: -------------------------------------------------------------------------------- 1 | static _Thread_local int foo; 2 | 3 | /* 4 | * check-name: c11-thread-local 5 | * check-command: test-parsing -std=c11 $file 6 | * 7 | * check-output-ignore 8 | * check-output-contains: \\[tls\\] 9 | */ 10 | -------------------------------------------------------------------------------- /validation/cast-bad-01.c: -------------------------------------------------------------------------------- 1 | extern unsigned long l; 2 | 3 | int foo(void) { 4 | return (int) (typeof(fundecl(0))) l; 5 | } 6 | 7 | /* 8 | * check-name: cast-bad 01 9 | * 10 | * check-error-start 11 | cast-bad-01.c:4:30: error: undefined identifier 'fundecl' 12 | * check-error-end 13 | */ 14 | -------------------------------------------------------------------------------- /validation/char-constant-signed.c: -------------------------------------------------------------------------------- 1 | int test(void) { return '\377' == -1; } 2 | 3 | /* 4 | * check-name: char-constant-signed 5 | * check-command: test-linearize -Wno-decl -fsigned-char $file 6 | * 7 | * check-output-ignore 8 | * check-output-returns: 1 9 | */ 10 | -------------------------------------------------------------------------------- /validation/char-constant-unsigned.c: -------------------------------------------------------------------------------- 1 | int test(void) { return '\377' == 255; } 2 | 3 | /* 4 | * check-name: char-constant-unsigned 5 | * check-command: test-linearize -Wno-decl -funsigned-char $file 6 | * 7 | * check-output-ignore 8 | * check-output-returns: 1 9 | */ 10 | -------------------------------------------------------------------------------- /validation/char-signed-native.c: -------------------------------------------------------------------------------- 1 | void foo(void) 2 | { 3 | _Static_assert((char) -1 == -1, "plain char is not signed"); 4 | } 5 | 6 | /* 7 | * check-name: char-signed-native 8 | * check-command: sparse --arch=i386 -Wno-decl $file 9 | */ 10 | -------------------------------------------------------------------------------- /validation/char-signed.c: -------------------------------------------------------------------------------- 1 | void foo(void) 2 | { 3 | _Static_assert((char) -1 == -1, "plain char is not signed"); 4 | } 5 | 6 | /* 7 | * check-name: fsigned-char 8 | * check-command: sparse -fsigned-char -Wno-decl $file 9 | */ 10 | -------------------------------------------------------------------------------- /validation/char-unsigned-native.c: -------------------------------------------------------------------------------- 1 | #define MASK ((1 << __CHAR_BIT__) - 1) 2 | 3 | void foo(void) 4 | { 5 | _Static_assert((char) -1 == (-1 & MASK), "plain char is not unsigned"); 6 | } 7 | 8 | /* 9 | * check-name: char-unsigned-native 10 | * check-command: sparse --arch=arm -Wno-decl $file 11 | */ 12 | -------------------------------------------------------------------------------- /validation/char-unsigned.c: -------------------------------------------------------------------------------- 1 | #define MASK ((1 << __CHAR_BIT__) - 1) 2 | 3 | void foo(void) 4 | { 5 | _Static_assert((char) -1 == (-1 & MASK), "plain char is not unsigned"); 6 | } 7 | 8 | /* 9 | * check-name: funsigned-char 10 | * check-command: sparse -funsigned-char -Wno-decl $file 11 | */ 12 | -------------------------------------------------------------------------------- /validation/check_access-multi.c: -------------------------------------------------------------------------------- 1 | extern int *a; 2 | extern int b[1]; 3 | 4 | static void foo(void) 5 | { 6 | *a = b[1]; 7 | } 8 | 9 | /* 10 | * check-name: check_access-multi 11 | * 12 | * check-error-start 13 | check_access-multi.c:6:15: warning: invalid access past the end of 'b' (4 4) 14 | * check-error-end 15 | */ 16 | -------------------------------------------------------------------------------- /validation/comma.c: -------------------------------------------------------------------------------- 1 | static char a[sizeof(char *) + 1]; 2 | static char b[1/(sizeof(a) - sizeof(0,a))]; 3 | static void f(void) 4 | { 5 | int c[42]; 6 | typeof((void)0,c) d; 7 | d = c; 8 | } 9 | /* 10 | * check-name: Comma and array decay 11 | * check-description: arguments of comma should degenerate 12 | */ 13 | -------------------------------------------------------------------------------- /validation/compare-null-to-int.c: -------------------------------------------------------------------------------- 1 | static unsigned int comparison = (void *)0 == 1; 2 | /* 3 | * check-name: Compare null pointer constant to int 4 | * check-description: Sparse used to allow this. 5 | * 6 | * check-error-start 7 | compare-null-to-int.c:1:44: error: incompatible types for operation (==): 8 | compare-null-to-int.c:1:44: void * 9 | compare-null-to-int.c:1:44: int 10 | * check-error-end 11 | */ 12 | -------------------------------------------------------------------------------- /validation/cond-address.c: -------------------------------------------------------------------------------- 1 | extern void f(void); 2 | extern int a[]; 3 | 4 | int foo(void) { if (f) return 1; return 0; } 5 | int bar(void) { if (a) return 1; return 0; } 6 | int qux(void) { if (f && a) return 1; return 0; } 7 | 8 | /* 9 | * check-name: cond-address.c 10 | * check-command: test-linearize -Wno-decl $file 11 | * check-output-ignore 12 | * 13 | * check-output-excludes: VOID 14 | */ 15 | -------------------------------------------------------------------------------- /validation/constexpr-constcond.c: -------------------------------------------------------------------------------- 1 | extern int var; 2 | 3 | static int a[] = { 4 | [0 ? var : 1] = 0, 5 | [1 ? 2 : var] = 0, 6 | }; 7 | 8 | /* 9 | * check-name: constexprness in constant conditionals 10 | */ 11 | -------------------------------------------------------------------------------- /validation/constexpr-labelref.c: -------------------------------------------------------------------------------- 1 | static void a(void) 2 | { 3 | label1: 4 | ; 5 | static void *b = &&label1; 6 | } 7 | 8 | /* 9 | * check-name: constexprness label reference 10 | * check-command: sparse -Wconstexpr-not-const $file 11 | * 12 | * check-error-start 13 | * check-error-end 14 | */ 15 | -------------------------------------------------------------------------------- /validation/constexpr-pointer-cast.c: -------------------------------------------------------------------------------- 1 | static int *a = (int*)0; // OK 2 | static int b = 0; 3 | static int *c = (int*)b; // KO 4 | 5 | 6 | /* 7 | * check-name: constexprness integer literal cast to pointer type 8 | * check-command: sparse -Wconstexpr-not-const $file 9 | * 10 | * check-error-start 11 | constexpr-pointer-cast.c:3:18: warning: non-constant initializer for static object 12 | * check-error-end 13 | */ 14 | -------------------------------------------------------------------------------- /validation/constexpr-shift.c: -------------------------------------------------------------------------------- 1 | #define __is_constexpr(x) \ 2 | (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8))) 3 | 4 | static void test(int x) { 5 | static int b[] = { 6 | [__builtin_choose_expr(__is_constexpr(1 << 1), 1, x)] = 0, 7 | }; 8 | } 9 | 10 | /* 11 | * check-name: constexpr-shift 12 | */ 13 | -------------------------------------------------------------------------------- /validation/constexpr-string.c: -------------------------------------------------------------------------------- 1 | static char *a = "foobar"; // OK 2 | 3 | /* 4 | * check-name: constness of string literal 5 | * check-command: sparse -Wconstexpr-not-const $file 6 | * 7 | * check-error-start 8 | * check-error-end 9 | */ 10 | -------------------------------------------------------------------------------- /validation/constexpr-types-compatible-p.c: -------------------------------------------------------------------------------- 1 | static int a[] = {[__builtin_types_compatible_p(int, int)] = 0}; 2 | 3 | /* 4 | * check-name: constness of __builtin_types_compatible_p() 5 | * 6 | * check-error-start 7 | * check-error-end 8 | */ 9 | -------------------------------------------------------------------------------- /validation/context-unreachable.c: -------------------------------------------------------------------------------- 1 | int fun(void); 2 | 3 | static void foo(void) 4 | { 5 | __context__(1); 6 | if (!fun()) { 7 | __builtin_unreachable(); 8 | return; 9 | } 10 | __context__(-1); 11 | } 12 | 13 | /* 14 | * check-name: context-unreachable 15 | */ 16 | -------------------------------------------------------------------------------- /validation/crash-add-doms.c: -------------------------------------------------------------------------------- 1 | char a; 2 | int b; 3 | void c(void) 4 | { 5 | if (0) { 6 | char *d; 7 | for (;;) 8 | for (;;) 9 | e: 10 | *d *= (a && 0) ^ b && *d; 11 | } 12 | goto e; 13 | } 14 | 15 | 16 | /* 17 | * check-name: crash add-doms 18 | * check-command: test-linearize $file 19 | * 20 | * check-error-ignore 21 | * check-output-ignore 22 | */ 23 | -------------------------------------------------------------------------------- /validation/crash-bb_target.c: -------------------------------------------------------------------------------- 1 | a() { 2 | &&b 3 | 4 | /* 5 | * check-name: crash bb_target 6 | * check-command: test-linearize $file 7 | * 8 | * check-error-ignore 9 | * check-output-ignore 10 | */ 11 | -------------------------------------------------------------------------------- /validation/crash-ep-active.c: -------------------------------------------------------------------------------- 1 | int a(int b) 2 | { 3 | return 0( && b; 4 | } 5 | 6 | /* 7 | * check-name: crash ep->active 8 | * check-command: test-linearize $file 9 | * 10 | * check-error-ignore 11 | * check-output-ignore 12 | */ 13 | -------------------------------------------------------------------------------- /validation/crash-rewrite-branch.c: -------------------------------------------------------------------------------- 1 | void a(int c, int e) 2 | { 3 | for(; b; c ; 4 | 5 | if (()) { 6 | unsigned short d = e; 7 | if (()) 8 | while () 9 | ; 10 | &d; 11 | } 12 | 13 | if (()) { 14 | int f = &f; 15 | } 16 | } 17 | 18 | /* 19 | * check-name: crash rewrite_branch 20 | * check-command: test-linearize $file 21 | * 22 | * check-error-ignore 23 | * check-output-ignore 24 | */ 25 | -------------------------------------------------------------------------------- /validation/crash-select.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | void *b; 3 | long c; 4 | }; 5 | 6 | long d(void); 7 | static long f(void) 8 | { 9 | struct s s; 10 | s.c = d(); 11 | if (s.c) 12 | s.c = 2; 13 | return s.c; 14 | } 15 | 16 | /* 17 | * check-name: crash-select 18 | */ 19 | -------------------------------------------------------------------------------- /validation/crash-undef-in-parens.c: -------------------------------------------------------------------------------- 1 | void foo(void) { return (UNDEF_STUFF_IN_PARENS); } 2 | 3 | /* 4 | * check-name: crash-undef-in-parens 5 | * 6 | * check-error-start 7 | crash-undef-in-parens.c:1:26: error: undefined identifier 'UNDEF_STUFF_IN_PARENS' 8 | * check-error-end 9 | */ 10 | -------------------------------------------------------------------------------- /validation/declaration-after-statement-ansi.c: -------------------------------------------------------------------------------- 1 | static void func (int i) 2 | { 3 | i; 4 | int j = i; 5 | } 6 | /* 7 | * check-name: declaration after statement (ANSI) 8 | * check-command: sparse -ansi $file 9 | * check-error-start 10 | declaration-after-statement-ansi.c:4:9: warning: mixing declarations and code 11 | * check-error-end 12 | */ 13 | -------------------------------------------------------------------------------- /validation/declaration-after-statement-c89.c: -------------------------------------------------------------------------------- 1 | static void func (int i) 2 | { 3 | i; 4 | int j = i; 5 | } 6 | /* 7 | * check-name: declaration after statement (C89) 8 | * check-command: sparse -std=c89 $file 9 | * check-error-start 10 | declaration-after-statement-c89.c:4:9: warning: mixing declarations and code 11 | * check-error-end 12 | */ 13 | -------------------------------------------------------------------------------- /validation/declaration-after-statement-c99.c: -------------------------------------------------------------------------------- 1 | static void func (int i) 2 | { 3 | i; 4 | int j = i; 5 | } 6 | /* 7 | * check-name: declaration after statement (C99) 8 | * check-command: sparse -std=c99 $file 9 | */ 10 | -------------------------------------------------------------------------------- /validation/declaration-after-statement-default.c: -------------------------------------------------------------------------------- 1 | static void func (int i) 2 | { 3 | i; 4 | int j = i; 5 | } 6 | /* 7 | * check-name: declaration after statement (default) 8 | * check-command: sparse $file 9 | */ 10 | -------------------------------------------------------------------------------- /validation/definitions.c: -------------------------------------------------------------------------------- 1 | static inline int f(void); 2 | static int g(void) 3 | { 4 | return f(); 5 | } 6 | static inline int f(void) 7 | { 8 | return 0; 9 | } 10 | /* 11 | * check-name: finding definitions 12 | */ 13 | -------------------------------------------------------------------------------- /validation/double-semicolon.c: -------------------------------------------------------------------------------- 1 | extern void *memset (void *s, int c, int n); 2 | static void test(void) 3 | { 4 | struct { int foo;; } val; 5 | memset(&val, 0, sizeof(val)); 6 | } 7 | /* 8 | * check-name: Double semicolon in struct 9 | */ 10 | -------------------------------------------------------------------------------- /validation/empty-assign.c: -------------------------------------------------------------------------------- 1 | static int foo(int a) 2 | { 3 | a = ; // KO 4 | return a; 5 | } 6 | 7 | /* 8 | * check-name: empty-assign 9 | * 10 | * check-error-start 11 | empty-assign.c:3:11: error: expression expected before ';' 12 | * check-error-end 13 | */ 14 | -------------------------------------------------------------------------------- /validation/empty-char-constant.c: -------------------------------------------------------------------------------- 1 | static int a = ''; 2 | 3 | /* 4 | * check-name: empty-char-constant 5 | * 6 | * check-error-start 7 | empty-char-constant.c:1:16: error: empty character constant 8 | * check-error-end 9 | */ 10 | -------------------------------------------------------------------------------- /validation/empty-file: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/error27/smatch/e1d933013098891462291a29c4cb664b3dc16522/validation/empty-file -------------------------------------------------------------------------------- /validation/empty-initializer.c: -------------------------------------------------------------------------------- 1 | static int i = ; // KO 2 | 3 | /* 4 | * check-name: empty-initializer 5 | * 6 | * check-error-start 7 | empty-initializer.c:1:16: error: expression expected before ';' 8 | * check-error-end 9 | */ 10 | -------------------------------------------------------------------------------- /validation/endian-big.c: -------------------------------------------------------------------------------- 1 | #if defined(__LITTLE_ENDIAN__) 2 | #error "__LITTLE_ENDIAN__ defined!" 3 | #endif 4 | #if (__BIG_ENDIAN__ != 1) 5 | #error "__BIG_ENDIAN__ not correctly defined!" 6 | #endif 7 | #if (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__) 8 | #error "__BYTE_ORDER__ not correctly defined!" 9 | #endif 10 | 11 | /* 12 | * check-name: endian-big.c 13 | * check-command: sparse -mbig-endian $file 14 | */ 15 | -------------------------------------------------------------------------------- /validation/endian-little.c: -------------------------------------------------------------------------------- 1 | #if defined(__BIG_ENDIAN__) 2 | #error "__BIG_ENDIAN__ defined!" 3 | #endif 4 | #if (__LITTLE_ENDIAN__ != 1) 5 | #error "__LITTLE_ENDIAN__ not correctly defined!" 6 | #endif 7 | #if (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__) 8 | #error "__BYTE_ORDER__ not correctly defined!" 9 | #endif 10 | 11 | /* 12 | * check-name: endian-little.c 13 | * check-command: sparse -mlittle-endian $file 14 | */ 15 | -------------------------------------------------------------------------------- /validation/enum-init-constness.c: -------------------------------------------------------------------------------- 1 | extern int invalid; 2 | 3 | enum e { 4 | E = 1 ? 1 : invalid 5 | }; 6 | 7 | /* 8 | * check-name: enum-init-constness 9 | */ 10 | -------------------------------------------------------------------------------- /validation/enum-invalid.c: -------------------------------------------------------------------------------- 1 | enum e { }; 2 | enum f { F = 0.1 }; 3 | 4 | /* 5 | * check-name: enum-invalid 6 | * 7 | * check-error-start 8 | enum-invalid.c:1:10: error: empty enum definition 9 | enum-invalid.c:2:14: error: bad constant expression 10 | * check-error-end 11 | */ 12 | -------------------------------------------------------------------------------- /validation/enum-same-type.c: -------------------------------------------------------------------------------- 1 | enum num { 2 | NEG = -1, 3 | NIL = 0, 4 | ONE = 1U, 5 | DUO = 2LL, 6 | }; 7 | 8 | _Static_assert([typeof(NIL)] == [typeof(NEG)], "enum same type"); 9 | _Static_assert([typeof(ONE)] == [typeof(NEG)], "enum same type"); 10 | _Static_assert([typeof(DUO)] == [typeof(NEG)], "enum same type"); 11 | 12 | /* 13 | * check-name: enum-same-type 14 | */ 15 | -------------------------------------------------------------------------------- /validation/enum-sign-extend.c: -------------------------------------------------------------------------------- 1 | enum num { 2 | a = 0x80000000, 3 | b = -1, 4 | }; 5 | 6 | _Static_assert([typeof(b)] == [long], "type"); 7 | _Static_assert(b == -1L, "value"); 8 | 9 | /* 10 | * check-name: enum-sign-extend 11 | * check-command: sparse -m64 $file 12 | */ 13 | -------------------------------------------------------------------------------- /validation/enum_scope.c: -------------------------------------------------------------------------------- 1 | enum {A = 12}; 2 | 3 | static void f(void) 4 | { 5 | enum {A = A + 1, B}; 6 | char s[1 - 2 * (B != 14)]; 7 | } 8 | 9 | /* 10 | * check-name: enumeration constants' scope [6.2.1p7] 11 | */ 12 | -------------------------------------------------------------------------------- /validation/error-at-eof.c: -------------------------------------------------------------------------------- 1 | /* 2 | * check-name: error-at-eof 3 | * 4 | * check-error-start 5 | error-at-eof.c:11:0: error: Expected ; at end of declaration 6 | error-at-eof.c:11:0: error: got end-of-input 7 | * check-error-end 8 | */ 9 | 10 | int a 11 | -------------------------------------------------------------------------------- /validation/eval-bad-assign1.c: -------------------------------------------------------------------------------- 1 | static void kos(int *r, int a) 2 | { 3 | r = ({ __builtin_types_compatible_p(int, int); }); 4 | } 5 | 6 | /* 7 | * check-name: eval-bad-assign1 8 | * 9 | * check-error-start 10 | eval-bad-assign1.c:3:11: warning: incorrect type in assignment (different base types) 11 | eval-bad-assign1.c:3:11: expected int *r 12 | eval-bad-assign1.c:3:11: got int 13 | * check-error-end 14 | */ 15 | -------------------------------------------------------------------------------- /validation/eval/addressable-degen.c: -------------------------------------------------------------------------------- 1 | extern void def(void *, unsigned int); 2 | 3 | static int bar(void) 4 | { 5 | int x[2] = { 1, 2 }; 6 | 7 | def(x, sizeof(x)); 8 | return x[1]; 9 | } 10 | 11 | /* 12 | * check-name: eval/addressable-degen 13 | * check-command: test-linearize -fdump-ir $file 14 | * 15 | * check-output-ignore 16 | * check-output-contains: load\\. 17 | */ 18 | -------------------------------------------------------------------------------- /validation/eval/array-quals0.c: -------------------------------------------------------------------------------- 1 | static int a[2][3]; 2 | static const int (*p)[3] = a; 3 | 4 | /* 5 | * check-name: array-quals0 6 | */ 7 | -------------------------------------------------------------------------------- /validation/eval/not-cast-bool.c: -------------------------------------------------------------------------------- 1 | static _Bool foo(void) 2 | { 3 | unsigned char c = 1; 4 | _Bool b = ~c; 5 | return b; 6 | } 7 | 8 | /* 9 | * check-name: not-cast-bool 10 | * check-command: test-linearize -Wno-decl $file 11 | * 12 | * check-output-ignore 13 | * check-output-returns: 1 14 | */ 15 | -------------------------------------------------------------------------------- /validation/eval/not-cast-float.c: -------------------------------------------------------------------------------- 1 | static int foo(void) 2 | { 3 | int i = 123; 4 | float x = ~i; 5 | return (x < 0); 6 | } 7 | 8 | /* 9 | * check-name: eval-bool-zext-neg 10 | * check-command: test-linearize -Wno-decl $file 11 | * 12 | * check-output-ignore 13 | * check-output-returns: 1 14 | */ 15 | -------------------------------------------------------------------------------- /validation/eval/typeof0.c: -------------------------------------------------------------------------------- 1 | static int i; 2 | static typeof(i) *ptr; 3 | 4 | /* 5 | * check-name: eval-typeof0 6 | * check-command: test-show-type $file 7 | * 8 | * check-output-ignore 9 | * check-output-excludes: unknown type 10 | */ 11 | -------------------------------------------------------------------------------- /validation/eval/undecl-no-indent.c: -------------------------------------------------------------------------------- 1 | inline void fun(void) 2 | { 3 | undecl(); 4 | } 5 | 6 | void foo(void); 7 | void foo(void) 8 | { 9 | fun(); 10 | fun(); 11 | } 12 | 13 | /* 14 | * check-name: undecl-no-indent 15 | * 16 | * check-error-start 17 | eval/undecl-no-indent.c:3:9: error: undefined identifier 'undecl' 18 | * check-error-end 19 | */ 20 | -------------------------------------------------------------------------------- /validation/eval/unqual-cast.c: -------------------------------------------------------------------------------- 1 | #define cvr const volatile restrict 2 | 3 | _Static_assert([typeof((cvr int) 0)] == [int]); 4 | _Static_assert([typeof((cvr int *) 0)] == [cvr int *]); 5 | 6 | static int *function(volatile int x) 7 | { 8 | extern typeof((typeof(x)) (x)) y; 9 | return &y; 10 | } 11 | 12 | /* 13 | * check-name: unqual-cast 14 | */ 15 | -------------------------------------------------------------------------------- /validation/eval/unqual-comma.c: -------------------------------------------------------------------------------- 1 | #define __unqual_typeof(x) typeof(((void)0, (x))) 2 | 3 | int *foo(volatile int x); 4 | int *foo(volatile int x) 5 | { 6 | extern __unqual_typeof(x) y; 7 | return &y; 8 | } 9 | 10 | /* 11 | * check-name: unqual-comma 12 | */ 13 | -------------------------------------------------------------------------------- /validation/eval/unqual-stmt-expr.c: -------------------------------------------------------------------------------- 1 | #define __unqual_typeof(x) typeof(({ x; })) 2 | 3 | int *foo(volatile int x); 4 | int *foo(volatile int x) 5 | { 6 | extern __unqual_typeof(x) y; 7 | return &y; 8 | } 9 | 10 | /* 11 | * check-name: unqual-stmt-expr 12 | */ 13 | -------------------------------------------------------------------------------- /validation/expand/asm0.c: -------------------------------------------------------------------------------- 1 | static void foo(void) 2 | { 3 | asm("" :: "i" (42 & 3)); 4 | asm("" :: "i" (__builtin_constant_p(0))); 5 | } 6 | 7 | /* 8 | * check-name: expand-asm0 9 | * check-command: test-linearize $file 10 | * 11 | * check-output-start 12 | foo: 13 | .L0: 14 | 15 | asm "" 16 | in: "i" ($2) 17 | asm "" 18 | in: "i" ($1) 19 | ret 20 | 21 | 22 | * check-output-end 23 | */ 24 | -------------------------------------------------------------------------------- /validation/expand/builtin_isdigit.c: -------------------------------------------------------------------------------- 1 | _Static_assert(__builtin_isdigit('0')); 2 | _Static_assert(__builtin_isdigit('9')); 3 | 4 | _Static_assert(!__builtin_isdigit(0)); 5 | _Static_assert(!__builtin_isdigit(' ')); 6 | _Static_assert(!__builtin_isdigit('z')); 7 | 8 | /* 9 | * check-name: builtin_isdigit 10 | */ 11 | -------------------------------------------------------------------------------- /validation/expand/constant-init-array.c: -------------------------------------------------------------------------------- 1 | int test_array(int i) 2 | { 3 | static const int a[3] = { 1, 2, 3, }; 4 | 5 | return a[1]; 6 | } 7 | 8 | /* 9 | * check-name: constant-init-array 10 | * check-command: test-linearize -Wno-decl -fdump-ir $file 11 | * 12 | * check-output-ignore 13 | * check-output-excludes: phisrc\\..*return.*\\$2 14 | * check-output-contains: load\\. 15 | */ 16 | -------------------------------------------------------------------------------- /validation/expand/constant-init-nested-array.c: -------------------------------------------------------------------------------- 1 | int foo(void) 2 | { 3 | int a[2][3] = {{0, 1, 2},{3, 4, 5}}; 4 | return a[1][2]; 5 | } 6 | 7 | /* 8 | * check-name: constant-init-nested-array 9 | * check-command: test-linearize -Wno-decl -fdump-ir $file 10 | * check-known-to-fail 11 | * 12 | * check-output-ignore 13 | * check-output-contains: phisrc\\..*\\$5 14 | * check-output-excludes: load\\. 15 | */ 16 | -------------------------------------------------------------------------------- /validation/expand/constant-init-string.c: -------------------------------------------------------------------------------- 1 | char foo(void) 2 | { 3 | static const char s[] = "abc?"; 4 | return s[3]; 5 | } 6 | 7 | /* 8 | * check-name: constant-init-nested-array 9 | * check-command: test-linearize -Wno-decl -fdump-ir $file 10 | * check-known-to-fail 11 | * 12 | * check-output-ignore 13 | * check-output-contains: phisrc\\..*\\$63 14 | * check-output-pattern(0,1): load\\. 15 | */ 16 | -------------------------------------------------------------------------------- /validation/expand/cost-deref-nested.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | struct { 3 | int u, v; 4 | } a, b; 5 | }; 6 | 7 | static const struct s s; 8 | 9 | static int foo(int c) 10 | { 11 | return c && s.b.v; 12 | } 13 | 14 | /* 15 | * check-name: cost-deref-nested 16 | * check-command: test-linearize -fdump-ir $file 17 | * 18 | * check-output-ignore 19 | * check-output-excludes: cbr 20 | */ 21 | -------------------------------------------------------------------------------- /validation/expand/default-init-array.c: -------------------------------------------------------------------------------- 1 | int test_array(int i) 2 | { 3 | static const int a[3] = { [0] = 1, [2] = 3, }; 4 | 5 | return a[1]; 6 | } 7 | 8 | /* 9 | * check-name: default-init-array 10 | * check-command: test-linearize -Wno-decl -fdump-ir $file 11 | * check-known-to-fail 12 | * 13 | * check-output-ignore 14 | * check-output-contains: phisrc\\..*return.*\\$0 15 | * check-output-excludes: load\\. 16 | */ 17 | -------------------------------------------------------------------------------- /validation/extern-array.c: -------------------------------------------------------------------------------- 1 | extern const char *v4l2_type_names[]; 2 | const char *v4l2_type_names[] = { 3 | "test" 4 | }; 5 | extern const char *v4l2_type_names[]; 6 | 7 | static void test(void) 8 | { 9 | unsigned sz = sizeof(v4l2_type_names); 10 | } 11 | /* 12 | * check-name: duplicate extern array 13 | */ 14 | 15 | -------------------------------------------------------------------------------- /validation/fdiag-prefix.c: -------------------------------------------------------------------------------- 1 | int a. 2 | 3 | /* 4 | * check-name: fdiag-prefix 5 | * check-command: sparse -fdiagnostic-prefix=prefix $file 6 | * 7 | * check-error-start 8 | fdiag-prefix.c:1:6: prefix: error: Expected ; at end of declaration 9 | fdiag-prefix.c:1:6: prefix: error: got . 10 | * check-error-end 11 | */ 12 | -------------------------------------------------------------------------------- /validation/field-overlap.c: -------------------------------------------------------------------------------- 1 | static struct { 2 | int x; 3 | struct { 4 | int z; 5 | int w; 6 | } y; 7 | } a = { .y.z = 1, .y.w = 2, }; 8 | 9 | static struct {int x, y, z;} w[2] = { 10 | {.x = 1, .y = 2, .z = 3}, 11 | {.x = 1, .y = 2, .z = 3} 12 | }; 13 | 14 | /* 15 | * check-name: field overlap 16 | */ 17 | -------------------------------------------------------------------------------- /validation/flex-array-array.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | int i; 3 | long f[]; 4 | }; 5 | 6 | static struct s a[2]; 7 | 8 | /* 9 | * check-name: flex-array-array 10 | * check-command: sparse -Wflexible-array-array $file 11 | * 12 | * check-error-start 13 | flex-array-array.c:6:18: warning: array of flexible structures 14 | * check-error-end 15 | */ 16 | -------------------------------------------------------------------------------- /validation/flex-array-sizeof.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | int i; 3 | long f[]; 4 | }; 5 | 6 | static int foo(struct s *s) 7 | { 8 | return sizeof(*s); 9 | } 10 | 11 | /* 12 | * check-name: flex-array-sizeof 13 | * check-command: sparse -Wflexible-array-sizeof $file 14 | * 15 | * check-error-start 16 | flex-array-sizeof.c:8:16: warning: using sizeof on a flexible structure 17 | * check-error-end 18 | */ 19 | -------------------------------------------------------------------------------- /validation/flex-array-union-array-no.c: -------------------------------------------------------------------------------- 1 | #include "flex-array-union-array.h" 2 | 3 | /* 4 | * check-name: flex-array-union-no 5 | * check-command: sparse -Wflexible-array-array -Wno-flexible-array-union $file 6 | * 7 | * check-error-start 8 | * check-error-end 9 | */ 10 | -------------------------------------------------------------------------------- /validation/flex-array-union-array-yes.c: -------------------------------------------------------------------------------- 1 | #include "flex-array-union-array.h" 2 | 3 | /* 4 | * check-name: flex-array-union-yes 5 | * check-command: sparse -Wflexible-array-array -Wflexible-array-union $file 6 | * 7 | * check-error-start 8 | flex-array-union-array-yes.c: note: in included file: 9 | flex-array-union-array.h:11:17: warning: array of flexible structures 10 | * check-error-end 11 | */ 12 | -------------------------------------------------------------------------------- /validation/flex-array-union-array.h: -------------------------------------------------------------------------------- 1 | struct s_flex { 2 | int i; 3 | long f[]; 4 | }; 5 | 6 | union s { 7 | struct s_flex flex; 8 | char buf[200]; 9 | }; 10 | 11 | static union s a[2]; 12 | -------------------------------------------------------------------------------- /validation/fored_arg.c: -------------------------------------------------------------------------------- 1 | /* 2 | * check-name: Forced function argument type. 3 | */ 4 | 5 | #define __iomem __attribute__((noderef, address_space(2))) 6 | #define __force __attribute__((force)) 7 | 8 | static void foo(__force void * addr) 9 | { 10 | } 11 | 12 | 13 | static void bar(void) 14 | { 15 | void __iomem *a; 16 | foo(a); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /validation/foul-scalar.c: -------------------------------------------------------------------------------- 1 | #define __bitwise __attribute__((bitwise)) 2 | 3 | typedef unsigned short __bitwise __be16; 4 | 5 | static void foo(__be16 x) 6 | { 7 | if (~x) 8 | ; 9 | } 10 | 11 | /* 12 | * check-name: foul-scalar 13 | */ 14 | -------------------------------------------------------------------------------- /validation/function-attribute-inner.c: -------------------------------------------------------------------------------- 1 | #define __noreturn __attribute__((__noreturn__)) 2 | 3 | void __noreturn fun(void); 4 | 5 | _Static_assert([void (__noreturn *)(void)] == [typeof(&fun)], ""); 6 | 7 | /* 8 | * check-name: function-attribute-inner 9 | */ 10 | -------------------------------------------------------------------------------- /validation/function-attribute-void-ptr.c: -------------------------------------------------------------------------------- 1 | #define __noreturn __attribute__((__noreturn__)) 2 | 3 | void fun(void *); 4 | void __noreturn die(void); 5 | 6 | static void foo(void) 7 | { 8 | void *ptr = die; 9 | fun(die); 10 | } 11 | 12 | /* 13 | * check-name: function-attribute-void-ptr 14 | */ 15 | -------------------------------------------------------------------------------- /validation/function-attribute.c: -------------------------------------------------------------------------------- 1 | #define __pure __attribute__((pure)) 2 | 3 | 4 | static __pure int funi(int val) 5 | { 6 | return val; 7 | } 8 | 9 | static __pure int *funp(int *ptr) 10 | { 11 | return ptr; 12 | } 13 | 14 | static void foo(int val, int *ptr) 15 | { 16 | int nbr = funi(val); 17 | int *res = funp(ptr); 18 | } 19 | 20 | /* 21 | * check-name: function-attribute 22 | */ 23 | -------------------------------------------------------------------------------- /validation/function-pointer-inheritance.c: -------------------------------------------------------------------------------- 1 | extern int foo(int f(int, void *)); 2 | 3 | int foo(int (*f)(int, void *)) 4 | { 5 | return 0; 6 | } 7 | /* 8 | * check-name: Function pointer inheritance 9 | */ 10 | -------------------------------------------------------------------------------- /validation/function-redecl-funattr.c: -------------------------------------------------------------------------------- 1 | #define __pure __attribute__((pure)) 2 | #define __noreturn __attribute__((noreturn)) 3 | 4 | 5 | int __pure p(int i); 6 | int p(int i) { return i; } 7 | 8 | void __noreturn n(void); 9 | void n(void) { while (1) ; } 10 | 11 | /* 12 | * check-name: function-redecl-funattr 13 | */ 14 | -------------------------------------------------------------------------------- /validation/goto-reserved.c: -------------------------------------------------------------------------------- 1 | static void foo(void) 2 | { 3 | goto return; 4 | } 5 | 6 | /* 7 | * check-name: goto-reserved 8 | * 9 | * check-error-start 10 | goto-reserved.c:3:14: error: Trying to use reserved word 'return' as identifier 11 | * check-error-end 12 | */ 13 | -------------------------------------------------------------------------------- /validation/implicit-KR-arg-type0.c: -------------------------------------------------------------------------------- 1 | int foo(a, b) 2 | int a; 3 | { 4 | if (b) 5 | return a; 6 | } 7 | 8 | /* 9 | * check-name: implicit-KR-arg-type 10 | * check-command: sparse -Wno-decl -Wold-style-definition -Wno-implicit-int $file 11 | * 12 | * check-error-start 13 | implicit-KR-arg-type0.c:2:9: warning: non-ANSI definition of function 'foo' 14 | * check-error-end 15 | */ 16 | -------------------------------------------------------------------------------- /validation/implicit-type.c: -------------------------------------------------------------------------------- 1 | extern a; 2 | static b; 3 | c; 4 | 5 | /* 6 | * check-name: implicit-type.c 7 | * check-command: sparse -Wno-decl $file 8 | * 9 | * check-error-start 10 | implicit-type.c:1:8: warning: 'a' has implicit type 11 | implicit-type.c:2:8: warning: 'b' has implicit type 12 | implicit-type.c:3:1: warning: 'c' has implicit type 13 | * check-error-end 14 | */ 15 | -------------------------------------------------------------------------------- /validation/include-eval.c: -------------------------------------------------------------------------------- 1 | /* nothing */ 2 | 3 | /* 4 | * check-name: include-eval.c 5 | * check-command: sparse -include ./include-eval.inc $file 6 | */ 7 | -------------------------------------------------------------------------------- /validation/include-eval.inc: -------------------------------------------------------------------------------- 1 | typedef unsigned long long_t; 2 | 3 | inline 4 | static unsigned int ok(void) 5 | { 6 | return sizeof(long_t); 7 | } 8 | 9 | static unsigned int ko(void) 10 | { 11 | return sizeof(long_t); 12 | } 13 | -------------------------------------------------------------------------------- /validation/infinite-loop0.c: -------------------------------------------------------------------------------- 1 | void foo(void) 2 | { 3 | int a = a || 0; 4 | if (a) ; 5 | } 6 | 7 | /* 8 | * check-name: internal infinite loop (0) 9 | * check-command: sparse -Wno-decl $file 10 | * check-timeout: 11 | */ 12 | -------------------------------------------------------------------------------- /validation/infinite-loop02.c: -------------------------------------------------------------------------------- 1 | void foo(void) 2 | { 3 | int a = 1; 4 | while ((a = !a)) 5 | ; 6 | } 7 | 8 | /* 9 | * check-name: infinite loop 02 10 | * check-command: sparse -Wno-decl $file 11 | * check-timeout: 12 | */ 13 | -------------------------------------------------------------------------------- /validation/infinite-loop03.c: -------------------------------------------------------------------------------- 1 | static void foo(int *buf) 2 | { 3 | int a = 1; 4 | int *b; 5 | do { 6 | if (a) 7 | b = buf; 8 | if (a) 9 | *buf = 0; 10 | } while (!(a = !a)); 11 | } 12 | 13 | /* 14 | * check-name: infinite loop 03 15 | * check-command: sparse -Wno-decl $file 16 | * check-timeout: 17 | */ 18 | -------------------------------------------------------------------------------- /validation/infinite-loop04.c: -------------------------------------------------------------------------------- 1 | extern void use(char); 2 | 3 | static void foo(char *b) 4 | { 5 | while (b) { 6 | if (b++) 7 | continue; 8 | ++b; 9 | use(*b); 10 | &b; 11 | } 12 | } 13 | 14 | /* 15 | * check-name: internal infinite loop (4) 16 | * check-command: sparse $file 17 | * check-timeout: 18 | */ 19 | -------------------------------------------------------------------------------- /validation/inline-early/bug-bad-token.c: -------------------------------------------------------------------------------- 1 | inline void fun(int x) 2 | { 3 | (typeof(@)) x; 4 | } 5 | 6 | void foo(void) 7 | { 8 | fun; 9 | } 10 | 11 | /* 12 | * check-name: bug-bad-token 13 | * check-exit-value: 0 14 | * check-error-ignore 15 | */ 16 | -------------------------------------------------------------------------------- /validation/inline-early/variadic0.c: -------------------------------------------------------------------------------- 1 | static inline void fun(const char *fmt, ...) 2 | { 3 | } 4 | 5 | void main(void) 6 | { 7 | fun("abc", 0); // will be a SYM_BASETYPE 8 | fun("ijk", (const int)1); // will be a SYM_NODE 9 | } 10 | 11 | /* 12 | * check-name: variadic0 13 | */ 14 | -------------------------------------------------------------------------------- /validation/inline-generic.c: -------------------------------------------------------------------------------- 1 | extern int a, b; 2 | inline int c(void) { return a++; } 3 | inline int e(int d) { return 0; } 4 | inline unsigned f(void) { return e(_Generic(b, int: c())); } 5 | static int g(void) { return f(); } 6 | static int h(void) { return f(); } 7 | 8 | /* 9 | * check-name: inline-generic 10 | */ 11 | -------------------------------------------------------------------------------- /validation/inline_compound_literals.c: -------------------------------------------------------------------------------- 1 | struct foo { 2 | int x; 3 | }; 4 | 5 | static inline void baz(void) 6 | { 7 | (struct foo) { .x = 0 }; 8 | } 9 | 10 | static void barf(void) 11 | { 12 | baz(); 13 | } 14 | 15 | static void foo(void) 16 | { 17 | baz(); 18 | } 19 | 20 | /* 21 | * check-name: inline compound literals 22 | */ 23 | -------------------------------------------------------------------------------- /validation/inline_self.c: -------------------------------------------------------------------------------- 1 | static inline void foo(void) 2 | { 3 | foo(); 4 | } 5 | 6 | static void baz(void) 7 | { 8 | foo(); 9 | } 10 | 11 | /* 12 | * check-name: inline_self 13 | */ 14 | -------------------------------------------------------------------------------- /validation/integer-promotions.c: -------------------------------------------------------------------------------- 1 | static int add_char(void) 2 | { 3 | return (char) 127 + (char) 127 + (char) 2; 4 | } 5 | /* 6 | * check-name: Integer promotions 7 | */ 8 | -------------------------------------------------------------------------------- /validation/ioc-typecheck.c: -------------------------------------------------------------------------------- 1 | extern unsigned int __invalid_size_argument_for_IOC; 2 | static unsigned iocnrs[] = { 3 | [ 1 ? 0 : __invalid_size_argument_for_IOC ] = 1, 4 | }; 5 | /* 6 | * check-name: integer constant & conditional expression 7 | */ 8 | -------------------------------------------------------------------------------- /validation/kill-computedgoto.c: -------------------------------------------------------------------------------- 1 | void foo(int a); 2 | void foo(int a) 3 | { 4 | void *l = &&end + 3; 5 | 6 | end: 7 | if (a * 0) 8 | goto *l; 9 | } 10 | 11 | /* 12 | * check-name: kill-computedgoto 13 | * check-command: test-linearize $file 14 | * 15 | * check-output-ignore 16 | * check-output-excludes: add\\. 17 | */ 18 | -------------------------------------------------------------------------------- /validation/kill-insert-branch.c: -------------------------------------------------------------------------------- 1 | void foo(int a) 2 | { 3 | int b = 1; 4 | if (a) 5 | b++; 6 | if (b) 7 | ; 8 | } 9 | 10 | void bar(int a) 11 | { 12 | if (a ? 1 : 2) 13 | ; 14 | } 15 | 16 | /* 17 | * check-name: kill insert-branch 18 | * check-command: test-linearize -Wno-decl $file 19 | * 20 | * check-output-ignore 21 | * check-output-excludes: select\\. 22 | */ 23 | -------------------------------------------------------------------------------- /validation/kill-phisrc.c: -------------------------------------------------------------------------------- 1 | int foo(int a, int b) 2 | { 3 | int r = a + b; 4 | 5 | if (a && 0) { 6 | int s = r; 7 | if (b) 8 | s = 0; 9 | (void) s; 10 | } 11 | 12 | return 0; 13 | } 14 | 15 | /* 16 | * check-name: kill-phisrc 17 | * check-command: test-linearize -Wno-decl $file 18 | * 19 | * check-output-ignore 20 | * check-output-excludes: add\\. 21 | */ 22 | -------------------------------------------------------------------------------- /validation/kill-rewritten-load.c: -------------------------------------------------------------------------------- 1 | int foo(int i) 2 | { 3 | i++; 4 | if (i && 0) 5 | i; 6 | return 0; 7 | } 8 | 9 | 10 | /* 11 | * check-name: kill-rewritten-load 12 | * check-command: test-linearize -Wno-decl $file 13 | * check-output-ignore 14 | * 15 | * check-output-excludes: add\\. 16 | */ 17 | -------------------------------------------------------------------------------- /validation/kill-select.c: -------------------------------------------------------------------------------- 1 | void foo(int x); 2 | void foo(int x) 3 | { 4 | unsigned int ui; 5 | 6 | ui = x + 1; 7 | ui = ui ? 0 : 1; 8 | } 9 | 10 | /* 11 | * check-name: kill-select 12 | * check-command: test-linearize $file 13 | * 14 | * check-output-ignore 15 | * check-output-excludes: add\\. 16 | */ 17 | -------------------------------------------------------------------------------- /validation/kill-slice.c: -------------------------------------------------------------------------------- 1 | struct bar { 2 | int x; 3 | int y[2]; 4 | }; 5 | struct bar bar(void); 6 | 7 | int foo(void) 8 | { 9 | int x = bar().x; 10 | return x & 0; 11 | } 12 | 13 | /* 14 | * check-name: kill-slice 15 | * check-command: test-linearize -Wno-decl $file 16 | * check-output-ignore 17 | * 18 | * check-output-excludes: slice\\. 19 | */ 20 | -------------------------------------------------------------------------------- /validation/kill-switch.c: -------------------------------------------------------------------------------- 1 | extern int i; 2 | 3 | static void foo(void) 4 | { 5 | switch (i) { 6 | case 0: 7 | ; 8 | } 9 | } 10 | 11 | /* 12 | * check-name: kill-switch 13 | * check-command: test-linearize $file 14 | * 15 | * check-output-ignore 16 | * check-output-excludes: load\\. 17 | */ 18 | -------------------------------------------------------------------------------- /validation/knr-attr-crash.c: -------------------------------------------------------------------------------- 1 | typedef int word; 2 | 3 | void foo(word x); 4 | 5 | void foo(x) 6 | word x; 7 | { } 8 | 9 | /* 10 | * check-name: knr-attr-crash 11 | * check-command: sparse -Wno-old-style-definition $file 12 | */ 13 | -------------------------------------------------------------------------------- /validation/label-asm.c: -------------------------------------------------------------------------------- 1 | #define barrier() __asm__ __volatile__("": : :"memory") 2 | 3 | static void f(void) 4 | { 5 | barrier(); 6 | goto l; 7 | l: 8 | barrier(); 9 | } 10 | /* 11 | * check-name: Label followed by __asm__ 12 | * check-description: Sparse used to parse the __asm__ as modifying the label. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/label-attr.c: -------------------------------------------------------------------------------- 1 | static int foo(void) 2 | { 3 | goto rtattr_failure; 4 | rtattr_failure: __attribute__ ((unused)) 5 | return -1; 6 | } 7 | /* 8 | * check-name: Label attribute 9 | */ 10 | -------------------------------------------------------------------------------- /validation/label-redefined.c: -------------------------------------------------------------------------------- 1 | extern void fun(void); 2 | 3 | static void foo(int p) 4 | { 5 | l: 6 | if (p) 7 | l: 8 | fun(); 9 | } 10 | 11 | /* 12 | * check-name: label-redefined 13 | * 14 | * check-error-start 15 | label-redefined.c:7:1: error: label 'l' redefined 16 | * check-error-end 17 | */ 18 | -------------------------------------------------------------------------------- /validation/label-scope.c: -------------------------------------------------------------------------------- 1 | static int f(int n) 2 | { 3 | __label__ n; 4 | n: return n; 5 | } 6 | 7 | /* 8 | * check-name: __label__ scope 9 | */ 10 | -------------------------------------------------------------------------------- /validation/linear/asm-toplevel.c: -------------------------------------------------------------------------------- 1 | __asm__("/* nothing */"); 2 | /* 3 | * check-name: asm-toplevel.c 4 | * check-command: test-linearize $file 5 | * check-known-to-fail 6 | * check-output-ignore 7 | * check-output-contains: asm *".. nothing .." 8 | */ 9 | -------------------------------------------------------------------------------- /validation/linear/bitfield-inc.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | int f:5; 3 | }; 4 | 5 | void inc(struct s *p) 6 | { 7 | p->f++; 8 | } 9 | 10 | /* 11 | * check-name: bitfield-inc 12 | * check-command: test-linearize -Wno-decl $file 13 | * 14 | * check-output-ignore 15 | * check-output-excludes: add\\.5 16 | */ 17 | -------------------------------------------------------------------------------- /validation/linear/bitfield-preinc.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | int f:3; 3 | }; 4 | 5 | int preinc(void) 6 | { 7 | struct s s = { 7 }; 8 | return ++s.f; 9 | } 10 | 11 | /* 12 | * check-name: bitfield-preinc 13 | * check-description: ++X is equivalent to X+=1 14 | * check-command: test-linearize -Wno-decl $file 15 | * 16 | * check-output-ignore 17 | * check-output-contains: ret.32 *\\$0 18 | */ 19 | -------------------------------------------------------------------------------- /validation/linear/bitfield-sign-default.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | int f:2; 3 | }; 4 | 5 | static int getf(struct s s) { return s.f; } 6 | 7 | /* 8 | * check-name: bitfield-sign-default 9 | * check-command: test-linearize -fdump-ir=linearize $file 10 | * 11 | * check-output-ignore 12 | * check-output-contains: sext\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/linear/bitfield-sign-signed.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | int f:2; 3 | }; 4 | 5 | static int getf(struct s s) { return s.f; } 6 | 7 | /* 8 | * check-name: bitfield-sign-signed 9 | * check-command: test-linearize -fdump-ir=linearize -fsigned-bitfields $file 10 | * 11 | * check-output-ignore 12 | * check-output-contains: sext\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/linear/bitfield-sign-unsigned.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | int f:2; 3 | }; 4 | 5 | static int getf(struct s s) { return s.f; } 6 | 7 | /* 8 | * check-name: bitfield-sign-unsigned 9 | * check-command: test-linearize -fdump-ir=linearize -funsigned-bitfields $file 10 | * 11 | * check-output-ignore 12 | * check-output-contains: zext\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/linear/builtin-fma.c: -------------------------------------------------------------------------------- 1 | double fma(double a, double x, double y) 2 | { 3 | return __builtin_fma(a, x, y); 4 | } 5 | 6 | /* 7 | * check-name: builtin-fma 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-start 11 | fma: 12 | .L0: 13 | 14 | fmadd.64 %r4 <- %arg1, %arg2, %arg3 15 | ret.64 %r4 16 | 17 | 18 | * check-output-end 19 | */ 20 | -------------------------------------------------------------------------------- /validation/linear/builtin_isdigit.c: -------------------------------------------------------------------------------- 1 | _Bool isdigit(int c) 2 | { 3 | return __builtin_isdigit(c) == (((unsigned) (c - '0')) <= 9); 4 | } 5 | 6 | /* 7 | * check-name: builtin_isdigit 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-returns: 1 12 | */ 13 | -------------------------------------------------------------------------------- /validation/linear/cast-volatile.c: -------------------------------------------------------------------------------- 1 | static int foo(volatile int *a, int v) 2 | { 3 | *a = v; 4 | return *a; 5 | } 6 | 7 | /* 8 | * check-name: cast-volatile 9 | * check-command: test-linearize -fdump-ir=linearize $file 10 | * 11 | * check-output-ignore 12 | * check-output-excludes: sext\\. 13 | * check-output-excludes: zext\\. 14 | * check-output-excludes: trunc\\. 15 | */ 16 | -------------------------------------------------------------------------------- /validation/linear/compound-literal00.c: -------------------------------------------------------------------------------- 1 | struct bfs { 2 | int a: 2; 3 | int b: 30; 4 | }; 5 | 6 | int foo(void) 7 | { 8 | return (struct bfs){ .a = 1, .b = 2}.b; 9 | } 10 | 11 | /* 12 | * check-name: compound-literal00.c 13 | * check-command: test-linearize -Wno-decl $file 14 | * 15 | * check-output-ignore 16 | * check-output-contains: ret\\..*\\$2 17 | * check-error-end 18 | */ 19 | -------------------------------------------------------------------------------- /validation/linear/compound-literal01.c: -------------------------------------------------------------------------------- 1 | struct bfs { 2 | int a: 2; 3 | int b: 30; 4 | }; 5 | 6 | int foo(void) 7 | { 8 | struct bfs bf = { .a = 1, .b = 2 }; 9 | return (struct bfs[]){bf}[0].b; 10 | } 11 | 12 | /* 13 | * check-name: compound-literal01.c 14 | * check-command: test-linearize -Wno-decl $file 15 | * 16 | * check-output-ignore 17 | * check-output-contains: ret\\..*\\$2 18 | */ 19 | -------------------------------------------------------------------------------- /validation/linear/fp-vs-ptrcast.c: -------------------------------------------------------------------------------- 1 | float *f01(void* p) 2 | { 3 | return p; 4 | } 5 | 6 | /* 7 | * check-name: fp-vs-ptrcast 8 | * check-command: test-linearize -Wno-decl $file 9 | * check-output-ignore 10 | * 11 | * check-output-excludes: fpcast 12 | * check-output-contains: ptrcast 13 | */ 14 | -------------------------------------------------------------------------------- /validation/linear/goto-invalid.c: -------------------------------------------------------------------------------- 1 | static void foo(void) 2 | { 3 | goto return; 4 | } 5 | 6 | void bar(void) 7 | { 8 | goto neverland; 9 | } 10 | 11 | /* 12 | * check-name: goto-invalid 13 | * check-command: test-linearize -Wno-decl $file 14 | * 15 | * check-error-ignore 16 | * check-output-ignore 17 | * check-output-excludes: END 18 | */ 19 | -------------------------------------------------------------------------------- /validation/linear/join-cond-discard.c: -------------------------------------------------------------------------------- 1 | void abort(void) __attribute__((noreturn)); 2 | 3 | int bar(int a) 4 | { 5 | return a ? (abort(), 0) : 0; 6 | } 7 | 8 | int qux(int a) 9 | { 10 | return a ? (abort(), 0) : (abort(), 1); 11 | } 12 | 13 | /* 14 | * check-name: join-cond-discard 15 | * check-command: test-linearize -Wno-decl $file 16 | * 17 | * check-output-ignore 18 | * check-output-excludes: phisrc\\..*phi 19 | */ 20 | -------------------------------------------------------------------------------- /validation/linear/label-scope-cgoto.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* 4 | * check-name: linear/label-scope-cgoto 5 | * check-command: test-linearize -Wno-decl -I. $file 6 | * 7 | * check-error-ignore 8 | * check-output-ignore 9 | * check-output-excludes: END 10 | */ 11 | -------------------------------------------------------------------------------- /validation/linear/label-stmt-expr0.c: -------------------------------------------------------------------------------- 1 | int foo(void); 2 | int foo(void) 3 | { 4 | int r; 5 | 6 | r = ({ goto label; label: 1; }); 7 | return r; 8 | } 9 | 10 | /* 11 | * check-name: label-stmt-expr0 12 | * check-command: test-linearize $file 13 | * check-output-ignore 14 | * 15 | * check-output-excludes: ret\\.32\$ 16 | * check-output-contains: ret\\.32 *\\$1 17 | */ 18 | -------------------------------------------------------------------------------- /validation/linear/label-unreachable.c: -------------------------------------------------------------------------------- 1 | static int foo(int a) 2 | { 3 | goto label; 4 | switch(a) { 5 | default: 6 | label: 7 | break; 8 | } 9 | return 0; 10 | } 11 | 12 | /* 13 | * check-name: label-unreachable 14 | * check-command: test-linearize $file 15 | * 16 | * check-error-ignore 17 | * check-output-ignore 18 | * check-output-contains: ret\\. 19 | * check-output-excludes: END 20 | */ 21 | -------------------------------------------------------------------------------- /validation/linear/missing-return0.c: -------------------------------------------------------------------------------- 1 | static int foo(int a) 2 | { 3 | if (a) 4 | return 1; 5 | } 6 | 7 | /* 8 | * check-name: missing-return0 9 | * check-command: sparse -vir -flinearize=last $file 10 | */ 11 | -------------------------------------------------------------------------------- /validation/linear/missing-return1.c: -------------------------------------------------------------------------------- 1 | static inline int fun(int a) 2 | { 3 | if (a) 4 | return 1; 5 | } 6 | 7 | static int foo(int a) 8 | { 9 | return fun(a); 10 | } 11 | 12 | /* 13 | * check-name: missing-return1 14 | * check-command: sparse -vir -flinearize=last $file 15 | */ 16 | -------------------------------------------------------------------------------- /validation/linear/missing-return2.c: -------------------------------------------------------------------------------- 1 | static int foo(int a) 2 | { 3 | switch (a) 4 | case 3: 5 | return 4; 6 | } 7 | 8 | /* 9 | * check-name: missing-return2 10 | * check-command: sparse -vir -flinearize=last $file 11 | */ 12 | -------------------------------------------------------------------------------- /validation/linear/missing-return3.c: -------------------------------------------------------------------------------- 1 | static int foo(int a) 2 | { 3 | if (a) 4 | return; 5 | } 6 | 7 | static void ref(void) 8 | { 9 | } 10 | 11 | /* 12 | * check-name: missing-return3 13 | * check-command: sparse -vir -flinearize=last $file 14 | * 15 | * check-error-start 16 | linear/missing-return3.c:4:17: error: return with no return value 17 | * check-error-end 18 | */ 19 | -------------------------------------------------------------------------------- /validation/linear/missing-return4.c: -------------------------------------------------------------------------------- 1 | static int foo(int a) 2 | { 3 | int r = a; 4 | r; 5 | } 6 | 7 | /* 8 | * check-name: missing-return4 9 | * check-command: test-linearize -Wno-decl $file 10 | * 11 | * check-error-ignore 12 | * check-output-ignore 13 | * check-output-contains: ret\\..*UNDEF 14 | */ 15 | -------------------------------------------------------------------------------- /validation/linear/noreturn-unreachable0.c: -------------------------------------------------------------------------------- 1 | extern void die(void) __attribute__((noreturn)); 2 | 3 | int foo(void) 4 | { 5 | die(); 6 | return 0; 7 | } 8 | 9 | /* 10 | * check-name: noreturn-unreachable0 11 | * check-command: test-linearize -Wno-decl $file 12 | * 13 | * check-output-start 14 | foo: 15 | .L0: 16 | 17 | call die 18 | unreachable 19 | 20 | 21 | * check-output-end 22 | */ 23 | -------------------------------------------------------------------------------- /validation/linear/phi-order01.c: -------------------------------------------------------------------------------- 1 | int fun(void); 2 | 3 | static int foo(int a) 4 | { 5 | return a && fun(); 6 | } 7 | 8 | static int bar(int a) 9 | { 10 | return a || fun(); 11 | } 12 | 13 | /* 14 | * check-name: phi-order01 15 | * check-command: sparse -vir -flinearize=last $file 16 | */ 17 | -------------------------------------------------------------------------------- /validation/linear/phi-order03.c: -------------------------------------------------------------------------------- 1 | int fun(void); 2 | 3 | static int foo(void) { return ((0 || fun()) && fun()); } 4 | 5 | /* 6 | * check-name: phi-order03 7 | * check-command: sparse -vir -flinearize=last $file 8 | */ 9 | -------------------------------------------------------------------------------- /validation/linear/phi-order04.c: -------------------------------------------------------------------------------- 1 | static void foo(int *b) 2 | { 3 | if (1) { 4 | int c; 5 | b = &c; 6 | } 7 | } 8 | 9 | /* 10 | * check-name: phi-order04 11 | * check-command: sparse -vir -flinearize=last $file 12 | */ 13 | -------------------------------------------------------------------------------- /validation/local-label.c: -------------------------------------------------------------------------------- 1 | void f(unsigned long ip); 2 | static void g(void) 3 | { 4 | if (1) { 5 | f(({ __label__ x; x: (unsigned long)&&x; })); 6 | } 7 | f(({ __label__ x; x: (unsigned long)&&x; })); 8 | } 9 | /* 10 | * check-name: Local label 11 | */ 12 | -------------------------------------------------------------------------------- /validation/logical.c: -------------------------------------------------------------------------------- 1 | extern int a(void); 2 | extern int b(void); 3 | extern int c(void); 4 | 5 | static int or(void) 6 | { 7 | return a() || b() || c(); 8 | } 9 | 10 | static int and(void) 11 | { 12 | return a() && b() && c(); 13 | } 14 | /* 15 | * check-name: Logical and/or 16 | */ 17 | 18 | -------------------------------------------------------------------------------- /validation/mem2reg/address-used00.c: -------------------------------------------------------------------------------- 1 | int foo(int **g, int j) 2 | { 3 | int i = 1; 4 | int *a; 5 | int **p; 6 | 7 | a = &i; 8 | p = &a; 9 | *p[0] = 0; 10 | return i; 11 | } 12 | 13 | /* 14 | * check-name: address-used00 15 | * check-command: test-linearize -Wno-decl -fdump-ir=final $file 16 | * check-output-ignore 17 | * check-output-excludes: ret\\..* \\$1 18 | */ 19 | -------------------------------------------------------------------------------- /validation/mem2reg/alias-distinct.c: -------------------------------------------------------------------------------- 1 | extern int g; 2 | extern int h; 3 | 4 | static int foo(void) 5 | { 6 | g = 1; 7 | h = 2; 8 | return g == 1; 9 | } 10 | 11 | /* 12 | * check-name: alias distinct symbols 13 | * check-command: test-linearize $file 14 | * check-output-ignore 15 | * 16 | * check-output-contains: ret\\..* *\\$1 17 | */ 18 | -------------------------------------------------------------------------------- /validation/mem2reg/alias-same.c: -------------------------------------------------------------------------------- 1 | extern int g; 2 | 3 | 4 | static int foo(void) 5 | { 6 | g = 1; 7 | g = 2; 8 | return g != 1; 9 | } 10 | 11 | /* 12 | * check-name: alias same symbols 13 | * check-command: test-linearize $file 14 | * check-output-ignore 15 | * 16 | * check-output-contains: ret\\..* *\\$1 17 | */ 18 | -------------------------------------------------------------------------------- /validation/mem2reg/asm-reload0.c: -------------------------------------------------------------------------------- 1 | static int asm_reload(void) 2 | { 3 | int mem = 0; 4 | asm volatile ("[%1] <= 1" : "=m" (mem)); 5 | return mem; 6 | } 7 | 8 | /* 9 | * check-name: asm-reload0 10 | * check-command: test-linearize $file 11 | * 12 | * check-output-ignore 13 | * check-output-contains: load\\. 14 | */ 15 | -------------------------------------------------------------------------------- /validation/mem2reg/cond-expr.c: -------------------------------------------------------------------------------- 1 | int fun(int); 2 | 3 | int foo(int a, int b, int c) 4 | { 5 | return a ? fun(b) : fun(c); 6 | } 7 | 8 | /* 9 | * check-name: cond-expr 10 | * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file 11 | * check-output-ignore 12 | * check-output-pattern(1): phi\\. 13 | * check-output-pattern(2): phisrc\\. 14 | */ 15 | -------------------------------------------------------------------------------- /validation/mem2reg/dead-phisrc.c: -------------------------------------------------------------------------------- 1 | static void foo(void) 2 | { 3 | extern int *a; 4 | 5 | if (a || *a) 6 | ; 7 | if (a[0] || a[1]) 8 | ; 9 | } 10 | 11 | /* 12 | * check-name: dead-phisrc 13 | * check-command: test-linearize $file 14 | * 15 | * check-output-ignore 16 | * check-output-excludes: phisrc 17 | */ 18 | -------------------------------------------------------------------------------- /validation/mem2reg/global-loop.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | int c; 3 | int a[]; 4 | } s; 5 | int f; 6 | 7 | void fun(void); 8 | void foo(void) 9 | { 10 | for (f = 1;;) 11 | if (s.a[f]) 12 | fun(); 13 | } 14 | 15 | /* 16 | * check-name: global var as loop index 17 | * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file 18 | * check-output-ignore 19 | * check-output-contains: load\\..*\\[f\\] 20 | */ 21 | -------------------------------------------------------------------------------- /validation/mem2reg/if-direct.c: -------------------------------------------------------------------------------- 1 | int foo(int c, int a, int b) 2 | { 3 | int l; 4 | 5 | if (c) 6 | l = a; 7 | else 8 | l = b; 9 | 10 | return l; 11 | } 12 | 13 | /* 14 | * check-name: if-then-else direct 15 | * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file 16 | * check-output-ignore 17 | * check-output-excludes: load\\. 18 | * check-output-contains: phi\\. 19 | */ 20 | -------------------------------------------------------------------------------- /validation/mem2reg/init-local-union0.c: -------------------------------------------------------------------------------- 1 | double uintfloat(void) 2 | { 3 | union { 4 | int a; 5 | double f; 6 | } s; 7 | 8 | s.a = 1; 9 | return s.f; 10 | } 11 | 12 | /* 13 | * check-name: init-local union 0 14 | * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file 15 | * check-output-ignore 16 | * check-output-pattern(1): store\\.32 17 | * check-output-pattern(1): load\\.64 18 | */ 19 | -------------------------------------------------------------------------------- /validation/mem2reg/load-dead.c: -------------------------------------------------------------------------------- 1 | int fun(int); 2 | 3 | static inline int fake(void) 4 | { 5 | } 6 | 7 | static void foo(int a) 8 | { 9 | 0 || fun((a, fake(), a)); 10 | } 11 | 12 | /* 13 | * check-name: load-dead 14 | * check-command: test-linearize -Wno-decl $file 15 | * 16 | * check-output-ignore 17 | * check-output-excludes: VOID 18 | */ 19 | -------------------------------------------------------------------------------- /validation/mem2reg/load-deadborn.c: -------------------------------------------------------------------------------- 1 | static void foo(int a) 2 | { 3 | return; 4 | a; 5 | } 6 | 7 | /* 8 | * check-name: load-deadborn 9 | */ 10 | -------------------------------------------------------------------------------- /validation/mem2reg/loop00.c: -------------------------------------------------------------------------------- 1 | int loop00(int n) 2 | { 3 | int i, r = 0; 4 | 5 | for (i = 1; i <= n; ++i) 6 | r += i; 7 | return r; 8 | } 9 | 10 | /* 11 | * check-name: loop00 12 | * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file 13 | * check-output-ignore 14 | * check-output-excludes: store\\. 15 | * check-output-excludes: load\\. 16 | */ 17 | -------------------------------------------------------------------------------- /validation/mem2reg/loop01-global.c: -------------------------------------------------------------------------------- 1 | extern int g; 2 | 3 | void fun(void); 4 | void loop01(void) 5 | { 6 | int i; 7 | for (i = 0; i <= 2;) 8 | if (g) 9 | fun(); 10 | } 11 | 12 | /* 13 | * check-name: loop01 global 14 | * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file 15 | * check-output-ignore 16 | * check-output-excludes: load\\..*\\[i\\] 17 | * check-output-contains: load\\..*\\[g\\] 18 | */ 19 | -------------------------------------------------------------------------------- /validation/mem2reg/loop02-global.c: -------------------------------------------------------------------------------- 1 | int i; 2 | 3 | int foo(void) 4 | { 5 | int j = 1; 6 | i = 6; 7 | 8 | do { 9 | if (i != 6) 10 | i++; 11 | i++; 12 | } while (i != j); 13 | 14 | return j; 15 | } 16 | 17 | /* 18 | * check-name: loop02 global 19 | * check-command: test-linearize -Wno-decl $file 20 | * check-output-ignore 21 | * check-output-excludes: load\\. 22 | */ 23 | -------------------------------------------------------------------------------- /validation/mem2reg/loop02-local.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int foo(void) 4 | { 5 | int j = 1; 6 | int i = 6; 7 | 8 | do { 9 | if (i != 6) 10 | i++; 11 | i++; 12 | } while (i != j); 13 | 14 | return j; 15 | } 16 | 17 | /* 18 | * check-name: loop02 pointer 19 | * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file 20 | * 21 | * check-output-ignore 22 | * check-output-excludes: load\\. 23 | */ 24 | -------------------------------------------------------------------------------- /validation/mem2reg/quadra02.c: -------------------------------------------------------------------------------- 1 | #include "repeat.h" 2 | 3 | #define PAT(X) int a##X = X; 4 | static void foo(void) 5 | { 6 | REPEAT2(12, PAT) 7 | } 8 | 9 | /* 10 | * check-name: quadratic vars 11 | * check-command: test-linearize -I. $file 12 | * check-timeout: 13 | * 14 | * check-output-ignore 15 | * check-output-excludes: phi\\. 16 | * check-output-excludes: phisrc\\. 17 | * check-output-excludes: store\\. 18 | */ 19 | -------------------------------------------------------------------------------- /validation/mem2reg/store-deadborn.c: -------------------------------------------------------------------------------- 1 | static void foo(int a) 2 | { 3 | return; 4 | a = 0; 5 | } 6 | 7 | /* 8 | * check-name: store-deadborn 9 | */ 10 | -------------------------------------------------------------------------------- /validation/mem2reg/undef01.c: -------------------------------------------------------------------------------- 1 | static void foo(void) 2 | { 3 | int *b; 4 | for (;;) 5 | *b++ = 0; 6 | } 7 | 8 | /* 9 | * check-name: undef01 10 | * check-command: sparse -Wmaybe-uninitialized $file 11 | * check-known-to-fail 12 | * 13 | * check-error-start 14 | crazy04.c:3:13: warning: variable 'b' may be uninitialized 15 | * check-error-end 16 | */ 17 | -------------------------------------------------------------------------------- /validation/mem2reg/unused-var.c: -------------------------------------------------------------------------------- 1 | int foo(int a) 2 | { 3 | switch (a) { 4 | int u = 1; 5 | 6 | default: 7 | return a; 8 | } 9 | } 10 | 11 | /* 12 | * check-name: unused-var 13 | * check-command: test-linearize -Wno-decl $file 14 | * 15 | * check-output-start 16 | foo: 17 | .L0: 18 | 19 | ret.32 %arg1 20 | 21 | 22 | * check-output-end 23 | */ 24 | -------------------------------------------------------------------------------- /validation/member_of_typeof.c: -------------------------------------------------------------------------------- 1 | static struct foo {int x;} v; 2 | static typeof(v) *p; 3 | static void bar(void) 4 | { 5 | p->x = 0; 6 | } 7 | /* 8 | * check-name: Expansion of typeof when dealing with member of struct 9 | * check-description: Used to expand SYM_TYPEOF too late 10 | */ 11 | -------------------------------------------------------------------------------- /validation/memops/kill-dead-loads00.c: -------------------------------------------------------------------------------- 1 | void fun(void); 2 | 3 | void foo(int *p) 4 | { 5 | for (*p; *p; *p) { 6 | l: 7 | fun(); 8 | } 9 | 10 | if (0) 11 | goto l; 12 | } 13 | 14 | /* 15 | * check-name: kill-dead-loads00 16 | * check-command: test-linearize -Wno-decl $file 17 | * 18 | * check-output-ignore 19 | * check-output-excludes: phi\\. 20 | * check-output-pattern(1): load\\. 21 | * check-output-end 22 | */ 23 | -------------------------------------------------------------------------------- /validation/memops/kill-dead-store-parent0.c: -------------------------------------------------------------------------------- 1 | void foo(int *ptr, int p) 2 | { 3 | if (p) 4 | *ptr = 1; 5 | *ptr = 0; 6 | } 7 | 8 | /* 9 | * check-name: kill-dead-store-parent0 10 | * check-command: test-linearize -Wno-decl $file 11 | * 12 | * check-output-ignore 13 | * check-output-pattern(1): store 14 | */ 15 | -------------------------------------------------------------------------------- /validation/memops/kill-redundant-store0.c: -------------------------------------------------------------------------------- 1 | void foo(int *ptr) 2 | { 3 | int i = *ptr; 4 | *ptr = i; 5 | } 6 | 7 | /* 8 | * check-name: kill-redundant-store0 9 | * check-command: test-linearize -Wno-decl $file 10 | * 11 | * check-output-ignore 12 | * check-output-excludes: store 13 | */ 14 | -------------------------------------------------------------------------------- /validation/multi-input.c: -------------------------------------------------------------------------------- 1 | int a = 1; 2 | int foo(void) {} 3 | 4 | static int b = 1; 5 | static int bar(void) {} 6 | 7 | /* 8 | * check-name: multi-input 9 | * check-command: sparse -Wno-decl $file $file 10 | * check-known-to-fail 11 | */ 12 | -------------------------------------------------------------------------------- /validation/multi_typedef.c: -------------------------------------------------------------------------------- 1 | typedef int T, *P; 2 | static void f(void) 3 | { 4 | unsigned P = 0; 5 | unsigned x = P; 6 | } 7 | static void g(void) 8 | { 9 | int P = 0; 10 | int x = P; 11 | } 12 | /* 13 | * check-name: typedefs with many declarators 14 | * check-description: we didn't recognize P above as a typedef 15 | */ 16 | -------------------------------------------------------------------------------- /validation/non-pointer-null.c: -------------------------------------------------------------------------------- 1 | static void *p = 0; 2 | /* 3 | * check-name: Using plain integer as NULL pointer 4 | * 5 | * check-error-start 6 | non-pointer-null.c:1:18: warning: Using plain integer as NULL pointer 7 | * check-error-end 8 | */ 9 | -------------------------------------------------------------------------------- /validation/old-initializer-nowarn.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | int i; 3 | }; 4 | 5 | static struct s the_s = { i: 1 }; 6 | /* 7 | * check-name: Old initializer with -Wno-old-initializer 8 | * check-command: sparse -Wno-old-initializer 9 | */ 10 | -------------------------------------------------------------------------------- /validation/old-initializer.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | int i; 3 | }; 4 | 5 | static struct s the_s = { i: 1 }; 6 | /* 7 | * check-name: Old initializer 8 | * 9 | * check-error-start 10 | old-initializer.c:5:27: warning: obsolete struct initializer, use C99 syntax 11 | * check-error-end 12 | */ 13 | -------------------------------------------------------------------------------- /validation/old-style-definition0.c: -------------------------------------------------------------------------------- 1 | extern int foo(int a, void *b); 2 | 3 | int foo(a, b) 4 | int a; 5 | void *b; 6 | { 7 | if (b) 8 | return a; 9 | } 10 | 11 | /* 12 | * check-name: old-stype-definition disabled 13 | * check-command: sparse -Wno-old-style-definition $file 14 | */ 15 | -------------------------------------------------------------------------------- /validation/old-style-definition1.c: -------------------------------------------------------------------------------- 1 | extern int foo(int a, void *b); 2 | 3 | int foo(a, b) 4 | int a; 5 | void *b; 6 | { 7 | if (b) 8 | return a; 9 | } 10 | 11 | /* 12 | * check-name: old-stype-definition enabled 13 | * check-command: sparse -Wold-style-definition $file 14 | * 15 | * check-error-start 16 | old-style-definition1.c:4:9: warning: non-ANSI definition of function 'foo' 17 | * check-error-end 18 | */ 19 | -------------------------------------------------------------------------------- /validation/optim/address-used01.c: -------------------------------------------------------------------------------- 1 | int foo(int **g, int j) 2 | { 3 | int i = 1; 4 | int *a; 5 | int **p; 6 | 7 | a = &i; 8 | p = &a; 9 | *p[0] = 0; 10 | return i; 11 | } 12 | 13 | /* 14 | * check-name: address-used01 15 | * check-command: test-linearize -Wno-decl -fdump-ir=final $file 16 | * check-output-ignore 17 | * check-output-contains: ret\\..* \\$0 18 | */ 19 | -------------------------------------------------------------------------------- /validation/optim/and-lsr.c: -------------------------------------------------------------------------------- 1 | // (x & M) >> S to (x >> S) & (M >> S) 2 | 3 | unsigned int foo(unsigned int x) 4 | { 5 | return (x & 0xffff) >> 12; 6 | } 7 | 8 | /* 9 | * check-name: and-lsr 10 | * check-command: test-linearize -Wno-decl $file 11 | * 12 | * check-output-ignore 13 | * check-output-contains: and\\..*\\$15 14 | * check-output-excludes: and\\..*\\$0xffff 15 | */ 16 | -------------------------------------------------------------------------------- /validation/optim/and-or-bf1.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | int :2; 3 | int f:3; 4 | }; 5 | 6 | void foo(struct s *d, const struct s *s, int a) 7 | { 8 | d->f = s->f | a; 9 | } 10 | 11 | /* 12 | * check-name: and-or-bf1 13 | * check-command: test-linearize -Wno-decl $file 14 | * 15 | * check-output-ignore 16 | * check-output-pattern(2): and\\. 17 | * check-output-pattern(2): or\\. 18 | */ 19 | -------------------------------------------------------------------------------- /validation/optim/and-or-bfx.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | int f:3; 3 | }; 4 | 5 | void foo(struct s *p, int a, int b) 6 | { 7 | p->f = a; 8 | p->f = b; 9 | } 10 | 11 | /* 12 | * check-name: and-or-bfx 13 | * check-command: test-linearize -Wno-decl $file 14 | * 15 | * check-output-ignore 16 | * check-output-pattern(2): and\\. 17 | * check-output-pattern(1): or\\. 18 | */ 19 | -------------------------------------------------------------------------------- /validation/optim/and-or-constant0.c: -------------------------------------------------------------------------------- 1 | int foo(int x) 2 | { 3 | return (x | 0xfffff000) & 0xfff; 4 | } 5 | 6 | /* 7 | * check-name: and-or-constant0 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-excludes: or\\. 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/and-or-constant1.c: -------------------------------------------------------------------------------- 1 | int foo(int x) 2 | { 3 | return (x | 0x000fffff) & 0xfff; 4 | } 5 | 6 | /* 7 | * check-name: or-and-constant1 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-contains: ret\\..*\\$0xfff 12 | * check-output-excludes: and\\. 13 | * check-output-excludes: or\\. 14 | */ 15 | -------------------------------------------------------------------------------- /validation/optim/and-or-constant2.c: -------------------------------------------------------------------------------- 1 | int foo(int x) 2 | { 3 | return (x | 0xfffffff0) & 0xfff; 4 | } 5 | 6 | /* 7 | * check-name: and-or-constant2 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-contains: or\\..*\\$0xff0 12 | * check-output-excludes: or\\..*\\$0xfffffff0 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/and-or-crash.c: -------------------------------------------------------------------------------- 1 | static unsigned a(unsigned b, unsigned c) { (c << 1 | b & 1 << 1) >> 1; } 2 | 3 | /* 4 | * check-name: catch crashes during AND-OR simplifications 5 | */ 6 | -------------------------------------------------------------------------------- /validation/optim/and-or-lsr0.c: -------------------------------------------------------------------------------- 1 | int foo(int a, int b) 2 | { 3 | return ((a & 0x00000fff) | b) >> 12; 4 | } 5 | 6 | /* 7 | * check-name: and-or-lsr0 8 | * check-command: test-linearize -Wno-decl $file 9 | * check-known-to-fail 10 | * 11 | * check-output-ignore 12 | * check-output-excludes: or\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/and-or-lsr1.c: -------------------------------------------------------------------------------- 1 | int foo(int a, int b) 2 | { 3 | return ((a & 0xfffff000) | b) >> 12; 4 | } 5 | 6 | /* 7 | * check-name: and-or-lsr1 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-pattern(0): and\\. 12 | * check-output-pattern(1): or\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/and-or-lsr2.c: -------------------------------------------------------------------------------- 1 | int foo(int x, int y) 2 | { 3 | return ((x & 0xf0ffffff) | y) >> 12; 4 | } 5 | 6 | /* 7 | * check-name: and-or-lsr2 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-contains: and\\..*\\$0xf0fff 12 | * check-output-excludes: and\\..*\\$0xf0ffffff 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/and-or-lsrx.c: -------------------------------------------------------------------------------- 1 | unsigned int foo(unsigned int x, unsigned int y, unsigned int a) 2 | { 3 | return ((x & y) | (a & 0x0fff)) >> 12; 4 | } 5 | 6 | /* 7 | * check-name: and-or-lsrx 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-pattern(1): and\\. 12 | * check-output-excludes: or\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/and-or-mask.c: -------------------------------------------------------------------------------- 1 | int foo(int a, int b) 2 | { 3 | return ((a & 7) | (b & 3)) & 8; 4 | } 5 | 6 | /* 7 | * check-name: and-or-mask 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-start 11 | foo: 12 | .L0: 13 | 14 | ret.32 $0 15 | 16 | 17 | * check-output-end 18 | */ 19 | -------------------------------------------------------------------------------- /validation/optim/and-or-mask0.c: -------------------------------------------------------------------------------- 1 | int foo(int a, int b) 2 | { 3 | return ((a & 0xfffff000) | b) & 0xfff; 4 | } 5 | 6 | /* 7 | * check-name: and-or-mask0 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-excludes: or\\. 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/and-or-mask1.c: -------------------------------------------------------------------------------- 1 | int foo(int a, int b) 2 | { 3 | return ((a & 0x0fffffff) | b) & 0xfff; 4 | } 5 | 6 | /* 7 | * check-name: and-or-mask1 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-pattern(1): and\\. 12 | * check-output-pattern(1): or\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/and-or-mask2.c: -------------------------------------------------------------------------------- 1 | int foo(int x, int y) 2 | { 3 | return ((x & 0xffffff0f) | y) & 0xfff; 4 | } 5 | 6 | /* 7 | * check-name: and-or-mask2 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-contains: and\\..*\\$0xf0f 12 | * check-output-excludes: and\\..*\\$0xffffff0f 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/and-or-maskx.c: -------------------------------------------------------------------------------- 1 | int foo(int x, int y, int a) 2 | { 3 | return ((x & y) | (a & 0xf000)) & 0x0fff; 4 | } 5 | 6 | /* 7 | * check-name: and-or-maskx 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-pattern(2): and\\. 12 | * check-output-excludes: or\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/and-or-shl0.c: -------------------------------------------------------------------------------- 1 | int foo(int a, int b) 2 | { 3 | return ((a & 0xfff00000) | b) << 12; 4 | } 5 | 6 | /* 7 | * check-name: and-or-shl0 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-excludes: or\\. 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/and-or-shl1.c: -------------------------------------------------------------------------------- 1 | int foo(int a, int b) 2 | { 3 | return ((a & 0x000fffff) | b) << 12; 4 | } 5 | 6 | /* 7 | * check-name: and-or-shl1 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-pattern(0): and\\. 12 | * check-output-pattern(1): or\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/and-or-shl2.c: -------------------------------------------------------------------------------- 1 | int foo(int x, int y) 2 | { 3 | return ((x & 0xffffff0f) | y) << 12; 4 | } 5 | 6 | /* 7 | * check-name: and-or-shl2 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-contains: and\\..*\\$0xfff0f 12 | * check-output-excludes: and\\..*\\$0xffffff0f 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/and-or-shlx.c: -------------------------------------------------------------------------------- 1 | unsigned int foo(unsigned int x, unsigned int y, unsigned int a) 2 | { 3 | return ((x & y) | (a & 0xfff00000)) << 12; 4 | } 5 | 6 | /* 7 | * check-name: and-or-shlx 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-pattern(1): and\\. 12 | * check-output-excludes: or\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/and-or-trunc0.c: -------------------------------------------------------------------------------- 1 | char foo(int x, int y) 2 | { 3 | return (x & 0xff00) | y; 4 | } 5 | 6 | /* 7 | * check-name: and-or-trunc0 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-excludes: and\\. 12 | * check-output-excludes: or\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/and-or-trunc1.c: -------------------------------------------------------------------------------- 1 | char foo(int x, int y) 2 | { 3 | return (x & 0xffff) | y; 4 | } 5 | 6 | /* 7 | * check-name: and-or-trunc1 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-excludes: and\\. 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/and-or-trunc2.c: -------------------------------------------------------------------------------- 1 | char foo(int x, int y) 2 | { 3 | return (x & 0xff07) | y; 4 | } 5 | 6 | /* 7 | * check-name: and-or-trunc2 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-pattern(1): and\\. 12 | * check-output-pattern(1): and\\..*\\$7 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/and-or-truncx.c: -------------------------------------------------------------------------------- 1 | char foo(int x, int y, int b) 2 | { 3 | return (x & y) | (b & 0xff00); 4 | } 5 | 6 | /* 7 | * check-name: and-or-truncx 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-pattern(1): and\\. 12 | * check-output-excludes: or\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/bad-phisrc1.c: -------------------------------------------------------------------------------- 1 | void foo(int a, int b) 2 | { 3 | if (b) 4 | while ((a += 5) > a) 5 | ; 6 | } 7 | 8 | /* 9 | * check-name: bad-phisrc1 10 | * check-command: test-linearize -Wno-decl $file 11 | * 12 | * check-output-ignore 13 | * check-output-excludes: phi\\. 14 | * check-output-excludes: phisource\\. 15 | */ 16 | -------------------------------------------------------------------------------- /validation/optim/bad-phisrc2.c: -------------------------------------------------------------------------------- 1 | int bad_phisrc2(int p, int a, int r) 2 | { 3 | if (p) 4 | r = a; 5 | else if (r) 6 | ; 7 | return r; 8 | } 9 | 10 | /* 11 | * check-name: bad-phisrc2 12 | * check-command: test-linearize -Wno-decl $file 13 | * 14 | * check-output-ignore 15 | * check-output-contains: select\\. 16 | */ 17 | -------------------------------------------------------------------------------- /validation/optim/bad-phisrc3.c: -------------------------------------------------------------------------------- 1 | void foo(void) 2 | { 3 | int c = 1; 4 | switch (3) { 5 | case 0: 6 | do { 7 | ; 8 | case 3: ; 9 | } while (c++); 10 | } 11 | } 12 | 13 | /* 14 | * check-name: bad-phisrc3 15 | * check-command: test-linearize -Wno-decl $file 16 | * 17 | * check-output-ignore 18 | * check-output-pattern(2): phisrc\\. 19 | * check-output-pattern(1): phi\\. 20 | */ 21 | -------------------------------------------------------------------------------- /validation/optim/bool-context.c: -------------------------------------------------------------------------------- 1 | #define bool _Bool 2 | 3 | bool bool_ior(int a, int b) { return a || b; } 4 | bool bool_and(int a, int b) { return a && b; } 5 | 6 | /* 7 | * check-name: bool-context 8 | * check-command: test-linearize -Wno-decl $file 9 | * check-output-ignore 10 | * 11 | * check-output-pattern(4): setne\\..* %arg[12] 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/bool-eq0.c: -------------------------------------------------------------------------------- 1 | int beq0(int a) { return a == 0; } 2 | int bnotne0(int a) { return !(a != 0); } 3 | int bnot(int a) { return !a; } 4 | 5 | /* 6 | * check-name: bool-eq0 7 | * check-command: test-linearize -Wno-decl $file 8 | * check-output-ignore 9 | * 10 | * check-output-excludes: setne\\. 11 | * check-output-contains: seteq\\. 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/bool-int-bool.c: -------------------------------------------------------------------------------- 1 | _Bool beq0(_Bool a) { return (a == 0); } 2 | _Bool beq1(_Bool a) { return (a == 1); } 3 | _Bool bne0(_Bool a) { return (a != 0); } 4 | _Bool bne1(_Bool a) { return (a != 1); } 5 | 6 | /* 7 | * check-name: bool - int - bool constants 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-excludes: cast\\. 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/bool-ne0.c: -------------------------------------------------------------------------------- 1 | int bne0(int a) { return a != 0; } 2 | int bnoteq0(int a) { return !(a == 0); } 3 | int bnotnot(int a) { return !(!a); } 4 | 5 | /* 6 | * check-name: bool-ne0 7 | * check-command: test-linearize -Wno-decl $file 8 | * check-output-ignore 9 | * 10 | * check-output-excludes: seteq\\. 11 | * check-output-contains: setne\\. 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/bool-neq0.c: -------------------------------------------------------------------------------- 1 | int bneq0(int a) { return a != 0; } 2 | int bnoteq0(int a) { return !(a == 0); } 3 | int bnotnot(int a) { return !(!a); } 4 | 5 | /* 6 | * check-name: bool-neq0 7 | * check-command: test-linearize -Wno-decl $file 8 | * check-output-ignore 9 | * 10 | * check-output-excludes: seteq\\. 11 | * check-output-contains: setne\\. 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/bool-same-args.c: -------------------------------------------------------------------------------- 1 | static int ior(int a) { return a || a; } 2 | static int and(int a) { return a && a; } 3 | 4 | /* 5 | * check-name: bool-same-args 6 | * check-command: test-linearize $file 7 | * check-output-ignore 8 | * 9 | * check-output-excludes: or-bool\\. 10 | * check-output-excludes: and-bool\\. 11 | * check-output-contains: setne\\. 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/bool-sext-test.c: -------------------------------------------------------------------------------- 1 | _Bool eqs0( signed char a) { return a == 0; } 2 | _Bool eqs1( signed char a) { return a == 1; } 3 | _Bool nes0( signed char a) { return a != 0; } 4 | _Bool nes1( signed char a) { return a != 1; } 5 | 6 | /* 7 | * check-name: bool-sext-test 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-excludes: sext\\. 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/bool-zext-test.c: -------------------------------------------------------------------------------- 1 | _Bool equ0(unsigned char a) { return a == 0; } 2 | _Bool equ1(unsigned char a) { return a == 1; } 3 | _Bool neu0(unsigned char a) { return a != 0; } 4 | _Bool neu1(unsigned char a) { return a != 1; } 5 | 6 | /* 7 | * check-name: bool-zext-test 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-excludes: zext\\. 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/call-complex-pointer.c: -------------------------------------------------------------------------------- 1 | int foo(int p, int (*f0)(int), int (*f1)(int), int arg) 2 | { 3 | return (p ? f0 : f1)(arg); 4 | } 5 | /* 6 | * check-name: call-complex-pointer 7 | * check-command: test-linearize -Wno-decl $file 8 | * check-known-to-fail 9 | * 10 | * check-output-ignore 11 | * check-output-excludes: ptrcast\\. 12 | * check-output-contains: select\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/canonical-abs.c: -------------------------------------------------------------------------------- 1 | _Bool abs0(int a) { return (a < 0 ? -a : a) == (a >= 0 ? a : -a); } 2 | _Bool abs1(int a) { return (a < 0 ? -a : a) == (a > 0 ? a : -a); } 3 | _Bool abs2(int a) { return (a < 0 ? -a : a) == (a <= 0 ? -a : a); } 4 | 5 | /* 6 | * check-name: canonical-abs1 7 | * check-command: test-linearize -Wno-decl $file 8 | * 9 | * check-output-ignore 10 | * check-output-returns: 1 11 | */ 12 | -------------------------------------------------------------------------------- /validation/optim/canonical-arg.c: -------------------------------------------------------------------------------- 1 | int def(void); 2 | 3 | int canon_arg_arg(int a, int b) 4 | { 5 | return (a + b) == (b + a); 6 | } 7 | 8 | int canon_arg_reg(int a) 9 | { 10 | int b = def(); 11 | return (a + b) == (b + a); 12 | } 13 | 14 | /* 15 | * check-name: canonical-arg 16 | * check-command: test-linearize -Wno-decl $file 17 | * 18 | * check-output-ignore 19 | * check-output-returns: 1 20 | */ 21 | -------------------------------------------------------------------------------- /validation/optim/canonical-not.c: -------------------------------------------------------------------------------- 1 | int canon_not(int a, int b) { return (a & ~b) == (~b & a); } 2 | 3 | /* 4 | * check-name: canonical-not 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-returns: 1 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/canonical-sub-cte.c: -------------------------------------------------------------------------------- 1 | int sub_cte(int x) { return (x - 1) != (x + -1); } 2 | 3 | /* 4 | * check-name: canonical-sub-cte 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-contains: ret\\..*\\$0 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/cast-nop.c: -------------------------------------------------------------------------------- 1 | static long p2l(long *p) 2 | { 3 | return (long) p; 4 | } 5 | 6 | static long *l2p(long l) 7 | { 8 | return (long*)l; 9 | } 10 | 11 | /* 12 | * check-name: cast-nop 13 | * check-command: test-linearize -Wno-decl $file 14 | * 15 | * check-output-ignore 16 | * check-output-excludes: utptr\\. 17 | * check-output-excludes: ptrtu\\. 18 | */ 19 | -------------------------------------------------------------------------------- /validation/optim/cgoto02.c: -------------------------------------------------------------------------------- 1 | int foo(int a) 2 | { 3 | void *label = a ? &&l1 : &&l2; 4 | goto *label; 5 | l1: 6 | return a; 7 | l2: 8 | return 0; 9 | } 10 | 11 | /* 12 | * check-name: cgoto02 13 | * check-command: test-linearize -Wno-decl $file 14 | * 15 | * check-output-ignore 16 | * check-output-returns: %arg1 17 | */ 18 | -------------------------------------------------------------------------------- /validation/optim/cmp-and-pow2.c: -------------------------------------------------------------------------------- 1 | #define M 32 2 | 3 | _Bool eq(int a) { return ((a & M) != M) == ((a & M) == 0); } 4 | _Bool ne(int a) { return ((a & M) == M) == ((a & M) != 0); } 5 | 6 | /* 7 | * check-name: cmp-and-pow2 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-returns: 1 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/cmp-op-type.c: -------------------------------------------------------------------------------- 1 | extern int get(void); 2 | 3 | static int array[8192]; 4 | 5 | static int foo(void) 6 | { 7 | int n = -1; 8 | if (n < 0) 9 | n = get(); 10 | return array[n]; 11 | } 12 | 13 | /* 14 | * check-name: cmp-op-type 15 | * check-command: test-linearize -Wno-decl $file 16 | * 17 | * check-output-ignore 18 | */ 19 | -------------------------------------------------------------------------------- /validation/optim/cmp-type0.c: -------------------------------------------------------------------------------- 1 | static int foo(long long a) 2 | { 3 | return 0LL < (0x80000000LL + (a - a)); 4 | } 5 | 6 | /* 7 | * check-name: cmp-type0 8 | * check-command: test-linearize $file 9 | * 10 | * check-output-ignore 11 | * check-output-returns: 1 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/cmp-type1.c: -------------------------------------------------------------------------------- 1 | int foo(void) 2 | { 3 | int r; 4 | long n; 5 | n = 0; 6 | return n < 2147483648U; 7 | } 8 | 9 | /* 10 | * check-name: cmp-type1 11 | * check-command: test-linearize -Wno-decl $file 12 | * 13 | * check-output-ignore 14 | * check-output-returns: 1 15 | */ 16 | -------------------------------------------------------------------------------- /validation/optim/cmpe-and0.c: -------------------------------------------------------------------------------- 1 | int cmpe_and_eq(int a) { return ((a & 0xff00) == 0xff01) + 1; } 2 | int cmpe_and_ne(int a) { return ((a & 0xff00) != 0xff01) + 0; } 3 | 4 | /* 5 | * check-name: cmpe-and0 6 | * check-command: test-linearize -Wno-decl $file 7 | * 8 | * check-output-ignore 9 | * check-output-returns: 1 10 | */ 11 | -------------------------------------------------------------------------------- /validation/optim/cmpe-or0.c: -------------------------------------------------------------------------------- 1 | int cmp_eq(int a) { return ((a | 1) != 0) + 0; } 2 | int cmp_ne(int a) { return ((a | 1) == 0) + 1; } 3 | 4 | /* 5 | * check-name: cmpe-or0 6 | * check-command: test-linearize -Wno-decl $file 7 | * 8 | * check-output-ignore 9 | * check-output-returns: 1 10 | */ 11 | -------------------------------------------------------------------------------- /validation/optim/cmps0-and0.c: -------------------------------------------------------------------------------- 1 | #define M 32 2 | 3 | int cmps_and_sle0(int a) { return ((a & M) <= 0) == ((a & M) == 0); } 4 | int cmps_and_sgt0(int a) { return ((a & M) > 0) == ((a & M) != 0); } 5 | 6 | /* 7 | * check-name: cmps0-and 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-returns: 1 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/cse-arg01.c: -------------------------------------------------------------------------------- 1 | int foo(int a, int b) { return (a < b) == (b > a); } 2 | 3 | /* 4 | * check-name: cse-arg01 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-returns: 1 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/cse-cmp-next.c: -------------------------------------------------------------------------------- 1 | void foo(int p, int i, int f, int *ref, int *dst, int *src) 2 | { 3 | if (p) 4 | f = ref[i]; 5 | if (f) 6 | dst[i] = src[i]; 7 | } 8 | 9 | /* 10 | * check-name: cse-cmp-next 11 | * check-command: test-linearize -Wno-decl $file 12 | * 13 | * check-output-ignore 14 | * check-output-pattern(1,2): mul\\. 15 | */ 16 | -------------------------------------------------------------------------------- /validation/optim/cse-fcmp.c: -------------------------------------------------------------------------------- 1 | extern void fun(void); 2 | 3 | int foo(double a, double b) 4 | { 5 | if (a < b) 6 | fun(); 7 | if (a < b) 8 | return 1; 9 | 10 | return 0; 11 | } 12 | 13 | /* 14 | * check-name: cse-fcmp 15 | * check-command: test-linearize -Wno-decl $file 16 | * 17 | * check-output-ignore 18 | * check-output-pattern(1): fcmp 19 | */ 20 | -------------------------------------------------------------------------------- /validation/optim/cse-label.c: -------------------------------------------------------------------------------- 1 | int foo(void) 2 | { 3 | label: 4 | return &&label == &&label; 5 | } 6 | 7 | /* 8 | * check-name: cse-label 9 | * check-command: test-linearize -Wno-decl $file 10 | * 11 | * check-output-ignore 12 | * check-output-returns: 1 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/cse-not01.c: -------------------------------------------------------------------------------- 1 | int and(int a) { return (~a & a) == 0; } 2 | int ior(int a) { return (~a | a) == ~0; } 3 | int xor(int a) { return (~a ^ a) == ~0; } 4 | 5 | /* 6 | * check-name: cse-not01 7 | * check-command: test-linearize -Wno-decl $file 8 | * 9 | * check-output-ignore 10 | * check-output-returns: 1 11 | */ 12 | -------------------------------------------------------------------------------- /validation/optim/cse-not02.c: -------------------------------------------------------------------------------- 1 | int and(int a, int b) { return ((a == b) & (a != b)) == 0; } 2 | int ior(int a, int b) { return ((a == b) | (a != b)) == 1; } 3 | int xor(int a, int b) { return ((a == b) ^ (a != b)) == 1; } 4 | 5 | /* 6 | * check-name: cse-not02 7 | * check-command: test-linearize -Wno-decl $file 8 | * 9 | * check-output-ignore 10 | * check-output-returns: 1 11 | */ 12 | -------------------------------------------------------------------------------- /validation/optim/cse-reg01.c: -------------------------------------------------------------------------------- 1 | int foo(int a, int b) { int x = a + b, y = ~b; return (x < y) == (y > x); } 2 | 3 | /* 4 | * check-name: cse-reg01 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-returns: 1 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/cse-setfval.c: -------------------------------------------------------------------------------- 1 | int ftest(double a, double b) 2 | { 3 | return a == 0.125 || b == 0.125; 4 | } 5 | 6 | /* 7 | * check-name: CSE OP_SETFVAL 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-pattern(1): setfval\\. 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/cse-size.c: -------------------------------------------------------------------------------- 1 | static void foo(void) 2 | { 3 | unsigned short p = 0; 4 | int x = 1; 5 | 6 | for (;;) 7 | if (p) 8 | p = x; 9 | } 10 | 11 | /* 12 | * check-name: cse-size 13 | * check-command: test-linearize -Wno-decl $file 14 | * 15 | * check-output-ignore 16 | * check-output-excludes: phi\\. 17 | * check-output-excludes: cbr 18 | */ 19 | -------------------------------------------------------------------------------- /validation/optim/devirtualize0.c: -------------------------------------------------------------------------------- 1 | static inline long f1(long x) { return x + 1;} 2 | 3 | extern long foo(long a); 4 | long foo(long a) 5 | { 6 | typeof(f1) *f = f1; 7 | return f(a); 8 | } 9 | 10 | /* 11 | * check-name: devirtualize0 12 | * check-command: test-linearize -Wno-decl $file 13 | * check-known-to-fail 14 | * 15 | * check-output-ignore 16 | * check-output-excludes: call\\. 17 | */ 18 | -------------------------------------------------------------------------------- /validation/optim/dup-cond0.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | int f; 3 | }; 4 | 5 | static int foo(struct s *s) 6 | { 7 | if (s->f) 8 | return 0; 9 | else if (!s->f) 10 | return 4; 11 | return -1; 12 | } 13 | 14 | /* 15 | * check-name: dup-cond0 16 | * check-command: test-linearize -Wno-decl $file 17 | * 18 | * check-output-ignore 19 | * check-output-contains: select 20 | */ 21 | -------------------------------------------------------------------------------- /validation/optim/ext-trunc-greater.c: -------------------------------------------------------------------------------- 1 | short sgt(char x) 2 | { 3 | return (int) x; 4 | } 5 | 6 | short ugt(unsigned char x) 7 | { 8 | return (int) x; 9 | } 10 | 11 | /* 12 | * check-name: ext-trunc-greater 13 | * check-command: test-linearize -Wno-decl $file 14 | * 15 | * check-output-ignore 16 | * check-output-excludes: trunc\\. 17 | */ 18 | -------------------------------------------------------------------------------- /validation/optim/ext-trunc-same.c: -------------------------------------------------------------------------------- 1 | short seq(short x) 2 | { 3 | return (int) x; 4 | } 5 | 6 | short ueq(unsigned short x) 7 | { 8 | return (int) x; 9 | } 10 | 11 | /* 12 | * check-name: ext-trunc-same 13 | * check-command: test-linearize -Wno-decl $file 14 | * 15 | * check-output-ignore 16 | * check-output-excludes: trunc\\. 17 | * check-output-excludes: sext\\. 18 | * check-output-excludes: zext\\. 19 | */ 20 | -------------------------------------------------------------------------------- /validation/optim/ext-trunc-smaller.c: -------------------------------------------------------------------------------- 1 | char slt(short x) 2 | { 3 | return (int) x; 4 | } 5 | 6 | char ult(unsigned short x) 7 | { 8 | return (int) x; 9 | } 10 | 11 | /* 12 | * check-name: ext-trunc-smaller 13 | * check-command: test-linearize -Wno-decl $file 14 | * 15 | * check-output-ignore 16 | * check-output-excludes: sext\\. 17 | * check-output-excludes: zext\\. 18 | */ 19 | -------------------------------------------------------------------------------- /validation/optim/fpcast-constant.c: -------------------------------------------------------------------------------- 1 | static double foo(double a, int p) 2 | { 3 | return a * ((p & 0) + 2); 4 | } 5 | 6 | /* 7 | * check-name: fpcast-constant 8 | * check-command: test-linearize $file 9 | * 10 | * check-output-ignore 11 | * check-output-contains: scvtf\\. 12 | * check-output-excludes: fmul\\..*\\$2 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/kill-stores2.c: -------------------------------------------------------------------------------- 1 | extern void def(int *); 2 | 3 | static void foo(void) 4 | { 5 | int c; 6 | def(&c); 7 | if (c) 8 | c = c; 9 | } 10 | 11 | /* 12 | * check-name: kill-stores2 13 | * check-command: test-linearize $file 14 | * 15 | * check-output-ignore 16 | * check-output-excludes: store\\. 17 | */ 18 | -------------------------------------------------------------------------------- /validation/optim/killed-insn.c: -------------------------------------------------------------------------------- 1 | static void foo(int v) 2 | { 3 | int a[2] = { }; 4 | a; 5 | a[1] = v; 6 | } 7 | 8 | /* 9 | * check-name: killed-insn 10 | * check-command: test-linearize $file 11 | * 12 | * check-output-ignore 13 | * check-output-excludes: store\\. 14 | */ 15 | -------------------------------------------------------------------------------- /validation/optim/load-converted.c: -------------------------------------------------------------------------------- 1 | static int foo(int *p, int i) 2 | { 3 | int a = p[i]; 4 | int b = p[i]; 5 | return (a - b); 6 | } 7 | 8 | /* 9 | * check-name: load-converted 10 | * check-command: test-linearize -Wno-decl $file 11 | * 12 | * check-output-ignore 13 | * check-output-excludes: add\\. 14 | */ 15 | -------------------------------------------------------------------------------- /validation/optim/load-dead.c: -------------------------------------------------------------------------------- 1 | void foo(int *p) { *p; } 2 | 3 | int *p; 4 | void bar(void) { *p; } 5 | 6 | /* 7 | * check-name: load-dead 8 | * check-command: test-linearize -Wno-decl $file 9 | * check-output-ignore 10 | * check-output-excludes: load\\. 11 | */ 12 | -------------------------------------------------------------------------------- /validation/optim/lsr-and0.c: -------------------------------------------------------------------------------- 1 | unsigned lsr_and0(unsigned x) 2 | { 3 | unsigned t = (x & 0x00000fff); 4 | return (t >> 12) & t; 5 | } 6 | 7 | /* 8 | * check-name: lsr-and0 9 | * check-command: test-linearize -Wno-decl $file 10 | * 11 | * check-output-ignore 12 | * check-output-contains: ret\\..*\\$0$ 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/lsr-shl0.c: -------------------------------------------------------------------------------- 1 | unsigned mask(unsigned x) 2 | { 3 | return (x << 15) >> 15; 4 | } 5 | 6 | /* 7 | * check-name: lsr-shl0 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-contains: and\\..*0x1ffff 12 | * check-output-excludes: lsr\\. 13 | * check-output-excludes: shl\\. 14 | */ 15 | -------------------------------------------------------------------------------- /validation/optim/mask-lsr.c: -------------------------------------------------------------------------------- 1 | // ((x & M) | y) >> S to (y >> S) when (M >> S) == 0 2 | 3 | unsigned int foo(unsigned int x, unsigned int y) 4 | { 5 | return ((x & 0xff) | y) >> 8; 6 | } 7 | 8 | /* 9 | * check-name: mask-lsr 10 | * check-command: test-linearize -Wno-decl $file 11 | * 12 | * check-output-ignore 13 | * check-output-excludes: %arg1 14 | */ 15 | -------------------------------------------------------------------------------- /validation/optim/mask-out.c: -------------------------------------------------------------------------------- 1 | unsigned mask(unsigned a, unsigned b) 2 | { 3 | return ((a & 0xffff0000) | b) & 0x0000ffff; 4 | } 5 | 6 | /* 7 | * check-name: mask-out 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-excludes: %arg1 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/memops-missed02.c: -------------------------------------------------------------------------------- 1 | void foo(int a[]) 2 | { 3 | int i, val; 4 | for (;; i++) 5 | val = a[i] ? a[i] : val; 6 | } 7 | 8 | /* 9 | * check-name: memops-missed02 10 | * check-command: test-linearize -Wno-decl $file 11 | * 12 | * check-output-ignore 13 | * check-output-pattern(1): load\\. 14 | */ 15 | -------------------------------------------------------------------------------- /validation/optim/missing-select.c: -------------------------------------------------------------------------------- 1 | static int foo(int **g) 2 | { 3 | int i = 1; 4 | int *a[2]; 5 | int **p; 6 | 7 | a[1] = &i; 8 | if (g) 9 | p = g; 10 | else 11 | p = &a[0]; 12 | if (!g) 13 | **p = 0; 14 | return i; 15 | } 16 | 17 | /* 18 | * check-name: missing-select 19 | * check-command: test-linearize -Wno-decl $file 20 | * 21 | * check-output-ignore 22 | * check-output-contains: select\\. 23 | */ 24 | -------------------------------------------------------------------------------- /validation/optim/muldiv-by-zero.c: -------------------------------------------------------------------------------- 1 | typedef unsigned int ui; 2 | typedef int si; 3 | 4 | si smul0(si a) { return a * 0; } 5 | ui umul0(ui a) { return a * 0; } 6 | 7 | /* 8 | * check-name: muldiv-by-zero 9 | * check-command: test-linearize -Wno-decl $file 10 | * check-output-ignore 11 | * 12 | * check-output-excludes: mul[us]\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/multi-phisrc.c: -------------------------------------------------------------------------------- 1 | void fun(void); 2 | 3 | void foo(int p, int a) 4 | { 5 | if (p == p) { 6 | switch (p) { 7 | case 0: 8 | break; 9 | case 1: 10 | a = 0; 11 | } 12 | } 13 | if (a) 14 | fun(); 15 | } 16 | 17 | /* 18 | * check-name: multi-phisrc 19 | * check-command: test-linearize -Wno-decl $file 20 | * 21 | * check-output-ignore 22 | * check-output-excludes: phi 23 | */ 24 | -------------------------------------------------------------------------------- /validation/optim/null-phi.c: -------------------------------------------------------------------------------- 1 | static int foo(void) 2 | { 3 | if (0) 4 | return 0; 5 | } 6 | 7 | /* 8 | * check-name: null-phi 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/phi-ret.c: -------------------------------------------------------------------------------- 1 | int foo(int p, int q, int v) 2 | { 3 | if (q) { 4 | if (p) { 5 | v = p; 6 | p = 0; 7 | } 8 | } else 9 | p = 0; 10 | if (p) 11 | return v + 1; 12 | return q; 13 | } 14 | 15 | /* 16 | * check-name: phi-ret 17 | * check-command: test-linearize -Wno-decl $file 18 | * 19 | * check-output-ignore 20 | * check-output-excludes: phi\\. 21 | */ 22 | -------------------------------------------------------------------------------- /validation/optim/range-check1.c: -------------------------------------------------------------------------------- 1 | #define N 1024 2 | 3 | _Bool check_ok(long i) 4 | { 5 | return i >= 0 && i < N; 6 | } 7 | 8 | /* 9 | * check-name: range-check1 10 | * check-command: test-linearize -Wno-decl $file 11 | * 12 | * check-output-ignore 13 | * check-output-contains: setbe\\..*0x3ff 14 | * check-output-excludes: set[lga][te]\\. 15 | * check-output-excludes: set[ab]\\. 16 | */ 17 | -------------------------------------------------------------------------------- /validation/optim/range-check2.c: -------------------------------------------------------------------------------- 1 | #define N 1024 2 | 3 | _Bool check_ok(int i) 4 | { 5 | return (i >= 0 && i < N) == (((unsigned int)i) < N); 6 | } 7 | 8 | /* 9 | * check-name: range-check2 10 | * check-command: test-linearize -Wno-decl $file 11 | * 12 | * check-output-ignore 13 | * check-output-returns: 1 14 | */ 15 | -------------------------------------------------------------------------------- /validation/optim/reassoc-op-op1.c: -------------------------------------------------------------------------------- 1 | int foo(int x, int *ptr) 2 | { 3 | int t = x + 1; 4 | *ptr = t; 5 | return t + -1; 6 | } 7 | 8 | /* 9 | * check-name: reassoc-op-op1 10 | * check-command: test-linearize -Wno-decl $file 11 | * 12 | * check-output-ignore 13 | * check-output-pattern(1): add\\. 14 | */ 15 | -------------------------------------------------------------------------------- /validation/optim/select-constant-cond.c: -------------------------------------------------------------------------------- 1 | int t(int p, int a, int b) { return ((p == p) ? a : b) == a; } 2 | int f(int p, int a, int b) { return ((p != p) ? a : b) == b; } 3 | 4 | /* 5 | * check-name: select-constant-cond 6 | * check-command: test-linearize -Wno-decl $file 7 | * 8 | * check-output-ignore 9 | * check-output-returns: 1 10 | */ 11 | -------------------------------------------------------------------------------- /validation/optim/select-same-args.c: -------------------------------------------------------------------------------- 1 | int foo(int p, int a) { return (p ? a : a) == a; } 2 | 3 | /* 4 | * check-name: select-same-args 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-returns: 1 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/select-select-true-false0.c: -------------------------------------------------------------------------------- 1 | int fw(int p, int a, int b) { return ((p ? 42 : 0) ? a : b) == ( p ? a : b); } 2 | int bw(int p, int a, int b) { return ((p ? 0 : 42) ? a : b) == ( p ? b : a); } 3 | 4 | /* 5 | * check-name: select-select-true-false0 6 | * check-command: test-linearize -Wno-decl $file 7 | * 8 | * check-output-ignore 9 | * check-output-returns: 1 10 | */ 11 | -------------------------------------------------------------------------------- /validation/optim/select-select-true-false1.c: -------------------------------------------------------------------------------- 1 | int foo(int p) 2 | { 3 | int t = (p ? 42 : 0); 4 | return (t ? 42 : 0) == ( p ? 42 : 0); 5 | } 6 | 7 | /* 8 | * check-name: select-select-true-false1 9 | * check-command: test-linearize -Wno-decl $file 10 | * 11 | * check-output-ignore 12 | * check-output-returns: 1 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/select-select-true-true.c: -------------------------------------------------------------------------------- 1 | int foo(int p, int a, int b) { return ((p ? 42 : 43) ? a : b) == a ; } 2 | 3 | /* 4 | * check-name: select-select-true-true 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-returns: 1 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/select-self-zero.c: -------------------------------------------------------------------------------- 1 | int sel_self0x(int x) { return (x ? 0 : x) == 0; } 2 | int sel_selfx0(int x) { return (x ? x : 0) == x; } 3 | 4 | /* 5 | * check-name: select-self-zero 6 | * check-command: test-linearize -Wno-decl $file 7 | * 8 | * check-output-ignore 9 | * check-output-returns: 1 10 | */ 11 | -------------------------------------------------------------------------------- /validation/optim/select-zero.c: -------------------------------------------------------------------------------- 1 | static int sel0(int a) 2 | { 3 | if (a) 4 | return 0; 5 | else 6 | return a; 7 | } 8 | 9 | /* 10 | * check-name: select-zero 11 | * check-command: test-linearize $file 12 | * 13 | * check-output-ignore 14 | * check-output-contains: ret.32 *\\$0 15 | * check-output-excludes: select\\. 16 | */ 17 | -------------------------------------------------------------------------------- /validation/optim/set-uimm1.c: -------------------------------------------------------------------------------- 1 | static _Bool setle_umax(unsigned int a) { return (a <= ~0) == 1; } 2 | static _Bool setgt_umax(unsigned int a) { return (a > ~0) == 0; } 3 | 4 | /* 5 | * check-name: set-uimm1 6 | * check-command: test-linearize $file 7 | * 8 | * check-output-ignore 9 | * check-output-returns: 1 10 | */ 11 | -------------------------------------------------------------------------------- /validation/optim/set-uimm3.c: -------------------------------------------------------------------------------- 1 | int le(int x) { return (x <= 0x7fffffffU) == (x >= 0); } 2 | int gt(int x) { return (x > 0x7fffffffU) == (x < 0); } 3 | 4 | /* 5 | * check-name: set-uimm3 6 | * check-command: test-linearize -Wno-decl $file 7 | * 8 | * check-output-ignore 9 | * check-output-returns: 1 10 | */ 11 | -------------------------------------------------------------------------------- /validation/optim/setcc-mask.c: -------------------------------------------------------------------------------- 1 | int foo (int a) 2 | { 3 | return ((a == 0) & 1) == (a == 0); 4 | } 5 | 6 | /* 7 | * check-name: setcc-mask 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-start 11 | foo: 12 | .L0: 13 | 14 | ret.32 $1 15 | 16 | 17 | * check-output-end 18 | */ 19 | -------------------------------------------------------------------------------- /validation/optim/setne0-sext.c: -------------------------------------------------------------------------------- 1 | long foo(int a) { return a != 0; } 2 | 3 | /* 4 | * check-name: setne0-sext 5 | * check-command: test-linearize -m64 -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-excludes: sext\\. 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/setne0-trunc.c: -------------------------------------------------------------------------------- 1 | char foo(int a) { return a != 0; } 2 | 3 | /* 4 | * check-name: setne0-trunc 5 | * check-command: test-linearize -m64 -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-excludes: trunc\\. 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/setne0-zext.c: -------------------------------------------------------------------------------- 1 | unsigned long foo(int a) { return (unsigned int) (a != 0); } 2 | 3 | /* 4 | * check-name: setne0-zext 5 | * check-command: test-linearize -m64 -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-excludes: zext\\. 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/sext-sext.c: -------------------------------------------------------------------------------- 1 | int foo(signed char offset) 2 | { 3 | return (int)(short) offset; 4 | } 5 | 6 | /* 7 | * check-name: sext-sext 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-pattern(1): sext\\. 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/sext.c: -------------------------------------------------------------------------------- 1 | int sext(int x) 2 | { 3 | return (x << 5) >> 5; 4 | } 5 | 6 | /* 7 | * check-name: sext 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-excludes: sext\\. 12 | * check-output-contains: asr\\.32 13 | * check-output-contains: shl\\.32 14 | */ 15 | -------------------------------------------------------------------------------- /validation/optim/shift-zext.c: -------------------------------------------------------------------------------- 1 | unsigned int foo(unsigned int x) 2 | { 3 | return (x << 20) >> 20; 4 | } 5 | 6 | /* 7 | * check-name: shift-zext 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-contains: and\\..*%arg1, \\$0xfff 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/shl-and0.c: -------------------------------------------------------------------------------- 1 | unsigned shl_and0(unsigned x) 2 | { 3 | unsigned t = (x & 0xfff00000); 4 | return (t << 12) & t; 5 | } 6 | 7 | /* 8 | * check-name: shl-and0 9 | * check-command: test-linearize -Wno-decl $file 10 | * 11 | * check-output-ignore 12 | * check-output-contains: ret\\..*\\$0$ 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/shl-lsr0.c: -------------------------------------------------------------------------------- 1 | unsigned mask(unsigned x) 2 | { 3 | return (x >> 15) << 15; 4 | } 5 | 6 | /* 7 | * check-name: shl-lsr0 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-contains: and\\..*0xffff8000 12 | * check-output-excludes: lsr\\. 13 | * check-output-excludes: shl\\. 14 | */ 15 | -------------------------------------------------------------------------------- /validation/optim/simplify-add-neg.c: -------------------------------------------------------------------------------- 1 | int add_neg(int x, int y) { return x + -y; } 2 | 3 | /* 4 | * check-name: simplify-add-neg 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-contains: sub\\..*%arg1, %arg2 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/simplify-cte-sub-addl.c: -------------------------------------------------------------------------------- 1 | int cte_sub_addl(int x) { return (1 - x) + 1; } 2 | 3 | /* 4 | * check-name: simplify-cte-sub-addl 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-contains: sub\\..*\\$2, %arg1 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/simplify-cte-sub-addr.c: -------------------------------------------------------------------------------- 1 | int cte_sub_addr(int x) { return 2 - (x + 1); } 2 | 3 | /* 4 | * check-name: simplify-cte-sub-addr 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-contains: sub\\..*\\$1, %arg1 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/simplify-cte-sub-subr.c: -------------------------------------------------------------------------------- 1 | int cte_sub_subr(int x) { return 1 - (1 - x); } 2 | 3 | /* 4 | * check-name: simplify-cte-sub-subr 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-contains: ret\\..* %arg1 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/simplify-neg-add-cte.c: -------------------------------------------------------------------------------- 1 | #define C 3 2 | 3 | int foo(int x) { return -(x + C) == (-3 - x); } 4 | 5 | /* 6 | * check-name: simplify-neg-add-cte 7 | * check-command: test-linearize -Wno-decl $file 8 | * 9 | * check-output-ignore 10 | * check-output-contains: ret\\..*\\$1 11 | */ 12 | -------------------------------------------------------------------------------- /validation/optim/simplify-neg-add.c: -------------------------------------------------------------------------------- 1 | int neg_add(int x, int y) { return -x + y; } 2 | 3 | /* 4 | * check-name: simplify-neg-add 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-contains: sub\\..*%arg2, %arg1 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/simplify-neg-not.c: -------------------------------------------------------------------------------- 1 | int foo(int x) { return -(~x) == x + 1; } 2 | 3 | /* 4 | * check-name: simplify-neg-not 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-contains: ret\\..*\\$1 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/simplify-neg-sub.c: -------------------------------------------------------------------------------- 1 | int foo(int x, int y) { return -(x - y) == (y - x); } 2 | 3 | /* 4 | * check-name: simplify-neg-sub 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-contains: ret\\..*\\$1 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/simplify-not-add-cte.c: -------------------------------------------------------------------------------- 1 | #define C 3 2 | 3 | int foo(int x) { return ~(x + C) == (~C - x); } 4 | 5 | /* 6 | * check-name: simplify-not-add-cte 7 | * check-command: test-linearize -Wno-decl $file 8 | * 9 | * check-output-ignore 10 | * check-output-contains: ret\\..*\\$1 11 | */ 12 | -------------------------------------------------------------------------------- /validation/optim/simplify-not-neg.c: -------------------------------------------------------------------------------- 1 | int foo(int x) { return ~(-x) == (x - 1); } 2 | 3 | /* 4 | * check-name: simplify-not-neg 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-contains: ret\\..*\\$1 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/simplify-not-sub-cte.c: -------------------------------------------------------------------------------- 1 | #define C 3 2 | 3 | int foo(int x) { return ~(C - x) == (x + ~C); } 4 | 5 | /* 6 | * check-name: simplify-not-sub-cte 7 | * check-command: test-linearize -Wno-decl $file 8 | * 9 | * check-output-ignore 10 | * check-output-contains: ret\\..*\\$1 11 | */ 12 | -------------------------------------------------------------------------------- /validation/optim/simplify-not-xor-cte.c: -------------------------------------------------------------------------------- 1 | #define C 3 2 | 3 | int foo(int x) { return ~(x ^ C) == (x ^ ~C); } 4 | 5 | /* 6 | * check-name: simplify-not-xor-cte 7 | * check-command: test-linearize -Wno-decl $file 8 | * 9 | * check-output-ignore 10 | * check-output-contains: ret\\..*\\$1 11 | */ 12 | -------------------------------------------------------------------------------- /validation/optim/simplify-same-add-subl.c: -------------------------------------------------------------------------------- 1 | int add_subl(int x, int y) { return (x + y) - x; } 2 | 3 | /* 4 | * check-name: simplify-same-add-subl 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-start 8 | add_subl: 9 | .L0: 10 | 11 | ret.32 %arg2 12 | 13 | 14 | * check-output-end 15 | */ 16 | -------------------------------------------------------------------------------- /validation/optim/simplify-same-add-subr.c: -------------------------------------------------------------------------------- 1 | int add_subr(int x, int y) { return (x + y) - y; } 2 | 3 | /* 4 | * check-name: simplify-same-add-subr 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-start 8 | add_subr: 9 | .L0: 10 | 11 | ret.32 %arg1 12 | 13 | 14 | * check-output-end 15 | */ 16 | -------------------------------------------------------------------------------- /validation/optim/simplify-same-addl-sub.c: -------------------------------------------------------------------------------- 1 | int foo(int x, int y) { return x + (y - x); } 2 | 3 | /* 4 | * check-name: simplify-same-addl-sub 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-contains: ret\\..*%arg2 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/simplify-same-sub-addl.c: -------------------------------------------------------------------------------- 1 | int foo(int x, int y) { return (x - y) + y; } 2 | 3 | /* 4 | * check-name: simplify-same-sub-addl 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-contains: ret\\..*%arg1 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/simplify-same-subl-add.c: -------------------------------------------------------------------------------- 1 | int subl_add(int x, int y) { return x - (x + y); } 2 | 3 | /* 4 | * check-name: simplify-same-subl-add 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-contains: neg\\..* %arg2 9 | * check-output-excludes: add\\. 10 | * check-output-excludes: sub\\. 11 | */ 12 | -------------------------------------------------------------------------------- /validation/optim/simplify-same-subr-add.c: -------------------------------------------------------------------------------- 1 | int subr_add(int x, int y) { return x - (y + x); } 2 | 3 | /* 4 | * check-name: simplify-same-subr-add 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-contains: neg\\..* %arg2 9 | * check-output-excludes: add\\. 10 | * check-output-excludes: sub\\. 11 | */ 12 | -------------------------------------------------------------------------------- /validation/optim/simplify-sub-neg.c: -------------------------------------------------------------------------------- 1 | int sub_neg(int x, int y) { return x - -y; } 2 | 3 | /* 4 | * check-name: simplify-sub-neg 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-contains: add\\..*%arg., %arg. 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/simplify-zero-sub.c: -------------------------------------------------------------------------------- 1 | int zero_sub(int x) { return 0 - x; } 2 | 3 | /* 4 | * check-name: simplify-zero-sub 5 | * check-command: test-linearize -Wno-decl $file 6 | * 7 | * check-output-ignore 8 | * check-output-contains: neg\\..* %arg1 9 | */ 10 | -------------------------------------------------------------------------------- /validation/optim/store-dominated.c: -------------------------------------------------------------------------------- 1 | static int a[]; 2 | 3 | static void foo(void) 4 | { 5 | int *c = &a[1]; 6 | *c = *c = 0; 7 | } 8 | 9 | /* 10 | * check-name: store-dominated 11 | * check-command: test-linearize $file 12 | * 13 | * check-output-ignore 14 | * check-output-excludes: add\\. 15 | */ 16 | -------------------------------------------------------------------------------- /validation/optim/testsuite.c: -------------------------------------------------------------------------------- 1 | int foo(void) 2 | { 3 | return 0; 4 | } 5 | 6 | /* 7 | * check-name: testsuite 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-match(ret): \\$0 12 | * check-output-returns: 0 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/trivial-phi01.c: -------------------------------------------------------------------------------- 1 | void foo(int a) 2 | { 3 | if (a) { 4 | while (a) { 5 | switch (0) { 6 | default: 7 | a = 0; 8 | case 0:; 9 | } 10 | } 11 | } 12 | } 13 | 14 | /* 15 | * check-name: trivial-phi01 16 | * check-command: test-linearize -Wno-decl $file 17 | * 18 | * check-output-ignore 19 | * check-output-excludes: phi\\. 20 | */ 21 | -------------------------------------------------------------------------------- /validation/optim/trivial-phis.c: -------------------------------------------------------------------------------- 1 | void foo(int a) 2 | { 3 | while (1) 4 | a ^= 0; 5 | } 6 | 7 | /* 8 | * check-name: trivial phis 9 | * check-command: test-linearize -Wno-decl $file 10 | * 11 | * check-output-ignore 12 | * check-output-excludes: phi\\. 13 | * check-output-excludes: phisrc\\. 14 | */ 15 | -------------------------------------------------------------------------------- /validation/optim/trunc-mask-zext.c: -------------------------------------------------------------------------------- 1 | unsigned long long foo(unsigned long long x) 2 | { 3 | return (((unsigned int) x) & 0x7ffU); 4 | } 5 | 6 | /* 7 | * check-name: trunc-mask-zext 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-excludes: trunc\\. 12 | * check-output-excludes: zext\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/trunc-setne0.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | unsigned int u:1; 3 | }; 4 | 5 | unsigned int foo(struct s x) 6 | { 7 | if (x.u) 8 | return 1; 9 | else 10 | return 0; 11 | } 12 | 13 | /* 14 | * check-name: trunc-setne0 15 | * check-command: test-linearize -Wno-decl $file 16 | * 17 | * check-output-ignore 18 | * check-output-contains: and\\. 19 | * check-output-excludes: trunc\\. 20 | */ 21 | -------------------------------------------------------------------------------- /validation/optim/trunc-trunc.c: -------------------------------------------------------------------------------- 1 | char foo(int a) 2 | { 3 | return ((((short) a) + 1) - 1); 4 | } 5 | 6 | /* 7 | * check-name: trunc-trunc 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-pattern(1): trunc\\. 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/volatile-bitfield.c: -------------------------------------------------------------------------------- 1 | struct s { 2 | int f:3; 3 | }; 4 | 5 | void foo(volatile struct s *p) 6 | { 7 | p->f; 8 | } 9 | 10 | /* 11 | * check-name: volatile-bitfield 12 | * check-command: test-linearize -Wno-decl $file 13 | * 14 | * check-output-ignore 15 | * check-output-contains: load\\. 16 | */ 17 | -------------------------------------------------------------------------------- /validation/optim/volatile-side-effect.c: -------------------------------------------------------------------------------- 1 | void foo(int p, volatile int *ptr) 2 | { 3 | p ? : *ptr; 4 | p ? : *ptr; 5 | } 6 | 7 | /* 8 | * check-name: volatile-side-effect 9 | * check-command: test-linearize -Wno-decl $file 10 | * check-output-ignore 11 | * 12 | * check-output-pattern(2): load 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/zext-and.c: -------------------------------------------------------------------------------- 1 | unsigned int foo(unsigned char x) 2 | { 3 | return (unsigned int)x & 0xffffU; 4 | } 5 | 6 | /* 7 | * check-name: zext-and 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-excludes: and\\. 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/zext-and1.c: -------------------------------------------------------------------------------- 1 | unsigned int bar(unsigned char x) 2 | { 3 | return (unsigned int)x & 0xff01U; 4 | } 5 | 6 | /* 7 | * check-name: zext-and1 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-contains: and\\..*\\$1 12 | */ 13 | -------------------------------------------------------------------------------- /validation/optim/zext-asr.c: -------------------------------------------------------------------------------- 1 | unsigned short foo(unsigned short a) 2 | { 3 | return a >> 16; 4 | } 5 | 6 | /* 7 | * check-name: zext-asr 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-contains: ret\\..*\\$0 12 | * check-output-excludes: asr\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/zext-sext.c: -------------------------------------------------------------------------------- 1 | int foo(unsigned char offset) 2 | { 3 | return (int)(short) offset; 4 | } 5 | 6 | /* 7 | * check-name: zext-sext 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-excludes: sext\\. 12 | * check-output-pattern(1): zext\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/optim/zext-zext.c: -------------------------------------------------------------------------------- 1 | int foo(unsigned char offset) 2 | { 3 | return (int)(unsigned short) offset; 4 | } 5 | 6 | /* 7 | * check-name: zext-zext 8 | * check-command: test-linearize -Wno-decl $file 9 | * 10 | * check-output-ignore 11 | * check-output-excludes: sext\\. 12 | * check-output-pattern(1): zext\\. 13 | */ 14 | -------------------------------------------------------------------------------- /validation/option-parsing-00.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * check-name: option parsing 00 4 | * check-command: sparse -foptimize-xyz $file 5 | */ 6 | -------------------------------------------------------------------------------- /validation/option-parsing-01.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * check-name: option parsing 01 4 | * check-command: sparse -fno-optimize-xyz $file 5 | */ 6 | -------------------------------------------------------------------------------- /validation/outer-scope.c: -------------------------------------------------------------------------------- 1 | #ifndef FOO 2 | struct st { int len; }; 3 | #define FOO 4 | #else 5 | struct st; 6 | static int test(struct st *s); 7 | static int test(struct st *s) 8 | { 9 | return s->len; 10 | } 11 | #endif 12 | /* 13 | * check-name: There is no scope boundary between global and file scope 14 | * check-description: Used to mess scopes with -include 15 | * check-command: sparse -include $file $file 16 | */ 17 | -------------------------------------------------------------------------------- /validation/packed-bitfield2.c: -------------------------------------------------------------------------------- 1 | struct bf2 { 2 | unsigned p1:2; 3 | unsigned i1:32; 4 | unsigned p2:2; 5 | unsigned s9:9; 6 | unsigned s9:9; 7 | unsigned s9:9; 8 | unsigned b1:1; 9 | } __attribute__((packed)); 10 | 11 | _Static_assert(sizeof(struct bf2) == 8); 12 | 13 | /* 14 | * check-name: packed-bitfield2 15 | */ 16 | -------------------------------------------------------------------------------- /validation/packed-bitfield4.c: -------------------------------------------------------------------------------- 1 | #define __packed __attribute__((packed)) 2 | 3 | typedef __UINT32_TYPE__ u32; 4 | 5 | struct s { 6 | u32 f:24; 7 | } __packed; 8 | _Static_assert(sizeof(struct s) == 3); 9 | 10 | static int ld(struct s *s) 11 | { 12 | return s->f; 13 | } 14 | 15 | /* 16 | * check-name: packed-bitfield4 17 | * check-description: Is check_access() OK with short packed bitfields? 18 | */ 19 | -------------------------------------------------------------------------------- /validation/pragma-once.c: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pragma-once.c" 3 | /* 4 | * check-name: #pragma once 5 | */ 6 | -------------------------------------------------------------------------------- /validation/preprocessor/bad-cmdline-include.c: -------------------------------------------------------------------------------- 1 | #error some random error 2 | 3 | /* 4 | * check-name: bad-cmdline-include 5 | * check-command: sparse -include $file 6 | * 7 | * check-error-start 8 | command-line: note: in included file (through builtin): 9 | preprocessor/bad-cmdline-include.c:1:2: error: some random error 10 | * check-error-end 11 | */ 12 | -------------------------------------------------------------------------------- /validation/preprocessor/base-file.c: -------------------------------------------------------------------------------- 1 | __FILE__ 2 | __BASE_FILE__ 3 | 4 | #include "base-file.h" 5 | 6 | /* 7 | * check-name: base file 8 | * check-command: sparse -E $file 9 | * 10 | * check-output-start 11 | 12 | "preprocessor/base-file.c" 13 | "preprocessor/base-file.c" 14 | "preprocessor/base-file.h" 15 | "preprocessor/base-file.c" 16 | * check-output-end 17 | */ 18 | -------------------------------------------------------------------------------- /validation/preprocessor/base-file.h: -------------------------------------------------------------------------------- 1 | __FILE__ 2 | __BASE_FILE__ 3 | -------------------------------------------------------------------------------- /validation/preprocessor/builtin.c: -------------------------------------------------------------------------------- 1 | __CHECKER__ 2 | F(__CHECKER__,__CHECKER__) 3 | S(#__CHECKER__) 4 | const char str[] = "__CHECKER__"; 5 | 6 | /* 7 | * check-name: builtin 8 | * check-command: sparse -E $file 9 | * 10 | * check-output-start 11 | 12 | 1 13 | F(1,1) 14 | S(#1) 15 | const char str[] = "__CHECKER__"; 16 | * check-output-end 17 | */ 18 | -------------------------------------------------------------------------------- /validation/preprocessor/cli-D-arg.c: -------------------------------------------------------------------------------- 1 | A 2 | B 3 | /* 4 | * check-name: cli: -D MACRO 5 | * check-command: sparse -E -D A -D B=abc $file 6 | * 7 | * check-output-start 8 | 9 | 1 10 | abc 11 | * check-output-end 12 | */ 13 | -------------------------------------------------------------------------------- /validation/preprocessor/cli-D-space.c: -------------------------------------------------------------------------------- 1 | M(0,1) 2 | /* 3 | * check-name: cli: allow spaces in macros 4 | * check-command: sparse -E '-DM(X, Y)=a' $file 5 | * 6 | * check-output-start 7 | 8 | a 9 | * check-output-end 10 | */ 11 | -------------------------------------------------------------------------------- /validation/preprocessor/counter1.c: -------------------------------------------------------------------------------- 1 | __COUNTER__ 2 | __COUNTER__ 3 | /* 4 | * check-name: __COUNTER__ #1 5 | * check-command: sparse -E $file 6 | * 7 | * check-output-start 8 | 9 | 0 10 | 1 11 | * check-output-end 12 | */ 13 | -------------------------------------------------------------------------------- /validation/preprocessor/counter2.c: -------------------------------------------------------------------------------- 1 | __FILE__ __COUNTER__ 2 | #include 3 | __FILE__ __COUNTER__ 4 | /* 5 | * check-name: __COUNTER__ #2 6 | * check-command: sparse -Ipreprocessor -E $file 7 | * 8 | * check-output-start 9 | 10 | "preprocessor/counter2.c" 0 11 | "preprocessor/counter2.h" 1 12 | "preprocessor/counter2.c" 2 13 | * check-output-end 14 | */ 15 | -------------------------------------------------------------------------------- /validation/preprocessor/counter2.h: -------------------------------------------------------------------------------- 1 | __FILE__ __COUNTER__ 2 | -------------------------------------------------------------------------------- /validation/preprocessor/counter3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * check-name: __COUNTER__ #3 3 | * check-command: sparse -Ipreprocessor -E preprocessor/counter1.c $file 4 | * 5 | * check-output-start 6 | 7 | 0 8 | 1 9 | "preprocessor/counter2.c" 0 10 | "preprocessor/counter2.h" 1 11 | "preprocessor/counter2.c" 2 12 | * check-output-end 13 | */ 14 | #include "counter2.c" 15 | -------------------------------------------------------------------------------- /validation/preprocessor/dump-macros-empty.c: -------------------------------------------------------------------------------- 1 | /* 2 | * check-name: dump-macros with empty file 3 | * check-command: sparse -E -dD empty-file 4 | * 5 | * check-output-ignore 6 | check-output-pattern(1): #define __CHECKER__ 1 7 | */ 8 | -------------------------------------------------------------------------------- /validation/preprocessor/dump-macros-multi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * check-name: dump-macros with multiple files 3 | * check-command: sparse -E -dD empty-file $file 4 | * 5 | * check-output-ignore 6 | check-output-pattern(2): #define __CHECKER__ 1 7 | */ 8 | -------------------------------------------------------------------------------- /validation/preprocessor/empty-char-constant.c: -------------------------------------------------------------------------------- 1 | #if 0 2 | '' 3 | #endif 4 | 5 | /* 6 | * check-name: empty-char-constant 7 | * check-command: sparse -E $file 8 | * 9 | * check-output-start 10 | 11 | 12 | * check-output-end 13 | */ 14 | -------------------------------------------------------------------------------- /validation/preprocessor/expand-and-nl.c: -------------------------------------------------------------------------------- 1 | #define M(X) X-X 2 | 3 | M(a 4 | b) 5 | /* 6 | * check-name: expand-and-nl 7 | * check-command: sparse -E $file 8 | * 9 | * check-output-start 10 | 11 | a b-a b 12 | * check-output-end 13 | */ 14 | -------------------------------------------------------------------------------- /validation/preprocessor/extra-token.c: -------------------------------------------------------------------------------- 1 | #define THIS 0 2 | #ifdef THIS == 1 3 | #endif 4 | 5 | /* 6 | * check-name: preprocessor/extra-token.c 7 | * check-command: sparse -E $file 8 | * check-known-to-fail 9 | * 10 | * check-error-start 11 | preprocessor/extra-token.c:2:13: warning: extra tokens at end of #ifdef directive 12 | * check-error-end 13 | * 14 | * check-output-ignore 15 | */ 16 | -------------------------------------------------------------------------------- /validation/preprocessor/freestanding.c: -------------------------------------------------------------------------------- 1 | __STDC_HOSTED__ 2 | 3 | /* 4 | * check-name: freestanding 5 | * check-command: sparse -E -ffreestanding $file 6 | * 7 | * check-output-start 8 | 9 | 0 10 | * check-output-end 11 | */ 12 | -------------------------------------------------------------------------------- /validation/preprocessor/hosted.c: -------------------------------------------------------------------------------- 1 | __STDC_HOSTED__ 2 | 3 | /* 4 | * check-name: hosted 5 | * check-command: sparse -E -fhosted $file 6 | * 7 | * check-output-start 8 | 9 | 1 10 | * check-output-end 11 | */ 12 | -------------------------------------------------------------------------------- /validation/preprocessor/ident-pragma.c: -------------------------------------------------------------------------------- 1 | #pragma ident "foo" 2 | 3 | /* 4 | * check-description: check that '#pragma ident ... " is ignored. 5 | * check-name: ident-pragma 6 | * check-command: sparse -E $file 7 | * 8 | * check-output-start 9 | 10 | 11 | * check-output-end 12 | */ 13 | -------------------------------------------------------------------------------- /validation/preprocessor/ident.c: -------------------------------------------------------------------------------- 1 | #ident "foo" 2 | 3 | /* 4 | * check-description: check that the non-standard "#ident ..." is ignored. 5 | * check-name: ident 6 | * check-command: sparse -E $file 7 | * 8 | * check-output-start 9 | 10 | 11 | * check-output-end 12 | */ 13 | -------------------------------------------------------------------------------- /validation/preprocessor/include-level.c: -------------------------------------------------------------------------------- 1 | __FILE__: __INCLUDE_LEVEL__ 2 | 3 | #include "include-level.h" 4 | 5 | /* 6 | * check-name: include-level 7 | * check-command: sparse -E $file 8 | * 9 | * check-output-start 10 | 11 | "preprocessor/include-level.c": 0 12 | "preprocessor/include-level.h": 1 13 | * check-output-end 14 | */ 15 | -------------------------------------------------------------------------------- /validation/preprocessor/include-level.h: -------------------------------------------------------------------------------- 1 | __FILE__: __INCLUDE_LEVEL__ 2 | -------------------------------------------------------------------------------- /validation/preprocessor/phase3-comments.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Each comment should be treated as if it had been a single space. 3 | */ 4 | 5 | /* This should give nothing */ 6 | #define X /* 7 | */ Y 8 | 9 | /* 10 | * check-name: phase3-comments 11 | * check-command: sparse -E $file 12 | * 13 | * check-output-start 14 | 15 | 16 | * check-output-end 17 | */ 18 | -------------------------------------------------------------------------------- /validation/preprocessor/predef-llp64.c: -------------------------------------------------------------------------------- 1 | #include "predef.c" 2 | 3 | /* 4 | * check-name: predefined macros for LLP64 5 | * check-command: test-linearize -Wno-decl -msize-llp64 $file 6 | * check-output-ignore 7 | * 8 | * check-output-contains: ret\\..*\\$0 9 | */ 10 | -------------------------------------------------------------------------------- /validation/preprocessor/predef-lp32.c: -------------------------------------------------------------------------------- 1 | #include "predef.c" 2 | 3 | /* 4 | * check-name: predefined macros for LP32 5 | * check-command: test-linearize -Wno-decl -m32 $file 6 | * check-output-ignore 7 | * 8 | * check-output-contains: ret\\..*\\$0 9 | */ 10 | -------------------------------------------------------------------------------- /validation/preprocessor/predef-lp64.c: -------------------------------------------------------------------------------- 1 | #include "predef.c" 2 | 3 | /* 4 | * check-name: predefined macros for LP64 5 | * check-command: test-linearize -Wno-decl -m64 $file 6 | * check-output-ignore 7 | * 8 | * check-output-contains: ret\\..*\\$0 9 | */ 10 | -------------------------------------------------------------------------------- /validation/preprocessor/predef-token.c: -------------------------------------------------------------------------------- 1 | static __UINT8_TYPE__ u8; 2 | 3 | /* 4 | * check-name: predef-token 5 | */ 6 | -------------------------------------------------------------------------------- /validation/preprocessor/predef-unsigned.c: -------------------------------------------------------------------------------- 1 | #include "predef.c" 2 | 3 | /* 4 | * check-name: predefined macros for -funsigned-char 5 | * check-command: test-linearize -Wno-decl -funsigned-char $file 6 | * check-output-ignore 7 | * 8 | * check-output-contains: ret\\..*\\$0 9 | */ 10 | -------------------------------------------------------------------------------- /validation/preprocessor/preprocessor1.c: -------------------------------------------------------------------------------- 1 | #define func(x) x 2 | #define bar func( 3 | #define foo bar foo 4 | foo ) 5 | /* 6 | * check-name: Preprocessor #1 7 | * check-description: Used to cause infinite recursion. 8 | * check-command: sparse -E $file 9 | * 10 | * check-output-start 11 | 12 | foo 13 | * check-output-end 14 | */ 15 | -------------------------------------------------------------------------------- /validation/preprocessor/preprocessor12.c: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU kludge 3 | */ 4 | #define A(x,...) x,##__VA_ARGS__ 5 | A(1) 6 | A(1,2) 7 | A(1,2,3) 8 | /* 9 | * check-name: Preprocessor #12 10 | * check-command: sparse -E $file 11 | * 12 | * check-output-start 13 | 14 | 1 15 | 1,2 16 | 1,2,3 17 | * check-output-end 18 | */ 19 | -------------------------------------------------------------------------------- /validation/preprocessor/preprocessor14.c: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU kludge, another corner case 3 | */ 4 | #define A(x,y,...) ,##x##__VA_ARGS__ 5 | A(,1) 6 | #define B(x,y,...) x##,##__VA_ARGS__ 7 | B(,1) 8 | /* 9 | * check-name: Preprocessor #14 10 | * check-command: sparse -E $file 11 | * 12 | * check-output-start 13 | 14 | 15 | * check-output-end 16 | */ 17 | -------------------------------------------------------------------------------- /validation/preprocessor/preprocessor15.c: -------------------------------------------------------------------------------- 1 | #define A defi 2 | #define B ned 3 | #define C(x,y) x##y 4 | #define D(x,y) C(x,y) 5 | #if D(A,B) B 6 | D(1,2) 7 | #endif 8 | /* 9 | * check-name: Preprocessor #15 10 | * check-command: sparse -E $file 11 | * 12 | * check-output-start 13 | 14 | 12 15 | * check-output-end 16 | */ 17 | -------------------------------------------------------------------------------- /validation/preprocessor/preprocessor17.c: -------------------------------------------------------------------------------- 1 | #if 0 2 | /* these should not warn */ 3 | #ifdef ( 4 | #endif 5 | #ifndef ( 6 | #endif 7 | #endif 8 | /* 9 | * check-name: Preprocessor #17 10 | * check-command: sparse -E $file 11 | * check-output-start 12 | 13 | 14 | * check-output-end 15 | */ 16 | -------------------------------------------------------------------------------- /validation/preprocessor/preprocessor2.c: -------------------------------------------------------------------------------- 1 | #define TWO a, b 2 | 3 | #define UNARY(x) BINARY(x) 4 | #define BINARY(x, y) x + y 5 | 6 | UNARY(TWO) 7 | /* 8 | * check-name: Preprocessor #2 9 | * check-command: sparse -E $file 10 | * 11 | * check-output-start 12 | 13 | a + b 14 | * check-output-end 15 | */ 16 | -------------------------------------------------------------------------------- /validation/preprocessor/preprocessor20.c: -------------------------------------------------------------------------------- 1 | #include "preprocessor20.h" 2 | #define X 3 | #define Y 4 | #include "preprocessor20.h" 5 | /* 6 | * check-name: Preprocessor #20 7 | * check-command: sparse -E $file 8 | * 9 | * check-output-start 10 | 11 | A 12 | B 13 | * check-output-end 14 | */ 15 | -------------------------------------------------------------------------------- /validation/preprocessor/preprocessor20.h: -------------------------------------------------------------------------------- 1 | #ifdef X 2 | B 3 | #endif 4 | #ifndef Y 5 | A 6 | #endif 7 | -------------------------------------------------------------------------------- /validation/preprocessor/preprocessor21.c: -------------------------------------------------------------------------------- 1 | #if 1 2 | #if 3 | /* 4 | * check-name: Preprocessor #21 5 | * check-description: This used to hang Sparse. 6 | * check-command: sparse -E $file 7 | * 8 | * check-output-start 9 | 10 | 11 | * check-output-end 12 | * 13 | * check-error-start 14 | preprocessor/preprocessor21.c:2:2: error: unterminated preprocessor conditional 15 | * check-error-end 16 | */ 17 | -------------------------------------------------------------------------------- /validation/preprocessor/preprocessor4.c: -------------------------------------------------------------------------------- 1 | #define foo bar 2 | #define mac(x) x(foo) 3 | 4 | mac(foo) 5 | 6 | /* 7 | * check-name: Preprocessor #4 8 | * check-description: More examples from the comp.std.c discussion. 9 | * check-command: sparse -E $file 10 | * 11 | * check-output-start 12 | 13 | bar(bar) 14 | * check-output-end 15 | */ 16 | -------------------------------------------------------------------------------- /validation/preprocessor/preprocessor5.c: -------------------------------------------------------------------------------- 1 | #define a a| 2 | #define b(x) x 3 | 4 | b(a) 5 | /* 6 | * check-name: Preprocessor #5 7 | * check-description: Yet more examples from comp.std.c. 8 | * check-command: sparse -E $file 9 | * 10 | * check-output-start 11 | 12 | a| 13 | * check-output-end 14 | */ 15 | -------------------------------------------------------------------------------- /validation/preprocessor/preprocessor7.c: -------------------------------------------------------------------------------- 1 | #define A(x) C(B, D 2 | #define D A(1)) 3 | #define C(x,y) E(y) 4 | #define E(y) #y 5 | A(2)) 6 | /* 7 | * check-name: Preprocessor #7 8 | * check-command: sparse -E $file 9 | * 10 | * check-output-start 11 | 12 | "\"D\"" 13 | * check-output-end 14 | */ 15 | -------------------------------------------------------------------------------- /validation/preprocessor/preprocessor9.c: -------------------------------------------------------------------------------- 1 | /* Only # in the input stream marks the beginning of preprocessor command, 2 | * and here we get it from macro expansion. 3 | */ 4 | #define A # define X 1 5 | A 6 | X 7 | /* 8 | * check-name: Preprocessor #9 9 | * check-command: sparse -E $file 10 | * 11 | * check-output-start 12 | 13 | # define X 1 14 | X 15 | * check-output-end 16 | */ 17 | -------------------------------------------------------------------------------- /validation/preprocessor/wide.c: -------------------------------------------------------------------------------- 1 | #define A(x) L##x 2 | A('a') 3 | A("bc") 4 | /* 5 | * check-name: wide char token-pasting 6 | * check-description: Used to cause infinite recursion. 7 | * check-command: sparse -E $file 8 | * 9 | * check-output-start 10 | 11 | L'a' 12 | L"bc" 13 | * check-output-end 14 | */ 15 | 16 | -------------------------------------------------------------------------------- /validation/prototype.c: -------------------------------------------------------------------------------- 1 | static int prototype(void); 2 | 3 | /* 4 | * check-name: Compile skip function prototype 5 | * check-command: sparsec -c $file -o tmp.o 6 | */ 7 | -------------------------------------------------------------------------------- /validation/reassoc/bug-zephyr-63417.c: -------------------------------------------------------------------------------- 1 | extern char __tdata_size[]; 2 | extern char __tdata_align[]; 3 | 4 | unsigned long z_tls_data_size(void); 5 | unsigned long z_tls_data_size(void) 6 | { 7 | return ((unsigned long)__tdata_size) + ((unsigned long)__tdata_align - 1); 8 | } 9 | 10 | /* 11 | * check-name: bug-zephyr-63417 12 | * check-timeout: 13 | */ 14 | -------------------------------------------------------------------------------- /validation/restricted-typeof.c: -------------------------------------------------------------------------------- 1 | typedef unsigned __attribute__((bitwise)) A; 2 | static A x; 3 | static __typeof__(x) y; 4 | static A *p = &y; 5 | /* 6 | * check-name: typeof with bitwise types 7 | * check-command: sparse -Wbitwise $file 8 | */ 9 | -------------------------------------------------------------------------------- /validation/scheck/ko.c: -------------------------------------------------------------------------------- 1 | static void ko(int x) 2 | { 3 | __assert((~x) == (~0 + x)); 4 | } 5 | 6 | /* 7 | * check-name: scheck-ko 8 | * check-command: scheck $file 9 | * check-known-to-fail 10 | */ 11 | -------------------------------------------------------------------------------- /validation/self-quote-args.c: -------------------------------------------------------------------------------- 1 | /* 2 | * check-name: self-quote-args 3 | * check-description: This is testing that the test-suite 4 | * respect the quoting of the command's arguments. 5 | * check-command: sparse '-foption with-spaces' empty-file 6 | * check-output-ignore 7 | */ 8 | -------------------------------------------------------------------------------- /validation/sizeof-bool.c: -------------------------------------------------------------------------------- 1 | static int a(void) 2 | { 3 | return sizeof(_Bool); 4 | } 5 | /* 6 | * check-name: sizeof(_Bool) is valid 7 | * check-description: sizeof(_Bool) was rejected because _Bool is not an even 8 | * number of bytes 9 | * check-command: sparse -Wsizeof-bool $file 10 | * check-error-start 11 | sizeof-bool.c:3:16: warning: expression using sizeof _Bool 12 | * check-error-end 13 | */ 14 | -------------------------------------------------------------------------------- /validation/sizeof-builtin.c: -------------------------------------------------------------------------------- 1 | int test(void); 2 | int test(void) 3 | { 4 | return sizeof &__builtin_trap; 5 | } 6 | 7 | /* 8 | * check-name: sizeof-builtin 9 | * check-command: sparse -Wno-decl $file 10 | * check-known-to-fail 11 | * 12 | * check-error-start 13 | sizeof-function.c:4:16: error: expression using addressof on a builtin function 14 | * check-error-end 15 | */ 16 | -------------------------------------------------------------------------------- /validation/sizeof-compound-postfix.c: -------------------------------------------------------------------------------- 1 | struct foo {int x, y;}; 2 | static int a(void) 3 | { 4 | return sizeof (struct foo){0,1}.y; 5 | } 6 | /* 7 | * check-name: Handling of sizeof compound-literal . member 8 | */ 9 | -------------------------------------------------------------------------------- /validation/sm_compare10.c: -------------------------------------------------------------------------------- 1 | #include "check_debug.h" 2 | 3 | int a, b, c; 4 | static int options_write(void) 5 | { 6 | if (c <= b) 7 | return; 8 | if (a >= b) 9 | return; 10 | __smatch_compare(a, c); 11 | } 12 | 13 | /* 14 | * check-name: smatch compare #10 15 | * check-command: smatch -I.. sm_compare10.c 16 | * 17 | * check-output-start 18 | sm_compare10.c:10 options_write() a < c 19 | * check-output-end 20 | */ 21 | -------------------------------------------------------------------------------- /validation/sm_compare8.c: -------------------------------------------------------------------------------- 1 | #include "check_debug.h" 2 | 3 | void *a, *b; 4 | static int options_write(void) 5 | { 6 | a = b + 1; 7 | __smatch_compare(a, b); 8 | } 9 | 10 | /* 11 | * check-name: smatch compare #8 12 | * check-command: smatch -I.. sm_compare8.c 13 | * 14 | * check-output-start 15 | sm_compare8.c:7 options_write() a > b 16 | * check-output-end 17 | */ 18 | -------------------------------------------------------------------------------- /validation/sm_compare9.c: -------------------------------------------------------------------------------- 1 | #include "check_debug.h" 2 | 3 | void *a, *b; 4 | static int options_write(void) 5 | { 6 | a = b / 2; 7 | __smatch_compare(a, b); 8 | } 9 | 10 | /* 11 | * check-name: smatch compare #9 12 | * check-command: smatch -I.. sm_compare9.c 13 | * 14 | * check-output-start 15 | sm_compare9.c:7 options_write() a < b 16 | * check-output-end 17 | */ 18 | -------------------------------------------------------------------------------- /validation/sm_double_free1.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void func (void) 4 | { 5 | void *x; 6 | 7 | x = malloc(42); 8 | 9 | free(x); 10 | free(x); 11 | 12 | return 0; 13 | } 14 | /* 15 | * check-name: double free test #1 16 | * check-command: smatch sm_double_free1.c 17 | * 18 | * check-output-start 19 | sm_double_free1.c:10 func() error: double free of 'x' 20 | * check-output-end 21 | */ 22 | -------------------------------------------------------------------------------- /validation/sm_loops5.c: -------------------------------------------------------------------------------- 1 | #include "check_debug.h" 2 | 3 | int frob(void); 4 | 5 | int a, b, c; 6 | void test(void) 7 | { 8 | a = 0; 9 | do { 10 | frob(); 11 | } while (a++ < 3); 12 | __smatch_implied(a); 13 | } 14 | /* 15 | * check-name: smatch loops #5 16 | * check-command: smatch -I.. sm_loops5.c 17 | * 18 | * check-output-start 19 | sm_loops5.c:12 test() implied: a = '4' 20 | * check-output-end 21 | */ 22 | -------------------------------------------------------------------------------- /validation/sm_memleak2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void func (void) 4 | { 5 | void *ptr; 6 | 7 | ptr = malloc(42); 8 | ptr = (void *) 0; 9 | 10 | return; 11 | } 12 | /* 13 | * check-name: leak test #2 14 | * check-command: smatch sm_memleak2.c 15 | * 16 | * check-output-start 17 | sm_memleak2.c:8 func() warn: overwrite may leak 'ptr' 18 | * check-output-end 19 | */ 20 | -------------------------------------------------------------------------------- /validation/sm_val_parse1.c: -------------------------------------------------------------------------------- 1 | #include "check_debug.h" 2 | 3 | int main(int x) 4 | { 5 | x = __smatch_type_rl(int, "s32min-s32max[$2 + 4]", 5); 6 | __smatch_implied(x); 7 | 8 | return 0; 9 | } 10 | /* 11 | * check-name: smatch parse value 12 | * check-command: smatch -I.. sm_val_parse1.c 13 | * 14 | * check-output-start 15 | sm_val_parse1.c:6 main() implied: x = '9' 16 | * check-output-end 17 | */ 18 | -------------------------------------------------------------------------------- /validation/smatch_db_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm -f smatch_db.sqlite 4 | 5 | ./build_smatch_db.sh $* 6 | ../smatch $* 7 | 8 | rm smatch_db.sqlite 9 | 10 | -------------------------------------------------------------------------------- /validation/static-forward-decl.c: -------------------------------------------------------------------------------- 1 | int fref(void); 2 | int fref(void) { return 0; } 3 | 4 | static 5 | int floc(void); 6 | int floc(void) { return 0; } 7 | 8 | static 9 | int oloc; 10 | int oloc = 0; 11 | 12 | /* 13 | * check-name: static forward declaration 14 | */ 15 | -------------------------------------------------------------------------------- /validation/strict-prototypes0.c: -------------------------------------------------------------------------------- 1 | extern void func1(); 2 | extern void myfunction(), myfunc2(); 3 | 4 | /* 5 | * check-name: strict-prototypes disabled 6 | * check-command: sparse -Wno-strict-prototypes $file 7 | */ 8 | -------------------------------------------------------------------------------- /validation/struct-as.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Structure members should get the address 3 | * space of their pointer. 4 | */ 5 | #define __user __attribute__((address_space(1))) 6 | 7 | struct hello { 8 | int a; 9 | }; 10 | 11 | extern int test(int __user *ip); 12 | 13 | static int broken(struct hello __user *sp) 14 | { 15 | return test(&sp->a); 16 | } 17 | /* 18 | * check-name: Address space of a struct member 19 | */ 20 | -------------------------------------------------------------------------------- /validation/struct-attribute-placement.c: -------------------------------------------------------------------------------- 1 | struct __attribute__((__aligned__(16))) foo { 2 | int a; 3 | }; 4 | /* 5 | * check-name: struct attribute placement 6 | */ 7 | -------------------------------------------------------------------------------- /validation/struct-size1.c: -------------------------------------------------------------------------------- 1 | struct A; 2 | struct B { 3 | struct A *pA; 4 | }; 5 | struct C; 6 | struct E { 7 | struct A **pA; 8 | struct C *pC; 9 | }; 10 | static void f(struct E *pE, struct B *pB) 11 | { 12 | pB->pA = pE->pA[0]; 13 | } 14 | static const struct { int x; } foo[] = {{ 1 }}; 15 | struct C { 16 | int bar[(sizeof foo/sizeof foo[0])]; 17 | }; 18 | 19 | /* 20 | * check-name: struct size 21 | */ 22 | -------------------------------------------------------------------------------- /validation/type-attribute-mod.c: -------------------------------------------------------------------------------- 1 | #define __noderef __attribute__((noderef)) 2 | 3 | struct s { 4 | int i; 5 | } __noderef; 6 | 7 | 8 | void main(void) 9 | { 10 | struct s s; 11 | 12 | s.i = 0; 13 | } 14 | 15 | /* 16 | * check-name: type-attribute-mod 17 | * 18 | * check-error-start 19 | type-attribute-mod.c:12:9: warning: dereference of noderef expression 20 | * check-error-end 21 | */ 22 | -------------------------------------------------------------------------------- /validation/type-attribute-qual.c: -------------------------------------------------------------------------------- 1 | static const struct s { 2 | int x; 3 | } map[2]; 4 | 5 | static void foo(struct s *p, int v) 6 | { 7 | p->x += v; 8 | } 9 | 10 | /* 11 | * check-name: type-attribute-qual 12 | * check-description: When declaring a type and a variable in the same 13 | * declaration, ensure that type qualifiers apply to the variable 14 | * and not to the type. 15 | */ 16 | -------------------------------------------------------------------------------- /validation/typedef-redef-c89.c: -------------------------------------------------------------------------------- 1 | typedef int int_t; 2 | typedef int int_t; 3 | 4 | /* 5 | * check-name: typedef-redef-c89 6 | * check-command: sparse -std=c89 --pedantic $file 7 | * check-known-to-fail 8 | * 9 | * check-error-start 10 | typedef-redef-c89.c:2:13: warning: redefinition of typedef 'int_t' 11 | typedef-redef-c89.c:1:13: info: originally defined here 12 | * check-error-end 13 | */ 14 | -------------------------------------------------------------------------------- /validation/typedef_shadow.c: -------------------------------------------------------------------------------- 1 | typedef int T; 2 | static void f(int T) 3 | { 4 | static T a; 5 | } 6 | /* 7 | * check-name: typedef shadowing 8 | * check-error-start 9 | typedef_shadow.c:4:16: warning: 'T' has implicit type 10 | typedef_shadow.c:4:18: error: Expected ; at end of declaration 11 | typedef_shadow.c:4:18: error: got a 12 | * check-error-end 13 | */ 14 | -------------------------------------------------------------------------------- /validation/typeof-noderef.c: -------------------------------------------------------------------------------- 1 | #define __noderef __attribute__((noderef)) 2 | 3 | static void test_noderef(void) 4 | { 5 | int __noderef obj, *ptr; 6 | typeof(ptr) ptr2 = ptr; 7 | typeof(*ptr) *ptr3 = ptr; 8 | typeof(obj) *ptr4 = ptr; 9 | ptr = ptr; 10 | ptr = &obj; 11 | } 12 | 13 | /* 14 | * check-name: typeof-noderef 15 | * check-known-to-fail 16 | * 17 | * check-error-start 18 | * check-error-end 19 | */ 20 | -------------------------------------------------------------------------------- /validation/usual-conv-lp32.c: -------------------------------------------------------------------------------- 1 | extern long l; 2 | extern unsigned int u; 3 | 4 | #if __SIZEOF_LONG__ == __SIZEOF_INT__ 5 | _Static_assert([typeof(l + u)] == [unsigned long], "ulong"); 6 | #endif 7 | 8 | /* 9 | * check-name: usual-conversions 10 | * check-command: sparse -m32 $file 11 | */ 12 | -------------------------------------------------------------------------------- /validation/varargs1.c: -------------------------------------------------------------------------------- 1 | extern int foo (const char *, ...); 2 | static void sparse_error(const char err[]) 3 | { 4 | foo("%s\n",err); 5 | } 6 | /* 7 | * check-name: Varargs bogus warning regression test #1 8 | */ 9 | -------------------------------------------------------------------------------- /validation/vla-sizeof0.c: -------------------------------------------------------------------------------- 1 | #define N 2 2 | #define T int 3 | 4 | static unsigned int foo(int x) 5 | { 6 | T a[(1,N)]; 7 | 8 | return sizeof(a) == (N * sizeof(T)); 9 | } 10 | 11 | /* 12 | * check-name: vla-sizeof cte,cte 13 | * check-command: test-linearize -Wvla $file 14 | * 15 | * check-output-ignore 16 | * check-output-contains: ret\\.32 *\\$1 17 | * 18 | * check-error-start 19 | * check-error-end 20 | */ 21 | -------------------------------------------------------------------------------- /validation/wide.c: -------------------------------------------------------------------------------- 1 | static char c = L'\x41'; 2 | static int n = 1/(0x41 - L'\x41'); 3 | /* 4 | * check-name: wide character constants 5 | * 6 | * check-error-start 7 | wide.c:2:17: warning: division by zero 8 | * check-error-end 9 | */ 10 | -------------------------------------------------------------------------------- /version.c: -------------------------------------------------------------------------------- 1 | #include "lib.h" 2 | #include "version.h" 3 | 4 | const char *sparse_version = SPARSE_VERSION; 5 | --------------------------------------------------------------------------------