From 65100792a69a16895bd80f1d639b99e7ad903386 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 26 Feb 2009 00:02:51 +0000 Subject: [PATCH] Use RecordFirst/RecordLast range checks in DeclContext git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65489 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/DeclBase.h | 2 +- lib/AST/DeclBase.cpp | 2 +- test/SemaTemplate/class-template-spec.cpp | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 1357a8eaac..ff8a1c1323 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -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 { diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 20139d7bb2..d6a0c35d92 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -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(this)->isAnonymousStructOrUnion(); else if (DeclKind == Decl::Namespace) return false; // FIXME: Check for C++0x inline namespaces diff --git a/test/SemaTemplate/class-template-spec.cpp b/test/SemaTemplate/class-template-spec.cpp index 15c797a5da..e4900838f1 100644 --- a/test/SemaTemplate/class-template-spec.cpp +++ b/test/SemaTemplate/class-template-spec.cpp @@ -37,11 +37,19 @@ template <> struct X { int bar(); }; // #2 typedef int int_type; void testme(X *x1, X *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 { + A(); +}; + +A::A() { } + +// Diagnose specialization errors struct A { }; // expected-error{{template specialization requires 'template<>'}} template // expected-error{{class template partial specialization is not yet supported}} @@ -72,3 +80,4 @@ namespace M { template<> struct N::B { int testf(int x) { return f(x); } }; +