On Sep 11, 2012, at 7:31 AM, Rafael Espíndola <[email protected]>
wrote:
> I am not sure if we have to handle more complicated "wrappings" of
> CXXConstructExpr, but this patch fixes the included testcase.
The logic of this routine is fairly broken. It's trying to find an object
construction (which is doesn't do correctly, even after your patch) and using
that to blacklist all of the ill-formed patterns, rather than detecting based
on the type and then white-listing the few exceptions.
It should really check for the valid cases directly (scalar/vector types are
okay, class types are okay when we're using the trivial default ctor and the
dtor is trivial) and fail with a generic error if our type is not one of those
valid cases. That way, the restricted form of the checking for CXXConstructExpr
that's currently being used will suffice for detecting the "constructed with
trivial constructor" case.
Here's a tweaked version of your test case that Clang still accepts, even after
your patch, and illustrates just how broken this code is:
namespace pr13812 {
struct C {
C(int x);
~C();
};
void f(void **ip) {
static void *ips[] = { &&l0 };
const C c0 = 17;
l0:
const C &c1 = 42;
const C &c2 = c0;
goto *ip;
}
}
- Doug
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits