[cfe-commits] r137799 - in /cfe/trunk: lib/AST/DeclBase.cpp lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriterDecl.cpp test/PCH/cxx-ms-function-specialization-class-scope.cpp test/PCH/cxx-ms-function-specialization-class-scope.h
Francois Pichet
pichet2000 at gmail.com
Tue Aug 16 18:06:54 PDT 2011
Author: fpichet
Date: Tue Aug 16 20:06:54 2011
New Revision: 137799
URL: http://llvm.org/viewvc/llvm-project?rev=137799&view=rev
Log:
Add serialization support for ClassScopeFunctionSpecializationDecl.
Added:
cfe/trunk/test/PCH/cxx-ms-function-specialization-class-scope.cpp
cfe/trunk/test/PCH/cxx-ms-function-specialization-class-scope.h
Modified:
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=137799&r1=137798&r2=137799&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Tue Aug 16 20:06:54 2011
@@ -628,7 +628,8 @@
isa<ParmVarDecl>(this) ||
// FIXME: a ClassTemplateSpecialization or CXXRecordDecl can have
// AS_none as access specifier.
- isa<CXXRecordDecl>(this))
+ isa<CXXRecordDecl>(this) ||
+ isa<ClassScopeFunctionSpecializationDecl>(this))
return;
assert(Access != AS_none &&
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=137799&r1=137798&r2=137799&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue Aug 16 20:06:54 2011
@@ -123,6 +123,8 @@
ClassTemplateSpecializationDecl *D);
void VisitClassTemplatePartialSpecializationDecl(
ClassTemplatePartialSpecializationDecl *D);
+ void VisitClassScopeFunctionSpecializationDecl(
+ ClassScopeFunctionSpecializationDecl *D);
void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D);
void VisitValueDecl(ValueDecl *VD);
void VisitEnumConstantDecl(EnumConstantDecl *ECD);
@@ -1215,6 +1217,12 @@
}
}
+void ASTDeclReader::VisitClassScopeFunctionSpecializationDecl(
+ ClassScopeFunctionSpecializationDecl *D) {
+ VisitDecl(D);
+ D->Specialization = ReadDeclAs<CXXMethodDecl>(Record, Idx);
+}
+
void ASTDeclReader::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
VisitRedeclarableTemplateDecl(D);
Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=137799&r1=137798&r2=137799&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Tue Aug 16 20:06:54 2011
@@ -65,6 +65,8 @@
ClassTemplateSpecializationDecl *D);
void VisitClassTemplatePartialSpecializationDecl(
ClassTemplatePartialSpecializationDecl *D);
+ void VisitClassScopeFunctionSpecializationDecl(
+ ClassScopeFunctionSpecializationDecl *D);
void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D);
void VisitValueDecl(ValueDecl *D);
void VisitEnumConstantDecl(EnumConstantDecl *D);
@@ -1109,6 +1111,14 @@
Code = serialization::DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION;
}
+void ASTDeclWriter::VisitClassScopeFunctionSpecializationDecl(
+ ClassScopeFunctionSpecializationDecl *D) {
+ VisitDecl(D);
+ Writer.AddDeclRef(D->getSpecialization(), Record);
+ Code = serialization::DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION;
+}
+
+
void ASTDeclWriter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
VisitRedeclarableTemplateDecl(D);
Added: cfe/trunk/test/PCH/cxx-ms-function-specialization-class-scope.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-ms-function-specialization-class-scope.cpp?rev=137799&view=auto
==============================================================================
--- cfe/trunk/test/PCH/cxx-ms-function-specialization-class-scope.cpp (added)
+++ cfe/trunk/test/PCH/cxx-ms-function-specialization-class-scope.cpp Tue Aug 16 20:06:54 2011
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fms-extensions -triple i386-unknown-unknown -x c++-header -emit-pch -o %t %S/cxx-ms-function-specialization-class-scope.h
+// RUN: %clang_cc1 -fms-extensions -triple i386-unknown-unknown -include-pch %t -fsyntax-only -verify %s
+
+
+void test2()
+{
+ B<char> b(3);
+ char* ptr;
+ b.f(ptr);
+ b.f<int>(99);
+ b.f(100);
+}
+
Added: cfe/trunk/test/PCH/cxx-ms-function-specialization-class-scope.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-ms-function-specialization-class-scope.h?rev=137799&view=auto
==============================================================================
--- cfe/trunk/test/PCH/cxx-ms-function-specialization-class-scope.h (added)
+++ cfe/trunk/test/PCH/cxx-ms-function-specialization-class-scope.h Tue Aug 16 20:06:54 2011
@@ -0,0 +1,29 @@
+
+
+
+template <class T>
+class B {
+public:
+ template <class U>
+ B(U p) {
+ }
+ template <>
+ B(int p) { // expected-warning{{explicit specialization of 'B<T>' within class scope is a Microsoft extension}}
+ }
+
+ template <class U>
+ void f(U p) {
+ T y = 9;
+ }
+
+
+ template <>
+ void f(int p) { // expected-warning{{explicit specialization of 'f' within class scope is a Microsoft extension}}
+ T a = 3;
+ }
+
+ void f(int p) {
+ T a = 3;
+ }
+};
+
More information about the cfe-commits
mailing list