diff options
-rw-r--r-- | include/clang/Basic/DiagnosticParseKinds.td | 2 | ||||
-rw-r--r-- | lib/Parse/Parser.cpp | 5 | ||||
-rw-r--r-- | test/Parser/MicrosoftExtensions.cpp | 12 |
3 files changed, 18 insertions, 1 deletions
diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index a297fd1ddc..6e1e1e4684 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -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">; diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index e0f7852e3c..9244b99492 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -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; } diff --git a/test/Parser/MicrosoftExtensions.cpp b/test/Parser/MicrosoftExtensions.cpp index ec297f2701..20da81d26f 100644 --- a/test/Parser/MicrosoftExtensions.cpp +++ b/test/Parser/MicrosoftExtensions.cpp @@ -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>(); } |