[cfe-commits] r102688 - in /cfe/trunk: lib/Parse/ParseTentative.cpp test/Parser/cxx-casting.cpp
John McCall
rjmccall at apple.com
Thu Apr 29 20:11:01 PDT 2010
Author: rjmccall
Date: Thu Apr 29 22:11:01 2010
New Revision: 102688
URL: http://llvm.org/viewvc/llvm-project?rev=102688&view=rev
Log:
Fix a tentative-parse error with unqualified template ids in cast expressions.
Also resolve a long-working FIXME in the test case I modified.
Modified:
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/test/Parser/cxx-casting.cpp
Modified: cfe/trunk/lib/Parse/ParseTentative.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=102688&r1=102687&r2=102688&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTentative.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTentative.cpp Thu Apr 29 22:11:01 2010
@@ -14,6 +14,7 @@
#include "clang/Parse/Parser.h"
#include "clang/Parse/ParseDiagnostic.h"
+#include "clang/Parse/Template.h"
using namespace clang;
/// isCXXDeclarationStatement - C++-specialized function that disambiguates
@@ -761,6 +762,17 @@
case tok::kw___vector:
return TPResult::True();
+ case tok::annot_template_id: {
+ TemplateIdAnnotation *TemplateId
+ = static_cast<TemplateIdAnnotation *>(Tok.getAnnotationValue());
+ if (TemplateId->Kind != TNK_Type_template)
+ return TPResult::False();
+ CXXScopeSpec SS;
+ AnnotateTemplateIdTokenAsType(&SS);
+ assert(Tok.is(tok::annot_typename));
+ goto case_typename;
+ }
+
case tok::annot_cxxscope: // foo::bar or ::foo::bar, but already parsed
// We've already annotated a scope; try to annotate a type.
if (TryAnnotateTypeOrScopeToken())
@@ -801,6 +813,7 @@
case tok::kw_double:
case tok::kw_void:
case tok::annot_typename:
+ case_typename:
if (NextToken().is(tok::l_paren))
return TPResult::Ambiguous();
Modified: cfe/trunk/test/Parser/cxx-casting.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-casting.cpp?rev=102688&r1=102687&r2=102688&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-casting.cpp (original)
+++ cfe/trunk/test/Parser/cxx-casting.cpp Thu Apr 29 22:11:01 2010
@@ -5,8 +5,6 @@
return const_cast<char*>(var);
}
-#if 0
-// FIXME: Uncomment when C++ is supported more.
struct A {
virtual ~A() {}
};
@@ -18,7 +16,6 @@
{
return dynamic_cast<struct B*>(a);
}
-#endif
char *reinterpret_cast_test()
{
@@ -34,3 +31,9 @@
{
return reinterpret_cast<char*>(0xdeadbeef)[0];
}
+
+// This was being incorrectly tentatively parsed.
+namespace test1 {
+ template <class T> class A {};
+ void foo() { A<int>(*(A<int>*)0); }
+}
More information about the cfe-commits
mailing list