From: Matt Beaumont-Gay Date: Thu, 25 Aug 2011 23:22:24 +0000 (+0000) Subject: Fix a crash-on-invalid. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3a51d418b267c2b302f1f6a10273049c6ce95e2b;p=clang Fix a crash-on-invalid. Much to everyone's surprise, the default constructor for TypeResult produces an instance with Invalid == false. This seems like a decision we may want to revisit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138601 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index a7d74ce7e8..c3d155cc84 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -2131,7 +2131,7 @@ TypeResult Sema::ActOnTagTemplateIdType(TagUseKind TUK, QualType Result = CheckTemplateIdType(Template, TemplateLoc, TemplateArgs); if (Result.isNull()) - return TypeResult(); + return TypeResult(true); // Check the tag kind if (const RecordType *RT = Result->getAs()) { diff --git a/test/SemaTemplate/missing-class-keyword-crash.cpp b/test/SemaTemplate/missing-class-keyword-crash.cpp new file mode 100644 index 0000000000..f0eee2ba2f --- /dev/null +++ b/test/SemaTemplate/missing-class-keyword-crash.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +class G {}; +template // expected-error{{unknown type name 'Foo'}} \ + // expected-note{{template parameter is declared here}} +class Bar {}; + +class Bar blah_test; // expected-error{{template argument for non-type template parameter must be an expression}}