diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-03-27 23:10:48 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-03-27 23:10:48 +0000 |
commit | 333489bba35d91e4ddb101f441087177c492d090 (patch) | |
tree | 6b658646aed7c601a730536e09816cecc7ff0c65 /clang/lib/Sema/SemaCXXScopeSpec.cpp | |
parent | 669f1d0b0b7ab0fd05f4cf672eab6dbe3f358953 (diff) | |
download | bcm5719-llvm-333489bba35d91e4ddb101f441087177c492d090.tar.gz bcm5719-llvm-333489bba35d91e4ddb101f441087177c492d090.zip |
Initial implementation of parsing, semantic analysis, and template
instantiation for C++ typename-specifiers such as
typename T::type
The parsing of typename-specifiers is relatively easy thanks to
annotation tokens. When we see the "typename", we parse the
typename-specifier and produce a typename annotation token. There are
only a few places where we need to handle this. We currently parse the
typename-specifier form that terminates in an identifier, but not the
simple-template-id form, e.g.,
typename T::template apply<U, V>
Parsing of nested-name-specifiers has a similar problem, since at this
point we don't have any representation of a class template
specialization whose template-name is unknown.
Semantic analysis is only partially complete, with some support for
template instantiation that works for simple examples.
llvm-svn: 67875
Diffstat (limited to 'clang/lib/Sema/SemaCXXScopeSpec.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCXXScopeSpec.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaCXXScopeSpec.cpp b/clang/lib/Sema/SemaCXXScopeSpec.cpp index 8fb2811ce51..a879989b33d 100644 --- a/clang/lib/Sema/SemaCXXScopeSpec.cpp +++ b/clang/lib/Sema/SemaCXXScopeSpec.cpp @@ -127,17 +127,20 @@ Sema::CXXScopeTy *Sema::ActOnCXXNestedNameSpecifier(Scope *S, if (TypeDecl *Type = dyn_cast<TypeDecl>(SD)) { // Determine whether we have a class (or, in C++0x, an enum) or // a typedef thereof. If so, build the nested-name-specifier. - QualType T; - if (TypedefDecl *TD = dyn_cast<TypedefDecl>(SD)) { + QualType T = Context.getTypeDeclType(Type); + bool AcceptableType = false; + if (T->isDependentType()) + AcceptableType = true; + else if (TypedefDecl *TD = dyn_cast<TypedefDecl>(SD)) { if (TD->getUnderlyingType()->isRecordType() || (getLangOptions().CPlusPlus0x && TD->getUnderlyingType()->isEnumeralType())) - T = Context.getTypeDeclType(TD); + AcceptableType = true; } else if (isa<RecordDecl>(Type) || (getLangOptions().CPlusPlus0x && isa<EnumDecl>(Type))) - T = Context.getTypeDeclType(Type); + AcceptableType = true; - if (!T.isNull()) + if (AcceptableType) return NestedNameSpecifier::Create(Context, Prefix, false, T.getTypePtr()); } |