[llvm-branch-commits] [clang] d942a81 - PR45063: Fix crash on invalid processing an elaborated class template-id

Haojian Wu via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jun 10 02:51:27 PDT 2020


Author: Richard Smith
Date: 2020-06-10T11:46:25+02:00
New Revision: d942a81c71a3f970857e92e98cc6503b61b589b0

URL: https://github.com/llvm/llvm-project/commit/d942a81c71a3f970857e92e98cc6503b61b589b0
DIFF: https://github.com/llvm/llvm-project/commit/d942a81c71a3f970857e92e98cc6503b61b589b0.diff

LOG: PR45063: Fix crash on invalid processing an elaborated class template-id
with an invalid scope specifier.

(cherry picked from commit 44c3a63c74dddeef17e424ec76bd90c8582d8a3c)

Added: 
    

Modified: 
    clang/lib/Sema/SemaTemplate.cpp
    clang/test/Parser/cxx-template-decl.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index c38c724ed9b0..943e8f422a70 100755
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -3817,6 +3817,9 @@ TypeResult Sema::ActOnTagTemplateIdType(TagUseKind TUK,
                                         SourceLocation LAngleLoc,
                                         ASTTemplateArgsPtr TemplateArgsIn,
                                         SourceLocation RAngleLoc) {
+  if (SS.isInvalid())
+    return TypeResult(true);
+
   TemplateName Template = TemplateD.get();
 
   // Translate the parser's template argument list in our AST format.

diff  --git a/clang/test/Parser/cxx-template-decl.cpp b/clang/test/Parser/cxx-template-decl.cpp
index cb8a93fdecb1..3d7a3dc14f4c 100644
--- a/clang/test/Parser/cxx-template-decl.cpp
+++ b/clang/test/Parser/cxx-template-decl.cpp
@@ -269,3 +269,7 @@ namespace AnnotateAfterInvalidTemplateId {
 
   void f() { A<0, 0>::f(); } // expected-error {{ambiguous partial specializations}}
 }
+
+namespace PR45063 {
+  template<class=class a::template b<>> struct X {}; // expected-error {{undeclared identifier 'a'}}
+}


        


More information about the llvm-branch-commits mailing list