Implement type merging in ASTContext

Patch per subject, adds a method to query for the merged type for two
types. This is necessary in a few places per the C standard, like
redeclarations and conditionals, although the effect is usually pretty
subtle.

I think this patch is pretty close to correct; the one thing I'm
really wondering about is ObjC types. I don't know what the rules for
compatibility for ObjC types are supposed to be, so the current patch
is mostly just guessing. The version attached doesn't cause any
regressions in the testsuite, so I think this gets the basics correct,
but I might be missing some cases. If anyone actually knows the
complete rules, I'd appreciate a patch review or a pointer to the
rules.

-Eli

typemergev1.txt (21 KB)

Patch per subject, adds a method to query for the merged type for two
types. This is necessary in a few places per the C standard, like
redeclarations and conditionals, although the effect is usually pretty
subtle.

Ok

I think this patch is pretty close to correct; the one thing I'm
really wondering about is ObjC types. I don't know what the rules for
compatibility for ObjC types are supposed to be, so the current patch
is mostly just guessing. The version attached doesn't cause any
regressions in the testsuite, so I think this gets the basics correct,
but I might be missing some cases. If anyone actually knows the
complete rules, I'd appreciate a patch review or a pointer to the
rules.

It looks pretty reasonable to me, but I didn't scrutinize the logic. If you think it is a step forward in the current codebase (towards correctness) plz feel free to commit it, even if not perfect.

-Chris