mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-08-17 08:39:54 +00:00
Fixed bug #402, getting confused with __attribute__ directives with spacing.
This commit is contained in:
@@ -121,7 +121,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
" my_realloc(void*, size_t) __attribute__((alloc_size(2)));\n" +
|
||||
"extern int\n" +
|
||||
" my_printf (void *my_object, const char *my_format, ...)\n" +
|
||||
" __attribute__ ((format (printf, 2, 3)));\n" +
|
||||
" __attribute__ ( (format (printf, 2, 3)) );\n" +
|
||||
" void __attribute__ ((interrupt)) universal_handler ();\n"
|
||||
|
||||
expected =
|
||||
@@ -2755,6 +2755,28 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
assert_equal(expected, @parser.transform_inline_functions(source))
|
||||
end
|
||||
|
||||
it "Transform inline functions using gnu attribute notation" do
|
||||
source =
|
||||
"static __inline__ __attribute__ ((always_inline)) uint16_t _somefunc (uint32_t a)\n" +
|
||||
"{\n" +
|
||||
" return _someotherfunc (a);\n" +
|
||||
"}\n" +
|
||||
"static __attribute__ (( always_inline )) uint16_t _somefunc_0 (uint32_t a)\n" +
|
||||
"{\n" +
|
||||
" return (uint16_t) a;\n" +
|
||||
"}\n" +
|
||||
"\n"
|
||||
|
||||
expected =
|
||||
"uint16_t _somefunc (uint32_t a);\n" +
|
||||
"uint16_t _somefunc_0 (uint32_t a);\n" +
|
||||
"\n"
|
||||
|
||||
@parser.treat_inlines = :include
|
||||
@parser.inline_function_patterns = ['(?:static\s*)?(?:__inline__)?__attribute__\s*\([ (]*always_inline[ )]*\)', 'static __inline__']
|
||||
assert_equal(expected, @parser.transform_inline_functions(source))
|
||||
end
|
||||
|
||||
it "Transform inline functions takes user provided patterns into account" do
|
||||
source =
|
||||
"static __inline__ __attribute__ ((always_inline)) uint16_t _somefunc (uint32_t a)\n" +
|
||||
|
||||
Reference in New Issue
Block a user