[cfe-commits] r102161 - in /cfe/trunk: lib/Parse/ParseExpr.cpp test/SemaCXX/qualified-id-lookup.cpp
Douglas Gregor
dgregor at apple.com
Thu Apr 22 19:08:13 PDT 2010
Author: dgregor
Date: Thu Apr 22 21:08:13 2010
New Revision: 102161
URL: http://llvm.org/viewvc/llvm-project?rev=102161&view=rev
Log:
When parsing a cast-expression that starts with a scope annotation,
try to annotate as a type first to determine whether we have a
functional-style cast. Patch by Eli Friedman, fixes PR6830.
Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/test/SemaCXX/qualified-id-lookup.cpp
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=102161&r1=102160&r2=102161&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu Apr 22 21:08:13 2010
@@ -788,6 +788,14 @@
}
case tok::annot_cxxscope: { // [C++] id-expression: qualified-id
+ // If TryAnnotateTypeOrScopeToken annotates the token, tail recurse.
+ // (We can end up in this situation after tentative parsing.)
+ if (TryAnnotateTypeOrScopeToken())
+ return ExprError();
+ if (!Tok.is(tok::annot_cxxscope))
+ return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
+ NotCastExpr, TypeOfCast);
+
Token Next = NextToken();
if (Next.is(tok::annot_template_id)) {
TemplateIdAnnotation *TemplateId
Modified: cfe/trunk/test/SemaCXX/qualified-id-lookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/qualified-id-lookup.cpp?rev=102161&r1=102160&r2=102161&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/qualified-id-lookup.cpp (original)
+++ cfe/trunk/test/SemaCXX/qualified-id-lookup.cpp Thu Apr 22 21:08:13 2010
@@ -124,3 +124,25 @@
template class ClassChecker<int>;
}
+
+namespace PR6830 {
+ namespace foo {
+
+ class X {
+ public:
+ X() {}
+ };
+
+ } // namespace foo
+
+ class Z {
+ public:
+ explicit Z(const foo::X& x) {}
+
+ void Work() {}
+ };
+
+ void Test() {
+ Z(foo::X()).Work();
+ }
+}
More information about the cfe-commits
mailing list