]> granicus.if.org Git - clang/commitdiff
Don't set out-of-line template specialization/definition information
authorDouglas Gregor <dgregor@apple.com>
Wed, 28 Jul 2010 23:59:57 +0000 (23:59 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 28 Jul 2010 23:59:57 +0000 (23:59 +0000)
for AST nodes that aren't actually out-of-line (i.e., require a
nested-name-specifier). Fixes <rdar://problem/8204126>.

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

lib/Sema/SemaDecl.cpp
lib/Sema/SemaTemplate.cpp
test/SemaTemplate/crash-8204126.cpp [new file with mode: 0644]

index 1788eb77226299adaefeef93895884df7c6ba30a..1836c47fdc7a16093ce024847f9b1afb42eed7ce 100644 (file)
@@ -2617,7 +2617,7 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
 
   SetNestedNameSpecifier(NewVD, D);
 
-  if (NumMatchedTemplateParamLists > 0) {
+  if (NumMatchedTemplateParamLists > 0 && D.getCXXScopeSpec().isSet()) {
     NewVD->setTemplateParameterListsInfo(Context,
                                          NumMatchedTemplateParamLists,
                         (TemplateParameterList**)TemplateParamLists.release());
@@ -3216,7 +3216,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
     }
   }
 
-  if (NumMatchedTemplateParamLists > 0) {
+  if (NumMatchedTemplateParamLists > 0 && D.getCXXScopeSpec().isSet()) {
     NewFD->setTemplateParameterListsInfo(Context,
                                          NumMatchedTemplateParamLists,
                         (TemplateParameterList**)TemplateParamLists.release());
index 03e5281d836818ce1bdc25778d0e54a0ba9203ee..d6672df3f4fa27432c74b6742af540a3b803acc5 100644 (file)
@@ -3819,7 +3819,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
                                                        PrevPartial,
                                                        SequenceNumber);
     SetNestedNameSpecifier(Partial, SS);
-    if (NumMatchedTemplateParamLists > 0) {
+    if (NumMatchedTemplateParamLists > 0 && SS.isSet()) {
       Partial->setTemplateParameterListsInfo(Context,
                                              NumMatchedTemplateParamLists,
                     (TemplateParameterList**) TemplateParameterLists.release());
@@ -3877,7 +3877,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
                                                 Converted,
                                                 PrevDecl);
     SetNestedNameSpecifier(Specialization, SS);
-    if (NumMatchedTemplateParamLists > 0) {
+    if (NumMatchedTemplateParamLists > 0 && SS.isSet()) {
       Specialization->setTemplateParameterListsInfo(Context,
                                                   NumMatchedTemplateParamLists,
                     (TemplateParameterList**) TemplateParameterLists.release());
diff --git a/test/SemaTemplate/crash-8204126.cpp b/test/SemaTemplate/crash-8204126.cpp
new file mode 100644 (file)
index 0000000..eb96560
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct A
+{
+  template<int> template<typename T> friend void foo(T) {} // expected-error{{extraneous template parameter list}}
+  void bar() { foo(0); } // expected-error{{use of undeclared identifier 'foo'}}
+};