[Bug 24995] New: Evaluating a variable shadowed inside a block gets ambiguity error since r247836

Bug ID 24995
Summary Evaluating a variable shadowed inside a block gets ambiguity error since r247836
Product lldb
Version unspecified
Hardware PC
OS All
Status NEW
Severity normal
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter dawn+bugzilla@burble.org
CC llvm-bugs@lists.llvm.org
Classification Unclassified

If an identifier is shadowed inside a block, evaluating the identifier gets an
ambiguity error.  This started with lldb r247836.  (Note: test case was tested
with clang based on svn 3.4, 3.6 and trunk on OSX).

Run to BPs as indicated in the test cases below and evaluate my_val.  You get:

   (lldb) p my_val
   error: reference to 'my_val' is ambiguous
   note: candidate found by name lookup is 'my_val'
   note: candidate found by name lookup is 'my_val'
   error: 1 errors parsing expression

Test case 1:
    #include <stdio.h>
    int make_used;
    int main() {
        static int my_val = 103;
        {
            static int my_val = 101;
            make_used += my_val;
        }
        // Set BP1, eval my_val, Exp: 103 Act: ambiguous
        printf("\neval @BP1 line=%d: my_val = %d", __LINE__, my_val);
        return make_used == 0;
    }

Test case 2:
    #include <stdio.h>
    int make_used;
    namespace NS {
        static int my_val = 2112;
        static void NSFunc(void) {
            make_used += my_val;
        }
    }
    int main() {
        {
            using namespace NS;
            // Set BP2, eval my_val, Exp: 2112 Act: ambiguous
            printf("\neval @BP2 line=%d: my_val = %d", __LINE__, my_val);
        }
        return make_used == 0;
    }