[cfe-commits] r65489 - in /cfe/trunk: include/clang/AST/DeclBase.h lib/AST/DeclBase.cpp test/SemaTemplate/class-template-spec.cpp

Douglas Gregor dgregor at apple.com
Wed Feb 25 16:02:51 PST 2009


Author: dgregor
Date: Wed Feb 25 18:02:51 2009
New Revision: 65489

URL: http://llvm.org/viewvc/llvm-project?rev=65489&view=rev
Log:
Use RecordFirst/RecordLast range checks in DeclContext

Modified:
    cfe/trunk/include/clang/AST/DeclBase.h
    cfe/trunk/lib/AST/DeclBase.cpp
    cfe/trunk/test/SemaTemplate/class-template-spec.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=65489&r1=65488&r2=65489&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Wed Feb 25 18:02:51 2009
@@ -440,7 +440,7 @@
   }
 
   bool isRecord() const {
-    return DeclKind == Decl::Record || DeclKind == Decl::CXXRecord;
+    return DeclKind >= Decl::RecordFirst && DeclKind <= Decl::RecordLast;
   }
 
   bool isNamespace() const {

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=65489&r1=65488&r2=65489&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Wed Feb 25 18:02:51 2009
@@ -409,7 +409,7 @@
     return true; // FIXME: Check for C++0x scoped enums
   else if (DeclKind == Decl::LinkageSpec)
     return true;
-  else if (DeclKind == Decl::Record || DeclKind == Decl::CXXRecord)
+  else if (DeclKind >= Decl::RecordFirst && DeclKind <= Decl::RecordLast)
     return cast<RecordDecl>(this)->isAnonymousStructOrUnion();
   else if (DeclKind == Decl::Namespace)
     return false; // FIXME: Check for C++0x inline namespaces

Modified: cfe/trunk/test/SemaTemplate/class-template-spec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/class-template-spec.cpp?rev=65489&r1=65488&r2=65489&view=diff

==============================================================================
--- cfe/trunk/test/SemaTemplate/class-template-spec.cpp (original)
+++ cfe/trunk/test/SemaTemplate/class-template-spec.cpp Wed Feb 25 18:02:51 2009
@@ -37,11 +37,19 @@
 
 typedef int int_type;
 void testme(X<int_type> *x1, X<float, int> *x2) { 
-  x1->foo(); // okay: refers to #1
-  x2->bar(); // okay: refers to #2
+  (void)x1->foo(); // okay: refers to #1
+  (void)x2->bar(); // okay: refers to #2
 }
 
-// Diagnose specializations in a different namespace
+// Make sure specializations are proper classes.
+template<>
+struct A<char> {
+  A();
+};
+
+A<char>::A() { }
+
+// Diagnose specialization errors
 struct A<double> { }; // expected-error{{template specialization requires 'template<>'}}
 
 template<typename T> // expected-error{{class template partial specialization is not yet supported}}
@@ -72,3 +80,4 @@
 template<> struct N::B<char> { 
   int testf(int x) { return f(x); }
 };
+





More information about the cfe-commits mailing list