Fixed another type of function pointer getting falsely identified as a function.

This commit is contained in:
Mark VanderVoord
2026-06-30 11:17:09 -04:00
parent a25354f659
commit 1724a4d0a2
2 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -330,7 +330,7 @@ class CMockHeaderParser
source.gsub!(/(^|\W+)(?:#{@c_strippables.join('|')})(?=$|\W+)/, '\1') unless @c_strippables.empty? # remove known attributes slated to be stripped
# scan standalone function pointers and remove them, because they can just be ignored
source.gsub!(/\w+\s*\(\s*\*\s*\w+\s*\)\s*\([^)]*\)\s*;/, ';')
source.gsub!(/[\w][\w\s*]*\(\s*\*\s*\w+\s*\)\s*\([^)]*\)\s*;/, ';')
# scan for functions which return function pointers, because they are a pain
source.gsub!(/([\w\s*]+)\(*\(\s*\*([\w\s*]+)\s*\(([\w\s*,]*)\)\)\s*\(([\w\s*,]*)\)\)*/) do |_m|
+11
View File
@@ -387,6 +387,17 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
end
it "ignore function pointer variables with pointer return types and not treat them as function prototypes" do
source =
"struct_t * (*func)(some_argument);\n" +
"void real_func(int a);\n"
expected = ["void real_func(int a)"]
assert_equal(expected, @parser.import_source(source, @test_project).map! { |s| s.strip })
end
it "remove struct statements" do
source =
"struct _NamedStruct1 {\n" +