From: Eli Friedman Date: Sat, 13 Jun 2009 04:51:30 +0000 (+0000) Subject: Fix for PR4382: allow instantiating dependent nested name specifiers. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=923f7534c529be478826f3d390d70dd8575dfd72;p=clang Fix for PR4382: allow instantiating dependent nested name specifiers. I'm not completely sure this is the right way to fix this issue, but it seems reasonable, and it's consistent with the non-template code for this construct. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73285 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index 1fd11147ed..4d03e79c65 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -1014,7 +1014,7 @@ Sema::InstantiateNestedNameSpecifier(NestedNameSpecifier *NNS, if (T.isNull()) return 0; - if (T->isRecordType() || + if (T->isDependentType() || T->isRecordType() || (getLangOptions().CPlusPlus0x && T->isEnumeralType())) { assert(T.getCVRQualifiers() == 0 && "Can't get cv-qualifiers here"); return NestedNameSpecifier::Create(Context, Prefix, diff --git a/test/SemaTemplate/instantiate-dependent-nested-name.cpp b/test/SemaTemplate/instantiate-dependent-nested-name.cpp new file mode 100644 index 0000000000..2b1d29878a --- /dev/null +++ b/test/SemaTemplate/instantiate-dependent-nested-name.cpp @@ -0,0 +1,7 @@ +// RUN: clang-cc -fsyntax-only -verify %s +// PR4382 +template struct X { static const T A = 1; }; +template::A> struct Y { typedef T A; }; +template struct Z { typedef typename Y::A A; }; +extern int x; +extern Z::A x; diff --git a/test/SemaTemplate/metafun-apply.cpp b/test/SemaTemplate/metafun-apply.cpp index 7bc971f24b..9261ed6a6c 100644 --- a/test/SemaTemplate/metafun-apply.cpp +++ b/test/SemaTemplate/metafun-apply.cpp @@ -23,8 +23,7 @@ struct bogus { template struct apply1 { typedef typename MetaFun::template apply::type type; // expected-note{{in instantiation of template class 'struct add_reference::apply' requested here}} \ - // expected-error{{'apply' following the 'template' keyword does not refer to a template}} \ - // FIXME: expected-error{{type 'MetaFun::template apply' cannot be used prior to '::' because it has no members}} + // expected-error{{'apply' following the 'template' keyword does not refer to a template}} }; int i; @@ -36,8 +35,7 @@ void test() { apply1::type t; // expected-note{{in instantiation of template class 'struct apply1' requested here}} \ // FIXME: expected-error{{unexpected type name 'type': expected expression}} - apply1::type t2; // expected-note{{in instantiation of template class 'struct apply1' requested here}} \ - // FIXME: expected-error{{unexpected type name 'type': expected expression}} + apply1::type t2; // expected-note{{in instantiation of template class 'struct apply1' requested here}} }