title: llvm selects first (wrong) local struct definition from two defined in different scopes: is that llvm's bug?
body: <p>I have following example code:</p>
  
  <pre><code>@interface S1 : NSObject
  {
      void(*fn_)();
  }
  @end
  @implementation S1
  - (void) set:(BOOL)f
  {
      if (f)
      {
          struct A { static void f() { std::cout &lt;&lt; "1" &lt;&lt; std::endl; } };
          fn_ = A::f;
      }
      else
      {
          struct A { static void f() { std::cout &lt;&lt; "2" &lt;&lt; std::endl; } };
          fn_ = A::f;
      }
  }
  - (void) test { fn_(); }
  @end
  
  struct S2
  {
      void set(BOOL f)
      {
          if (f)
          {
              struct A { static void f() { std::cout &lt;&lt; "1" &lt;&lt; std::endl; } };
              fn_ = A::f;
          }
          else
          {
              struct A { static void f() { std::cout &lt;&lt; "2" &lt;&lt; std::endl; } };
              fn_ = A::f;
          }
      }
      void test() { fn_(); }
      void(*fn_)();
  };
  
  int main(int argc, const char * argv[])
  {
      auto s1 = [[S1 alloc] init];
      [s1 set:TRUE];
      [s1 test];
      [s1 set:FALSE];
      [s1 test];
  
      S2 s2;
      s2.set(TRUE);
      s2.test();
      s2.set(FALSE);
      s2.test();
  
      return 0;
  }
  </code></pre>
  
  <p>It prints</p>
  
  <pre><code>1
  1
  1
  2
  </code></pre>
  
  <p>but I expecting</p>
  
  <pre><code>1
  2
  1
  2
  </code></pre>
  
  <p>If I change name of second struct to different (e. g. "B"), always works as expected.</p>
  
  <p>No warnings appears, so it's hard to find why your program doesn't work properly.</p>
  
  <p>Is that my ignorance or llvm's bug?</p>