]> granicus.if.org Git - clang/commitdiff
Added a fixit to remove empty parens from a C++11 attribute argument list when we...
authorAaron Ballman <aaron@aaronballman.com>
Fri, 19 Dec 2014 18:37:22 +0000 (18:37 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Fri, 19 Dec 2014 18:37:22 +0000 (18:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224595 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDeclCXX.cpp
test/SemaCXX/attr-cxx0x-fixit.cpp [new file with mode: 0644]

index 01f91eb26d80faea45e8570142b90ad0090c4862..e2a51ecfca4034b856e729b238abe5f3093dbb6f 100644 (file)
@@ -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 (file)
index 0000000..6a6cdc1
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s\r
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -std=c++11 %s 2>&1 | FileCheck %s\r
+\r
+[[noreturn()]] void f(); // expected-error {{attribute 'noreturn' cannot have an argument list}} \\r
+// CHECK: fix-it:"{{.*}}":{4:11-4:13}:""\r