diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 9b60b95ed1738e..20ad465550f82d 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -6751,18 +6751,17 @@ void Parser::ParseDeclaratorInternal(Declarator &D, DeclSpec DS(AttrFactory); // Complain about: - // - rvalue references in C++03, - // - `^T &&` parsing ambiguity in C++2x + // - rvalue references in C++03 + // - `^T &&` parsing ambiguity of compound expression with reflection in C++2x // but then go on and build the declarator. if (Kind == tok::ampamp) { if (D.getContext() == DeclaratorContext::ReflectOperator) { - std::string typeName = "T"; - if (D.hasName()) { - typeName = Actions.GetNameForDeclarator(D).getName().getAsString(); - } + // parser already consumed '^' token before setting this context Diag(Loc, diag::warn_parsing_ambiguity_in_refl_expression_with_ampamp_token) - << typeName; + << (D.hasName() + ? Actions.GetNameForDeclarator(D).getName().getAsString() + : "T"); } Diag(Loc, getLangOpts().CPlusPlus11