]> granicus.if.org Git - clang/commitdiff
Use RecordFirst/RecordLast range checks in DeclContext
authorDouglas Gregor <dgregor@apple.com>
Thu, 26 Feb 2009 00:02:51 +0000 (00:02 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 26 Feb 2009 00:02:51 +0000 (00:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65489 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclBase.h
lib/AST/DeclBase.cpp
test/SemaTemplate/class-template-spec.cpp

index 1357a8eaacfdd037aefe6d31d118c9f43a471205..ff8a1c1323b2d6c78e0d8ae0fe76b8e1886ad991 100644 (file)
@@ -440,7 +440,7 @@ public:
   }
 
   bool isRecord() const {
-    return DeclKind == Decl::Record || DeclKind == Decl::CXXRecord;
+    return DeclKind >= Decl::RecordFirst && DeclKind <= Decl::RecordLast;
   }
 
   bool isNamespace() const {
index 20139d7bb2312a2fe92318063fed6e47c66c5b18..d6a0c35d92897d7cb65c470c14bf930ee1e2152b 100644 (file)
@@ -409,7 +409,7 @@ bool DeclContext::isTransparentContext() const {
     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
index 15c797a5daf46efcf05ed8035138f19cf9d91251..e4900838f114f311957a001c6aeacc2c98ad9782 100644 (file)
@@ -37,11 +37,19 @@ template <> struct X<float> { int bar(); };  // #2
 
 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 @@ namespace M {
 template<> struct N::B<char> { 
   int testf(int x) { return f(x); }
 };
+