[cfe-commits] r130088 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/Parser.cpp test/Parser/MicrosoftExtensions.cpp

Francois Pichet pichet2000 at gmail.com
Sun Apr 24 04:24:13 PDT 2011


Author: fpichet
Date: Sun Apr 24 06:24:13 2011
New Revision: 130088

URL: http://llvm.org/viewvc/llvm-project?rev=130088&view=rev
Log:
Downgrade unnecessary "typename" from error to warning in Microsoft mode. 
This fixes 1 error when parsing MSVC 2008 headers with clang. 

Must "return true;" even if it is a warning because the rest of the code path assumes that SS is set to something. The parser will get back on its feet and continue parsing the rest of the declaration correctly so it is not a problem.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
    cfe/trunk/lib/Parse/Parser.cpp
    cfe/trunk/test/Parser/MicrosoftExtensions.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=130088&r1=130087&r2=130088&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Sun Apr 24 06:24:13 2011
@@ -404,6 +404,8 @@
 
 def err_expected_qualified_after_typename : Error<
   "expected a qualified name after 'typename'">;
+def warn_expected_qualified_after_typename : ExtWarn<
+  "expected a qualified name after 'typename'">;
 def err_expected_semi_after_tagdecl : Error<
   "expected ';' after %0">;
 

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=130088&r1=130087&r2=130088&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Sun Apr 24 06:24:13 2011
@@ -1090,7 +1090,10 @@
                                        0, /*IsTypename*/true))
       return true;
     if (!SS.isSet()) {
-      Diag(Tok.getLocation(), diag::err_expected_qualified_after_typename);
+      if (getLang().Microsoft)
+        Diag(Tok.getLocation(), diag::warn_expected_qualified_after_typename);
+      else
+        Diag(Tok.getLocation(), diag::err_expected_qualified_after_typename);
       return true;
     }
 

Modified: cfe/trunk/test/Parser/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.cpp?rev=130088&r1=130087&r2=130088&view=diff
==============================================================================
--- cfe/trunk/test/Parser/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/Parser/MicrosoftExtensions.cpp Sun Apr 24 06:24:13 2011
@@ -130,7 +130,19 @@
   typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
 }
 
+
+
+class AAAA { };
+
+template <class T>
+void redundant_typename() {
+   typename T t;// expected-warning {{expected a qualified name after 'typename'}}
+   typename AAAA a;// expected-warning {{expected a qualified name after 'typename'}}
+   t = 3;
+}
+
 int main() {
+  redundant_typename<int>();
   f<int>();
 }
 





More information about the cfe-commits mailing list