From 2c4a7501eef0db6198e896b17be8333def044c85 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 23 Apr 2010 02:08:13 +0000 Subject: [PATCH] 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. llvm-svn: 102161 --- clang/lib/Parse/ParseExpr.cpp | 8 ++++++++ clang/test/SemaCXX/qualified-id-lookup.cpp | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 588825b01ca4..b9e632a1846e 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -788,6 +788,14 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression, } 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 diff --git a/clang/test/SemaCXX/qualified-id-lookup.cpp b/clang/test/SemaCXX/qualified-id-lookup.cpp index abde62efceae..dfb059aa36ad 100644 --- a/clang/test/SemaCXX/qualified-id-lookup.cpp +++ b/clang/test/SemaCXX/qualified-id-lookup.cpp @@ -124,3 +124,25 @@ namespace test1 { template class ClassChecker; } + +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(); + } +} -- GitLab