In the testcase, the using-declaration was confusing namespace comparison into thinking that we were instantiating a template from an enclosing namespace. Given using-declarations, we need to wait until we've chosen a template before donig this comparison. Tested x86_64-pc-linux-gnu, applying to trunk.