]> granicus.if.org Git - clang/commitdiff
[microsoft] Move missing typename warning from -fms-extensions to -fms-compatibility...
authorFrancois Pichet <pichet2000@gmail.com>
Wed, 21 Sep 2011 07:59:49 +0000 (07:59 +0000)
committerFrancois Pichet <pichet2000@gmail.com>
Wed, 21 Sep 2011 07:59:49 +0000 (07:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140240 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/MicrosoftCompatibility.cpp
test/SemaCXX/MicrosoftExtensions.cpp

index 6ad8584469b8d468e7c63ce94db46d0d299169a4..164fb2f1c27e915300c01979e7b5a7074403288c 100644 (file)
@@ -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)
index 4179ed81f3ee7f66dd0b7a6963625f78e4ff6641..788fcfbff020ab2233e85b1edf77cfdb9337fd90 100644 (file)
@@ -90,3 +90,47 @@ private:
 }\r
 \r
 \r
+namespace MissingTypename {\r
+\r
+template<class T> class A {\r
+public:\r
+        typedef int TYPE;\r
+};\r
+\r
+template<class T> class B {\r
+public:\r
+        typedef int TYPE;\r
+};\r
+\r
+\r
+template<class T, class U>\r
+class C : private A<T>, public B<U> {\r
+public:\r
+   typedef A<T> Base1;\r
+   typedef B<U> Base2;\r
+   typedef A<U> Base3;\r
+\r
+   A<T>::TYPE a1; // expected-warning {{missing 'typename' prior to dependent type name}}\r
+   Base1::TYPE a2; // expected-warning {{missing 'typename' prior to dependent type name}}\r
+\r
+   B<U>::TYPE a3; // expected-warning {{missing 'typename' prior to dependent type name}}\r
+   Base2::TYPE a4; // expected-warning {{missing 'typename' prior to dependent type name}}\r
+\r
+   A<U>::TYPE a5; // expected-error {{missing 'typename' prior to dependent type name}}\r
+   Base3::TYPE a6; // expected-error {{missing 'typename' prior to dependent type name}}\r
+ };\r
+\r
+class D {\r
+public:\r
+    typedef int Type;\r
+};\r
+\r
+template <class T>\r
+void function_missing_typename()\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
+\r
+}\r
index 1eb0c495f82a1cdbb6d8fa2977b115e1c505ace3..63e058b36daa4c6e086832bdaf121966684527d1 100644 (file)
@@ -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}}