]> granicus.if.org Git - clang/commitdiff
[Microsoft] If -fms-compatibility, then downgrade missing typename error to warning...
authorFrancois Pichet <pichet2000@gmail.com>
Tue, 11 Oct 2011 01:50:09 +0000 (01:50 +0000)
committerFrancois Pichet <pichet2000@gmail.com>
Tue, 11 Oct 2011 01:50:09 +0000 (01:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141630 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/Sema.h
lib/Sema/SemaDecl.cpp
test/SemaCXX/MicrosoftCompatibility.cpp

index 55b8f9856774c8a05aa1b611d0a46155e9000367..39c989976114f2767f623d649138c7233a64aac8 100644 (file)
@@ -876,7 +876,7 @@ public:
                          bool WantNontrivialTypeSourceInfo = false,
                          IdentifierInfo **CorrectedII = 0);
   TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S);
-  bool isMicrosoftMissingTypename(const CXXScopeSpec *SS);
+  bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
   bool DiagnoseUnknownTypeName(const IdentifierInfo &II,
                                SourceLocation IILoc,
                                Scope *S,
index b510091ffaccbb0aed0e783ce537965f691dda5e..d19023d04553746b716e59c7d4dca686f7dd46c0 100644 (file)
@@ -317,7 +317,7 @@ DeclSpec::TST Sema::isTagName(IdentifierInfo &II, Scope *S) {
 ///   A<T>::TYPE a; // no typename required because A<T> is a base class.
 /// };
 /// @endcode
-bool Sema::isMicrosoftMissingTypename(const CXXScopeSpec *SS) {
+bool Sema::isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S) {
   if (CurContext->isRecord()) {
     const Type *Ty = SS->getScopeRep()->getAsType();
 
@@ -326,8 +326,9 @@ bool Sema::isMicrosoftMissingTypename(const CXXScopeSpec *SS) {
           BaseEnd = RD->bases_end(); Base != BaseEnd; ++Base)
       if (Context.hasSameUnqualifiedType(QualType(Ty, 1), Base->getType()))
         return true;
+    return S->isFunctionPrototypeScope();
   } 
-  return CurContext->isFunctionOrMethod();
+  return CurContext->isFunctionOrMethod() || S->isFunctionPrototypeScope();
 }
 
 bool Sema::DiagnoseUnknownTypeName(const IdentifierInfo &II, 
@@ -409,7 +410,7 @@ bool Sema::DiagnoseUnknownTypeName(const IdentifierInfo &II,
       << &II << DC << SS->getRange();
   else if (isDependentScopeSpecifier(*SS)) {
     unsigned DiagID = diag::err_typename_missing;
-    if (getLangOptions().MicrosoftMode && isMicrosoftMissingTypename(SS))
+    if (getLangOptions().MicrosoftMode && isMicrosoftMissingTypename(SS, S))
       DiagID = diag::warn_typename_missing;
 
     Diag(SS->getRange().getBegin(), DiagID)
index 1370b7dbf4f178cbf38d6b2c67a7c9c04708f620..dfc47d6fc956b10129f9366e00b87ef29b5d5e8e 100644 (file)
@@ -126,12 +126,12 @@ public:
 };\r
 \r
 template <class T>\r
-void function_missing_typename()\r
+void function_missing_typename(const T::Type param)// expected-warning {{missing 'typename' prior to dependent type name}}\r
 {\r
     const T::Type var = 2; // expected-warning {{missing 'typename' prior to dependent type name}}\r
 }\r
 \r
-template void function_missing_typename<D>();\r
+template void function_missing_typename<D>(const D::Type param);\r
 \r
 }\r
 \r