]> granicus.if.org Git - clang/commitdiff
Be a little more careful when trying to extract a TypeDecl from a enum/class/struct...
authorDouglas Gregor <dgregor@apple.com>
Thu, 5 Nov 2009 20:54:04 +0000 (20:54 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 5 Nov 2009 20:54:04 +0000 (20:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86171 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaType.cpp
test/SemaTemplate/class-template-decl.cpp

index f003127f149f11219dcb63c89a5fed04c7f462b4..93ef1ea2ead5bde23600cc1729a5c4ce84161345 100644 (file)
@@ -229,7 +229,8 @@ static QualType ConvertDeclSpecToType(Declarator &TheDeclarator, Sema &TheSema){
   case DeclSpec::TST_enum:
   case DeclSpec::TST_union:
   case DeclSpec::TST_struct: {
-    TypeDecl *D = cast_or_null<TypeDecl>(static_cast<Decl *>(DS.getTypeRep()));
+    TypeDecl *D 
+      = dyn_cast_or_null<TypeDecl>(static_cast<Decl *>(DS.getTypeRep()));
     if (!D) {
       // This can happen in C++ with ambiguous lookups.
       Result = Context.IntTy;
index 8c717ea16e18ed0a86da9c5776aa042faa420b75..a8163127b00000cab70a37cf4c6d9a947ff1d1da 100644 (file)
@@ -49,3 +49,5 @@ public:
 void f() {
   template<typename T> class X; // expected-error{{expression}}
 }
+
+template<typename T> class X1 { } var; // expected-error{{declared as a template}}