Weird clang behaviour wrt identifiers with the same name of builtin functions

This little program fails to compile with clang r74831

$ cat w.c
void f1() {
  int index = 1;
}

static int index;

int f() {
  return index << 2;
}
$ ~/llvm/Debug/bin/clang-cc z.c
z.c:51:12: error: redefinition of 'index' as different kind of symbol
static int index;
           ^
z.c:48:7: note: previous definition is here
  int index = 1;
      ^
z.c:54:16: error: invalid operands to binary expression ('char *(char
const *,
      int)' and 'int')
  return index << 2;
         ~~~~~ ^ ~
3 diagnostics generated.

This seems to happen only with builtin function name and only if there
is a locally scoped variabile with the same name.

It looks very strange to me, I hope someone is able to shed some light
on this failure.

Clang is being too eager when implicitly building declarations for builtins. I've fixed it in r74917. Thanks for the bug report!

  - Doug