]> granicus.if.org Git - clang/commitdiff
Tests and fixes for templates declared within (non-template)
authorDouglas Gregor <dgregor@apple.com>
Fri, 27 Mar 2009 04:21:56 +0000 (04:21 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 27 Mar 2009 04:21:56 +0000 (04:21 +0000)
classes. Test case from Anders Carlsson, fix from Piotr Rak!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67817 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaLookup.cpp
test/SemaTemplate/nested-template.cpp [new file with mode: 0644]

index 616ee3dd932ea6e43d070c43ccd401362bd09f52..770f9301e616ea92cd8d8c262bbe48adc3fb6e84 100644 (file)
@@ -600,10 +600,11 @@ Sema::CppLookupName(Scope *S, DeclarationName Name,
       // base classes, we never need to perform qualified lookup
       // because all of the members are on top of the identifier
       // chain.
-      if (isa<RecordDecl>(Ctx) &&
-          (R = LookupQualifiedName(Ctx, Name, NameKind, RedeclarationOnly)))
-        return std::make_pair(true, R);
-
+      if (isa<RecordDecl>(Ctx)) {
+        R = LookupQualifiedName(Ctx, Name, NameKind, RedeclarationOnly);
+        if (R || RedeclarationOnly)
+          return std::make_pair(true, R);
+      }
       if (Ctx->getParent() != Ctx->getLexicalParent()) {
         // It is out of line defined C++ method or struct, we continue
         // doing name lookup in parent context. Once we will find namespace
@@ -611,8 +612,8 @@ Sema::CppLookupName(Scope *S, DeclarationName Name,
         // using-directives later.
         for (OutOfLineCtx = Ctx; OutOfLineCtx && !OutOfLineCtx->isFileContext();
              OutOfLineCtx = OutOfLineCtx->getParent()) {
-          if ((R = LookupQualifiedName(OutOfLineCtx, Name, NameKind,
-                                      RedeclarationOnly)))
+          R = LookupQualifiedName(OutOfLineCtx, Name, NameKind, RedeclarationOnly);
+          if (R || RedeclarationOnly)
             return std::make_pair(true, R);
         }
       }
diff --git a/test/SemaTemplate/nested-template.cpp b/test/SemaTemplate/nested-template.cpp
new file mode 100644 (file)
index 0000000..bd9e89f
--- /dev/null
@@ -0,0 +1,16 @@
+// RUN: clang-cc -fsyntax-only %s
+
+class A;
+
+class S {
+public:
+   template<typename T> struct A { 
+     struct Nested {
+       typedef T type;
+     };
+   };
+};
+
+int i;
+S::A<int>::Nested::type *ip = &i;
+