[cfe-commits] r160613 - in /cfe/trunk: lib/Parse/Parser.cpp test/SemaCXX/MicrosoftCompatibility.cpp
Francois Pichet
pichet2000 at gmail.com
Sun Jul 22 08:10:57 PDT 2012
Author: fpichet
Date: Sun Jul 22 10:10:57 2012
New Revision: 160613
URL: http://llvm.org/viewvc/llvm-project?rev=160613&view=rev
Log:
Allow the parser to recover gracefully if a typename is used to introduce a decltype type.
In Microsoft mode, we emit a warning instead of an error.
This fixes a couple of errors when parsing the MSVC 11 RC headers with clang.
Modified:
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=160613&r1=160612&r2=160613&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Sun Jul 22 10:10:57 2012
@@ -1334,10 +1334,12 @@
0, /*IsTypename*/true))
return true;
if (!SS.isSet()) {
- if (Tok.is(tok::identifier) || Tok.is(tok::annot_template_id)) {
+ if (Tok.is(tok::identifier) || Tok.is(tok::annot_template_id) ||
+ Tok.is(tok::annot_decltype)) {
// Attempt to recover by skipping the invalid 'typename'
- if (!TryAnnotateTypeOrScopeToken(EnteringContext, NeedType) &&
- Tok.isAnnotation()) {
+ if (Tok.is(tok::annot_decltype) ||
+ (!TryAnnotateTypeOrScopeToken(EnteringContext, NeedType) &&
+ 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"
Modified: cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp?rev=160613&r1=160612&r2=160613&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp Sun Jul 22 10:10:57 2012
@@ -4,6 +4,8 @@
typedef unsigned short char16_t;
typedef unsigned int char32_t;
+typename decltype(3) a; // expected-warning {{expected a qualified name after 'typename'}}
+
namespace ms_conversion_rules {
void f(float a);
More information about the cfe-commits
mailing list