- Fix a couple of typographical errors.
Hi rsmith,
http://llvm-reviews.chandlerc.com/D1433
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D1433?vs=3549&id=3550#toc
Files:
lib/Parse/Parser.cpp
test/Parser/MicrosoftExtensions.cpp
Index: lib/Parse/Parser.cpp
===================================================================
--- lib/Parse/Parser.cpp
+++ lib/Parse/Parser.cpp
@@ -1480,6 +1480,27 @@
&& "Cannot be a type or scope token!");
if (Tok.is(tok::kw_typename)) {
+ // MSVC lets you do stuff like:
+ // typename typedef T_::D D;
+ //
+ // We will consume the typedef token here and put it back after we have
+ // parsedthe first identifier, transforming it into something more like:
+ // typename T_::D typedef D;
+ if (getLangOpts().MicrosoftExt && NextToken().is(tok::kw_typedef)) {
+ Token TypenameToken = Tok;
+ ConsumeToken();
+ Token TypedefToken = Tok;
+ ConsumeToken();
+ PP.EnterToken(Tok);
+ Tok = TypenameToken;
+ bool Result = TryAnnotateTypeOrScopeToken(EnteringContext, NeedType);
+ PP.EnterToken(Tok);
+ Tok = TypedefToken;
+ if (!Result)
+ Diag(Tok.getLocation(), diag::warn_expected_qualified_after_typename);
+ return Result;
+ }
+
// Parse a C++ typename-specifier, e.g., "typename T::type".
//
// typename-specifier:
@@ -1498,7 +1519,7 @@
// Attempt to recover by skipping the invalid 'typename'
if (Tok.is(tok::annot_decltype) ||
(!TryAnnotateTypeOrScopeToken(EnteringContext, NeedType) &&
- Tok.isAnnotation())) {
+ Tok.isAnnotation())) {
unsigned DiagID = diag::err_expected_qualified_after_typename;
// MS compatibility: MSVC permits using known types with typename.
// e.g. "typedef typename T* pointer_type"
Index: test/Parser/MicrosoftExtensions.cpp
===================================================================
--- test/Parser/MicrosoftExtensions.cpp
+++ test/Parser/MicrosoftExtensions.cpp
@@ -149,7 +149,9 @@
-class AAAA { };
+class AAAA {
+ typedef int D;
+};
template <typename T>
class SimpleTemplate {};
@@ -171,6 +173,12 @@
int k = typename var;// expected-error {{expected a qualified name after
'typename'}}
}
+template <typename T>
+struct TypenameWrongPlace {
+ typename typedef T::D D;// expected-warning {{expected a qualified name
after 'typename'}}
+};
+
+extern TypenameWrongPlace<AAAA> PR16925;
__interface MicrosoftInterface;
__interface MicrosoftInterface {
Index: lib/Parse/Parser.cpp
===================================================================
--- lib/Parse/Parser.cpp
+++ lib/Parse/Parser.cpp
@@ -1480,6 +1480,27 @@
&& "Cannot be a type or scope token!");
if (Tok.is(tok::kw_typename)) {
+ // MSVC lets you do stuff like:
+ // typename typedef T_::D D;
+ //
+ // We will consume the typedef token here and put it back after we have
+ // parsedthe first identifier, transforming it into something more like:
+ // typename T_::D typedef D;
+ if (getLangOpts().MicrosoftExt && NextToken().is(tok::kw_typedef)) {
+ Token TypenameToken = Tok;
+ ConsumeToken();
+ Token TypedefToken = Tok;
+ ConsumeToken();
+ PP.EnterToken(Tok);
+ Tok = TypenameToken;
+ bool Result = TryAnnotateTypeOrScopeToken(EnteringContext, NeedType);
+ PP.EnterToken(Tok);
+ Tok = TypedefToken;
+ if (!Result)
+ Diag(Tok.getLocation(), diag::warn_expected_qualified_after_typename);
+ return Result;
+ }
+
// Parse a C++ typename-specifier, e.g., "typename T::type".
//
// typename-specifier:
@@ -1498,7 +1519,7 @@
// Attempt to recover by skipping the invalid 'typename'
if (Tok.is(tok::annot_decltype) ||
(!TryAnnotateTypeOrScopeToken(EnteringContext, NeedType) &&
- Tok.isAnnotation())) {
+ Tok.isAnnotation())) {
unsigned DiagID = diag::err_expected_qualified_after_typename;
// MS compatibility: MSVC permits using known types with typename.
// e.g. "typedef typename T* pointer_type"
Index: test/Parser/MicrosoftExtensions.cpp
===================================================================
--- test/Parser/MicrosoftExtensions.cpp
+++ test/Parser/MicrosoftExtensions.cpp
@@ -149,7 +149,9 @@
-class AAAA { };
+class AAAA {
+ typedef int D;
+};
template <typename T>
class SimpleTemplate {};
@@ -171,6 +173,12 @@
int k = typename var;// expected-error {{expected a qualified name after 'typename'}}
}
+template <typename T>
+struct TypenameWrongPlace {
+ typename typedef T::D D;// expected-warning {{expected a qualified name after 'typename'}}
+};
+
+extern TypenameWrongPlace<AAAA> PR16925;
__interface MicrosoftInterface;
__interface MicrosoftInterface {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits