mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-09-13 21:59:58 +00:00
Protect against function-looking structs (Fixes #513)
This commit is contained in:
@@ -253,7 +253,7 @@ class CMockHeaderParser
|
||||
# enums, unions, structs, and typedefs can all contain things (e.g. function pointers) that parse like function prototypes, so yank them
|
||||
# forward declared structs are removed before struct definitions so they don't mess up real thing later. we leave structs keywords in function prototypes
|
||||
source.gsub!(/^[\w\s]*struct[^;{}()]+;/m, '') # remove forward declared structs
|
||||
source.gsub!(/^[\w\s]*(enum|union|struct|typedef)[\w\s]*\{[^}]+\}[\w\s*,]*;/m, '') # remove struct, union, and enum definitions and typedefs with braces
|
||||
source.gsub!(/^[\w\s]*(enum|union|struct|typedef)[\w\s()]*\{[^}]+\}[\w\s*,]*;/m, '') # remove struct, union, and enum definitions and typedefs with braces
|
||||
# remove problem keywords
|
||||
source.gsub!(/(\W)(?:register|auto|restrict)(\W)/, '\1\2')
|
||||
source.gsub!(/(\W)(?:static)(\W)/, '\1\2') unless cpp
|
||||
|
||||
@@ -111,3 +111,8 @@ inline int stuff(int num)
|
||||
}
|
||||
return reg;
|
||||
}
|
||||
|
||||
/* it seems like CMock didn't love a func-looking struct before a func */
|
||||
#define FOO_TYPE(a) foo_##a
|
||||
struct FOO_TYPE(bar) { int baz; };
|
||||
char b(void);
|
||||
|
||||
Reference in New Issue
Block a user