summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Pichet <pichet2000@gmail.com>2011-05-14 19:17:07 +0000
committerFrancois Pichet <pichet2000@gmail.com>2011-05-14 19:17:07 +0000
commitc2fac71c75f76932dcbfdbc4552c48e2b4d58297 (patch)
tree0fd7fe142c3d93bb10c57db0458e2b067f15ccb7
parentf6ed8ffd695a633369b6dd048216076629ad5ef3 (diff)
downloadbcm5719-llvm-c2fac71c75f76932dcbfdbc4552c48e2b4d58297.tar.gz
bcm5719-llvm-c2fac71c75f76932dcbfdbc4552c48e2b4d58297.zip
Revert 131347. It asserts if the specialization in within a class template:
template<class U> struct X1 { template<class T> void f(T*); template<> void f(int*) { } }; Won't be so simple. I need to think more about it. llvm-svn: 131362
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td3
-rw-r--r--clang/lib/Sema/SemaDecl.cpp10
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp9
-rw-r--r--clang/test/SemaCXX/MicrosoftExtensions.cpp7
4 files changed, 6 insertions, 23 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index ea82cf80edb..ea1ef56010a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1775,9 +1775,6 @@ def err_template_spec_decl_function_scope : Error<
"explicit specialization of %0 in function scope">;
def err_template_spec_decl_class_scope : Error<
"explicit specialization of %0 in class scope">;
-def war_template_spec_decl_class_scope : ExtWarn<
- "Allowing explicit specialization of %0 in class scope is a Microsoft "
- "extension">, InGroup<Microsoft>;
def err_template_spec_decl_friend : Error<
"cannot declare an explicit specialization in a friend">;
def err_template_spec_decl_out_of_scope_global : Error<
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 25d23584b8f..93857324a1f 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1685,14 +1685,10 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
if (OldMethod && NewMethod) {
// Preserve triviality.
NewMethod->setTrivial(OldMethod->isTrivial());
-
- // MSVC allows explicit template specialization at class scope.
- bool IsMSExplicitSpecialization = getLangOptions().Microsoft &&
- NewMethod->isFunctionTemplateSpecialization();
+
bool isFriend = NewMethod->getFriendObjectKind();
- if (!isFriend && NewMethod->getLexicalDeclContext()->isRecord() &&
- !IsMSExplicitSpecialization) {
+ if (!isFriend && NewMethod->getLexicalDeclContext()->isRecord()) {
// -- Member function declarations with the same name and the
// same parameter types cannot be overloaded if any of them
// is a static member function declaration.
@@ -4573,7 +4569,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
NewFD->setInvalidDecl();
} else if (isFunctionTemplateSpecialization) {
if (CurContext->isDependentContext() && CurContext->isRecord()
- && !isFriend) {
+ && !isFriend && !getLangOptions().Microsoft) {
Diag(NewFD->getLocation(), diag::err_function_specialization_in_class)
<< NewFD->getDeclName();
NewFD->setInvalidDecl();
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 9b14f633013..c31ed017377 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -4401,12 +4401,9 @@ static bool CheckTemplateSpecializationScope(Sema &S,
}
if (S.CurContext->isRecord() && !IsPartialSpecialization) {
- if (S.getLangOptions().Microsoft)
- S.Diag(Loc, diag::war_template_spec_decl_class_scope) << Specialized;
- else {
- S.Diag(Loc, diag::err_template_spec_decl_class_scope) << Specialized;
- return true;
- }
+ S.Diag(Loc, diag::err_template_spec_decl_class_scope)
+ << Specialized;
+ return true;
}
// C++ [temp.class.spec]p6:
diff --git a/clang/test/SemaCXX/MicrosoftExtensions.cpp b/clang/test/SemaCXX/MicrosoftExtensions.cpp
index e1c64b1ac8f..88e39226708 100644
--- a/clang/test/SemaCXX/MicrosoftExtensions.cpp
+++ b/clang/test/SemaCXX/MicrosoftExtensions.cpp
@@ -197,10 +197,3 @@ void pointer_to_integral_type_conv(char* ptr) {
ch = (char)ptr;
sh = (short)ptr;
}
-
-
-struct X1 {
- template<typename T> void f(T);
-
- template<> void f(int) { } // expected-warning{{Allowing explicit specialization of 'f' in class scope is a Microsoft extension}}
-};
OpenPOWER on IntegriCloud