On 12/16/2012 05:54 PM, Rafael Espíndola wrote:
In the c++ case the difference is that we use the canonical decl, so we
will need a different way to test this.

I think I have a fix, but it depends on the patch I posted yesterday
fixing tentative definitions. I also need a testcase I can include in
the clang test suite. A file that currently has an incorrect error or
warning would be ideal, but a unit test will do.

Would you mind making a test out of your visitor?

Not a viable alternative.

I tried to produce a -Wunused-variable warning with the following code:
======================
static int y;

int* inner() {
  extern int y;
  return &y;
}
======================

and a failing run-time testcase as follows
======================
static int y;

int* outer() {
  return &y;
}

int* inner() {
  extern int y;
  return &y;
}

int main() {
  return (outer() == inner()) ? 0 : 1;
}
======================

but in both cases clang behaves "correctly" (just because the second declaration of y has the first one as its canonical decl).

So, we have a canonical declaration having internal linkage and a later redeclaration of the same entity having external linkage. Shouldn't this be *always* wrong? I mean, would it be possible to add an assertion in clang checking that, when a redeclaration is chained to previous ones, the corresponding linkages are "compatible"?

Enea.

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to