[cfe-commits] r141630 - in /cfe/trunk: include/clang/Sema/Sema.h lib/Sema/SemaDecl.cpp test/SemaCXX/MicrosoftCompatibility.cpp
Francois Pichet
pichet2000 at gmail.com
Mon Oct 10 18:50:09 PDT 2011
Author: fpichet
Date: Mon Oct 10 20:50:09 2011
New Revision: 141630
URL: http://llvm.org/viewvc/llvm-project?rev=141630&view=rev
Log:
[Microsoft] If -fms-compatibility, then downgrade missing typename error to warning at function prototype scope.
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=141630&r1=141629&r2=141630&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Oct 10 20:50:09 2011
@@ -876,7 +876,7 @@
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,
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=141630&r1=141629&r2=141630&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Oct 10 20:50:09 2011
@@ -317,7 +317,7 @@
/// 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 @@
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 @@
<< &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)
Modified: cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp?rev=141630&r1=141629&r2=141630&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp Mon Oct 10 20:50:09 2011
@@ -126,12 +126,12 @@
};
template <class T>
-void function_missing_typename()
+void function_missing_typename(const T::Type param)// expected-warning {{missing 'typename' prior to dependent type name}}
{
const T::Type var = 2; // expected-warning {{missing 'typename' prior to dependent type name}}
}
-template void function_missing_typename<D>();
+template void function_missing_typename<D>(const D::Type param);
}
More information about the cfe-commits
mailing list