Update:
To make it short… the "GCC-Plugin" Technology seems to be "unusable" for
"normal"
educated people like me. The task is very simple, just to suppress a
[-Wincompatible-pointer-types] warning if the condition from the bottom
is fulfilled…
BUT it seems that:
a) no special "callback" is available for ERROR-Handling and
b) to "rewrite" the parse-tree the !! entire !! knowledge of all the gcc
!! internals !!
is required… so - you probably have to invest months++ of study to do
this :-)
→ I think this is the reason why close to NOBODY use it :-)
*** A type has been finished
struct 'A' has size 64 [bits]
*** A type has been finished
struct 'A' has size 64 [bits]
*** A type has been finished
struct 'base' has size 32 [bits]
*** A type has been finished
struct 'base' has size 32 [bits]
test.c: In function ‘main’:
test.c:31:17: warning: passing argument 1 of ‘method_base’ from
incompatible pointer type [-Wincompatible-pointer-types]
31 | method_base(bO, 4);
| ^~
| |
| struct A *
test.c:13:32: note: expected ‘struct base *’ but argument is of type
‘struct A *’
13 | void method_base (struct base* hdl, int val) {
| ~~~~~~~~~~~~~^~~
*** We are about to emit GENERIC after parsing C/C++
*** About to execute a pass
*** About to execute a pass
*** About to execute a pass
*** About to execute a pass
*** About to execute a pass
*** About to execute a pass
*** About to execute a pass
*** About to execute a pass
*** About to execute a pass
*** About to execute a pass
On 17.02.20 09:39, aotto wrote:
Hi,
I discovered the gcc-plugin and I should be able to extend the
existing gcc to
add a feature that "&aObj->obj" == aObj. This mean that I can suppress
the
error message and just to an IMPLICIT Pointer-Cast from (struct A) to
(struct base)
the gcc-plugin-docu is available at:
http://gcc.gnu.org/onlinedocs/gccint/Plugins.html#Plugins
now I missing a good starting point, for example I don't know which
callback I have to call.
→ is probably any help available ?
On 03.02.20 08:21, aotto wrote:
Hi, the following scenario has a "definition hole" in the "C" language
code example:
-------------------------
struct base {
...
};
struct A {
struct base obj;
...
} aObj;
struct B {
struct base obj;
...
} bObj;
void method_base (struct base * hdl, ...);
method_base(&aObj, ...)
method_base(&bObj, ...)
------------------------
- a POINTER to "A" is also a valid POINTER to "base"
- a POINTER to "B" is also a valid POINTER to "base"
- a POINTER to "base" is NOT a valid POINTER to "A" and "B"
I require a solution for this problem WITHOUT forced pointer cast
code and without "void* and type-check" inflation.
The following solutions are acceptable:
1. "gcc" discover by its own that "base" is a "friend" of "A" and "B".
2. add a "frienddef" keyword like "typedef" using:
typedef struct base * baseP;
typedef struct A * aP;
typedef struct P * bP;
frienddef baseP aP;
frienddef baseP bP;
3. add a #PRAGMA to enable/disable this feature
4. add a "gcc" api to easy extend "GCC" without being FORCED
to "hack" the core.
thanks for your help