diff options
author | Francois Pichet <pichet2000@gmail.com> | 2011-09-21 07:59:49 +0000 |
---|---|---|
committer | Francois Pichet <pichet2000@gmail.com> | 2011-09-21 07:59:49 +0000 |
commit | 036277e3e7bfa3ccef96fabf0b34a75d9a7c015b (patch) | |
tree | 7f8196f3d9d0b2c7d5fb7e1862816e90feac6c67 | |
parent | 88df12521ed20adce83652ba207d39475b7ece71 (diff) |
[microsoft] Move missing typename warning from -fms-extensions to -fms-compatibility. Also allow the missing typename warning at function scope.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140240 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 4 | ||||
-rw-r--r-- | test/SemaCXX/MicrosoftCompatibility.cpp | 44 | ||||
-rw-r--r-- | test/SemaCXX/MicrosoftExtensions.cpp | 34 |
3 files changed, 46 insertions, 36 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 6ad8584469..164fb2f1c2 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -280,7 +280,7 @@ bool Sema::isMicrosoftMissingTypename(const CXXScopeSpec *SS) { if (Context.hasSameUnqualifiedType(QualType(Ty, 1), Base->getType())) return true; } - return false; + return CurContext->isFunctionOrMethod(); } bool Sema::DiagnoseUnknownTypeName(const IdentifierInfo &II, @@ -362,7 +362,7 @@ bool Sema::DiagnoseUnknownTypeName(const IdentifierInfo &II, << &II << DC << SS->getRange(); else if (isDependentScopeSpecifier(*SS)) { unsigned DiagID = diag::err_typename_missing; - if (getLangOptions().MicrosoftExt && isMicrosoftMissingTypename(SS)) + if (getLangOptions().MicrosoftMode && isMicrosoftMissingTypename(SS)) DiagID = diag::warn_typename_missing; Diag(SS->getRange().getBegin(), DiagID) diff --git a/test/SemaCXX/MicrosoftCompatibility.cpp b/test/SemaCXX/MicrosoftCompatibility.cpp index 4179ed81f3..788fcfbff0 100644 --- a/test/SemaCXX/MicrosoftCompatibility.cpp +++ b/test/SemaCXX/MicrosoftCompatibility.cpp @@ -90,3 +90,47 @@ private: }
+namespace MissingTypename {
+
+template<class T> class A {
+public:
+ typedef int TYPE;
+};
+
+template<class T> class B {
+public:
+ typedef int TYPE;
+};
+
+
+template<class T, class U>
+class C : private A<T>, public B<U> {
+public:
+ typedef A<T> Base1;
+ typedef B<U> Base2;
+ typedef A<U> Base3;
+
+ A<T>::TYPE a1; // expected-warning {{missing 'typename' prior to dependent type name}}
+ Base1::TYPE a2; // expected-warning {{missing 'typename' prior to dependent type name}}
+
+ B<U>::TYPE a3; // expected-warning {{missing 'typename' prior to dependent type name}}
+ Base2::TYPE a4; // expected-warning {{missing 'typename' prior to dependent type name}}
+
+ A<U>::TYPE a5; // expected-error {{missing 'typename' prior to dependent type name}}
+ Base3::TYPE a6; // expected-error {{missing 'typename' prior to dependent type name}}
+ };
+
+class D {
+public:
+ typedef int Type;
+};
+
+template <class T>
+void function_missing_typename()
+{
+ const T::Type var = 2; // expected-warning {{missing 'typename' prior to dependent type name}}
+}
+
+template void function_missing_typename<D>();
+
+}
diff --git a/test/SemaCXX/MicrosoftExtensions.cpp b/test/SemaCXX/MicrosoftExtensions.cpp index 1eb0c495f8..63e058b36d 100644 --- a/test/SemaCXX/MicrosoftExtensions.cpp +++ b/test/SemaCXX/MicrosoftExtensions.cpp @@ -152,40 +152,6 @@ template <class T> void BB<T>::f(int g = 0) { } // expected-warning {{redefinition of default argument}} -namespace MissingTypename { - -template<class T> class A { -public: - typedef int TYPE; -}; - -template<class T> class B { -public: - typedef int TYPE; -}; - - -template<class T, class U> -class C : private A<T>, public B<U> { -public: - typedef A<T> Base1; - typedef B<U> Base2; - typedef A<U> Base3; - - A<T>::TYPE a1; // expected-warning {{missing 'typename' prior to dependent type name}} - Base1::TYPE a2; // expected-warning {{missing 'typename' prior to dependent type name}} - - B<U>::TYPE a3; // expected-warning {{missing 'typename' prior to dependent type name}} - Base2::TYPE a4; // expected-warning {{missing 'typename' prior to dependent type name}} - - A<U>::TYPE a5; // expected-error {{missing 'typename' prior to dependent type name}} - Base3::TYPE a6; // expected-error {{missing 'typename' prior to dependent type name}} - }; - -} - - - extern void static_func(); void static_func(); // expected-note {{previous declaration is here}} |