From: Aaron Ballman Date: Fri, 19 Dec 2014 18:37:22 +0000 (+0000) Subject: Added a fixit to remove empty parens from a C++11 attribute argument list when we... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5568fd102de53b13f4bdec829c8eb24d5c1263f8;p=clang Added a fixit to remove empty parens from a C++11 attribute argument list when we diagnose this as an error. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224595 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 01f91eb26d..e2a51ecfca 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -3469,7 +3469,6 @@ bool Parser::ParseCXX11AttributeArgs(IdentifierInfo *AttrName, if (Attr->getMaxArgs() && !NumArgs) { // The attribute was allowed to have arguments, but none were provided // even though the attribute parsed successfully. This is an error. - // FIXME: This is a good place for a fixit which removes the parens. Diag(LParenLoc, diag::err_attribute_requires_arguments) << AttrName; return false; } else if (!Attr->getMaxArgs()) { @@ -3477,7 +3476,8 @@ bool Parser::ParseCXX11AttributeArgs(IdentifierInfo *AttrName, // arguments. It doesn't matter whether any were provided -- the // presence of the argument list (even if empty) is diagnosed. Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments) - << AttrName; + << AttrName + << FixItHint::CreateRemoval(SourceRange(LParenLoc, *EndLoc)); return false; } } diff --git a/test/SemaCXX/attr-cxx0x-fixit.cpp b/test/SemaCXX/attr-cxx0x-fixit.cpp new file mode 100644 index 0000000000..6a6cdc1128 --- /dev/null +++ b/test/SemaCXX/attr-cxx0x-fixit.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -std=c++11 %s 2>&1 | FileCheck %s + +[[noreturn()]] void f(); // expected-error {{attribute 'noreturn' cannot have an argument list}} \ +// CHECK: fix-it:"{{.*}}":{4:11-4:13}:""