]> granicus.if.org Git - clang/commitdiff
Downgrade unnecessary "typename" from error to warning in Microsoft mode.
authorFrancois Pichet <pichet2000@gmail.com>
Sun, 24 Apr 2011 11:24:13 +0000 (11:24 +0000)
committerFrancois Pichet <pichet2000@gmail.com>
Sun, 24 Apr 2011 11:24:13 +0000 (11:24 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130088 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticParseKinds.td
lib/Parse/Parser.cpp
test/Parser/MicrosoftExtensions.cpp

index a297fd1ddcdc73e4d4e4cc990082a4416d70d7b9..6e1e1e46849c1530857001ed05ae6d695c1fdf9a 100644 (file)
@@ -404,6 +404,8 @@ def err_out_of_line_type_names_constructor : Error<
 
 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">;
 
index e0f7852e3c70a2722b8b19c3811be9b48e2fa0b4..9244b99492c8fdeebf488496bcfec061963263ea 100644 (file)
@@ -1090,7 +1090,10 @@ bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext) {
                                        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;
     }
 
index ec297f27013e33d616db0e74b262d90d4572eda3..20da81d26faed185ba99fb7eeb7f7d79a8c4e3f2 100644 (file)
@@ -130,7 +130,19 @@ void f(){
   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>();
 }