]> granicus.if.org Git - clang/commitdiff
Parse: return true from ParseCXX11AttributeArgs if an attribute was added
authorSaleem Abdulrasool <compnerd@compnerd.org>
Mon, 16 Feb 2015 22:26:52 +0000 (22:26 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Mon, 16 Feb 2015 22:26:52 +0000 (22:26 +0000)
In the case that we diagnosed an invalid attribute due to missing or present
arguments, we would return false, indicating to the caller that the parsing
failed.  However, we would have added the attribute in ParseAttributeArgsCommon
(which may have been called indirectly through ParseGNUAttributeArgs).
Returning true in this case ensures that a second copy of the attribute is not
added.

I haven't added a test case for this as the existing test will cover this with
the next commit which diagnoses a C++14 attribute applied in C++11 mode.  Rather
than duplicating the existing test case, allow the tree to remain without a test
between this and the next change.  We would see double warnings in the
[[deprecated()]] applied to a declaration in C++11 mode, which will cause an
error in the cxx0x-attributes test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229446 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDeclCXX.cpp

index 0a88d202b8beb9579f35edbe3c78933b0d8009ce..eaaeba2d8915044be1ff123183e868c2d425e960 100644 (file)
@@ -3472,7 +3472,6 @@ bool Parser::ParseCXX11AttributeArgs(IdentifierInfo *AttrName,
         // The attribute was allowed to have arguments, but none were provided
         // even though the attribute parsed successfully. This is an error.
         Diag(LParenLoc, diag::err_attribute_requires_arguments) << AttrName;
-        return false;
       } else if (!Attr->getMaxArgs()) {
         // The attribute parsed successfully, but was not allowed to have any
         // arguments. It doesn't matter whether any were provided -- the
@@ -3480,7 +3479,6 @@ bool Parser::ParseCXX11AttributeArgs(IdentifierInfo *AttrName,
         Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
             << AttrName
             << FixItHint::CreateRemoval(SourceRange(LParenLoc, *EndLoc));
-        return false;
       }
     }
   }