Clang is right.
Paragraph 6.5.4/1 of the C++11 Standard defines the range-based for statement as follows:
For a range-based for statement of the form
for ( for-range-declaration : expression ) statement
let range-init be equivalent to the expression surrounded by parentheses
( expression )
and for a range-based for statement of the form
for ( for-range-declaration : braced-init-list ) statement
let range-init be equivalent to the braced-init-list. In each case, a range-based for statement is equivalent
to
{
auto && __range = range-init;
for ( auto __begin = begin-expr,
__end = end-expr;
__begin != __end;
++__begin ) {
for-range-declaration = *__begin;
statement
}
}
From the above, it is visible that variable b, which corresponds to the for-range-declaration, is declared inside a nested block statement, while the initializer range-init (which corresponds to b.nums) appears in the parent scope, where b should resolve to the object of type bar.