summaryrefslogtreecommitdiffstats
path: root/clang/test/Parser/cxx0x-attributes.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add a fixit for attributes incorrectly placed prior to 'struct/class/enum' ↵Faisal Vali2017-12-251-1/+8
| | | | | | | | | | | | | keyword. Suggest moving the following erroneous attrib list (based on location) [[]] struct X; to struct [[]] X; Additionally, added a fixme for the current implementation that diagnoses misplaced attributes to consider using the newly introduced diagnostic (that I think is more user-friendly). llvm-svn: 321449
* Determine the attribute subject for diagnostics based on declarative ↵Aaron Ballman2017-11-261-1/+1
| | | | | | | | | | information in DeclNodes.td. This greatly reduces the number of enumerated values used for more complex diagnostics; these are now only required when the "attribute only applies to" diagnostic needs to be generated manually as part of semantic processing. This also clarifies some terminology used by the diagnostic (methods -> Objective-C methods, fields -> non-static data members, etc). Many of the tests needed to be updated in multiple places for the diagnostic wording tweaks. The first instance of the diagnostic for that attribute is fully specified and subsequent instances cut off the complete list (to make it easier if additional subjects are added in the future for the attribute). llvm-svn: 319002
* Fix backwards warning for use of C++17 ↵Richard Smith2017-10-141-2/+2
| | | | | | attributes-on-namespaces-and-enumerators feature. llvm-svn: 315784
* Replace remaining user-visible mentions of C++1z with C++17.Richard Smith2017-08-131-4/+4
| | | | llvm-svn: 310804
* Fix constructor declarator detection for the case when the name is followed byRichard Smith2017-02-081-4/+6
| | | | | | an attribute-specifier-seq. (Also fixes the same problem for deduction-guides.) llvm-svn: 294396
* Silence duplicate diagnostics because parsing of a standards-based attribute ↵Aaron Ballman2016-03-081-1/+0
| | | | | | triggers parsing diagnostics that may also be picked up during semantic analysis. llvm-svn: 262960
* P0188R1: add support for standard [[fallthrough]] attribute. This is almostRichard Smith2016-03-081-1/+13
| | | | | | | | | | | | | | exactly the same as clang's existing [[clang::fallthrough]] attribute, which has been updated to have the same semantics. The one significant difference is that [[fallthrough]] is ill-formed if it's not used immediately before a switch label (even when -Wimplicit-fallthrough is disabled). To support that, we now build a CFG of any function that uses a '[[fallthrough]];' statement to check. In passing, fix some bugs with our support for statement attributes -- in particular, diagnose their use on declarations, rather than asserting. llvm-svn: 262881
* [Sema] Tweak incomplete enum types on MSVC ABI targetsDavid Majnemer2015-10-081-1/+1
| | | | | | | | | Enums without an explicit, fixed, underlying type are implicitly given a fixed 'int' type for ABI compatibility with MSVC. However, we can enforce the standard-mandated rules on these types as-if we didn't know this fact if the tag is not part of a definition. llvm-svn: 249667
* Update tests touched by r249656David Majnemer2015-10-081-1/+1
| | | | | | | | | These test updates almost exclusively around the change in behavior around enum: enums without a definition are considered incomplete except when targeting MSVC ABIs. Since these tests are interested in the 'incomplete-enum' behavior, restrict them to %itanium_abi_triple. llvm-svn: 249660
* [parse] Don't crash on alternative operator spellings from macros in c++11 ↵Benjamin Kramer2015-03-291-0/+7
| | | | | | | | attributes. Found by afl-fuzz. llvm-svn: 233499
* Minor tweaks to r229447 to ensure the attribute is properly quoted when ↵Aaron Ballman2015-02-161-4/+4
| | | | | | diagnosed. llvm-svn: 229454
* Sema: diagnose use of unscoped deprecated prior to C++14Saleem Abdulrasool2015-02-161-1/+6
| | | | | | | | | The deprecated attribute was adopted as part of the C++14, however, there is a GNU version available in C++11. When using C++ earlier than C++14, diagnose the use of the attribute without the GNU scope, but only when using the generalised attribute syntax. llvm-svn: 229447
* Parse: Don't crash when an annotation token shows up in a C++11 attrDavid Majnemer2015-01-091-0/+7
| | | | | | | It's not safe to blindly call getIdentifierInfo without checking the token is not an annotation token. llvm-svn: 225533
* Crash even less on malformed attributes in an incorrect location.Nico Weber2014-12-291-4/+4
| | | | | | | | | | | This is a follow-up to r224915. This adds a bit more line noise to the tests added in that revision to make sure the parser is ready for a toplevel decl after each incorrect line. Use this to move the tests up to where they belong. This uncovered that the early return was missing a call to ActOnTagDefinitionError(), so add that. (Also fixes at least one of the crashes on SLi's bot.) llvm-svn: 224958
* Don't crash on malformed attributes in an incorrect location.Nico Weber2014-12-291-0/+4
| | | | | | | | | | | | | | | | | | r168626 added nicer diagnostics for attributes in the wrong places, such as after the `final` on a class. To do this, it added code that did high-level pattern matching for e.g. 'final' 'alignas' '(' and then skipped until the closing ')'. If it saw that, it then went down the regular class parsing path and then called MaybeParseCXX11Attributes() to parse the attribute after the 'final' using real attribute parsing code. On invalid attributes, the real attribute parsing code could eat more tokens than the pattern matching code and for example skip past the '{' starting the class, which would then lead to an assert. To prevent this, check for a good state after calling MaybeParseCXX11Attributes() (which morphed into CheckMisplacedCXX11Attribute() in r175575) and bail out if things look bleak. Found by SLi's afl bot. llvm-svn: 224915
* Updated the wording for a diagnostic to be more grammatically correct, and ↵Aaron Ballman2014-11-081-2/+2
| | | | | | use a %select. Also ensure that nested namespace definitions are diagnosed properly. Both changes are motivated by post-commit feedback from r221580. llvm-svn: 221581
* [c++1z] Support for attributes on namespaces and enumerators.Aaron Ballman2014-11-081-2/+3
| | | | llvm-svn: 221580
* Fixing a typo, updating the diagnostic wording and logic based on ↵Aaron Ballman2014-04-151-1/+1
| | | | | | post-commit review feedback. Amends r206186. llvm-svn: 206229
* Properly diagnose standard C++ attributes which have optional argument lists ↵Aaron Ballman2014-04-141-0/+7
| | | | | | | | | | | when the arguments are elided. eg) [[deprecated()]] // error [[deprecated]] // OK [[deprecated("")]] // OK [[gnu::deprecated()]] // OK llvm-svn: 206186
* Introduced an attribute syntax-neutral method for parsing attribute ↵Aaron Ballman2014-03-311-8/+9
| | | | | | arguments that is currently being used by GNU and C++-style attributes. This allows C++11 attributes with argument lists to be handled properly, fixing the "deprecated", "type_visibility", and capability-related attributes with arguments. llvm-svn: 205226
* add an additional test case for generic attributesSaleem Abdulrasool2013-11-301-0/+2
| | | | | | | | gcc treats [[gnu:const]], [[gnu::__const]], and [[gnu:__const__]] as all being equivalent. Add an additional test case to ensure that we do not miss the last case. llvm-svn: 195982
* Adding the Subjects entry back for the noreturn attributes. This caused some ↵Aaron Ballman2013-11-271-8/+8
| | | | | | test cases to be updated because the original diagnostic was about applying to methods as well as functions, but the semantic checking disallowed methods. llvm-svn: 195862
* Add missing attributes [[gnu::no_sanitize_address]] andNick Lewycky2013-10-291-0/+7
| | | | | | [[gnu::no_address_safety_analysis]]. llvm-svn: 193583
* Treat [[gnu::__const]] the same as [[gnu::const]]. GCC's tokenizer can't tellNick Lewycky2013-10-291-0/+8
| | | | | | the difference. llvm-svn: 193582
* Tidy up and improve error recovery for C++11 attributes in bad places. Based onRichard Smith2013-10-151-0/+18
| | | | | | a patch by Michael Han. llvm-svn: 192666
* C++11 attributes after 'constructor-name (' unambiguously signal that we have aRichard Smith2013-09-061-0/+5
| | | | | | constructor. llvm-svn: 190111
* [Sema] Semantic analysis for empty-declaration and attribute-declaration.Michael Han2013-02-221-1/+2
| | | | | | | | Introduce a new AST Decl node "EmptyDecl" to model empty-declaration. Have attributes from attribute-declaration appertain to the EmptyDecl node by creating the AST representations of these attributes and attach them to the EmptyDecl node so these attributes can be sema checked just as attributes attached to "normal" declarations. llvm-svn: 175900
* Per the grammar in [dcl.dcl]p1, a simple-declaration can only have attributesRichard Smith2013-02-221-0/+5
| | | | | | if it has declarators. We were missing the check for this in a couple of places. llvm-svn: 175876
* Process and handle attributes on conditions and for loop variables. Process andRichard Smith2013-02-201-6/+16
| | | | | | | diagnose attributes on alias declarations, using directives, and attribute declarations. llvm-svn: 175649
* Downgrade 'attribute ignored when parsing type' from error to warning, to matchRichard Smith2013-01-291-3/+3
| | | | | | | | | the diagnostic's warn_ name. Switch some places (notably C++11 attributes) which really wanted an error over to a different diagnostic. Finally, suppress the diagnostic entirely for __ptr32, __ptr64 and __w64, to avoid producing diagnostics in important system headers. llvm-svn: 173788
* Implement C++11 semantics for [[noreturn]] attribute. This required splittingRichard Smith2013-01-171-2/+5
| | | | | | | | it apart from [[gnu::noreturn]] / __attribute__((noreturn)), since their semantics are not equivalent (for instance, we treat [[gnu::noreturn]] as affecting the function type, whereas [[noreturn]] does not). llvm-svn: 172691
* Accept [[gnu::*]] for all __attribute__((*))s which are:Richard Smith2013-01-141-3/+7
| | | | | | | | | | | 1) Supported by Clang, and 2) Supported by GCC, and 3) Documented in GCC's manual. g++ allows its C++11-style attributes to appertain only to the entity being declared, and never to a type (even for a type attribute), so we do the same. llvm-svn: 172382
* Add fixit hints for misplaced C++11 attributes around class specifiers.Michael Han2013-01-071-1/+0
| | | | | | | | | | Following r168626, in class declaration or definition, there are a combination of syntactic locations where C++11 attributes could appear, and among those the only valid location permitted by standard is between class-key and class-name. So for those attributes appear at wrong locations, fixit is used to move them to expected location and we recover by applying them to the class specifier. llvm-svn: 171757
* Implement C++11 [dcl.attr.grammar] p4: If an attribute-specifier-seq ↵Michael Han2012-11-281-1/+7
| | | | | | appertains to a friend declaration, that declaration shall be a definition. llvm-svn: 168826
* Improve diagnostic on C++11 attribute specifiers that appear at wrong ↵Michael Han2012-11-261-0/+23
| | | | | | | | | | | | | syntactic locations around class specifiers. This change list implemented logic that explicitly detects several combinations of locations where C++11 attribute specifiers might be incorrectly placed within a class specifier. Previously we emit generic diagnostics like "expected identifier" for such cases; now we emit specific diagnostic against the misplaced attributes, this also fixed a bug in old code where attributes appear at legitimate locations were incorrectly rejected. Thanks to Richard Smith for reviewing! llvm-svn: 168626
* Teach Clang parser to reject C++11 attributes that appertain to declaration ↵Michael Han2012-11-061-0/+7
| | | | | | | | | specifiers. We don't support any C++11 attributes that appertain to declaration specifiers so reject the attributes in parser until we support them; this also conforms to what g++ 4.8 is doing. llvm-svn: 167481
* Improve C++11 attribute parsing.Michael Han2012-10-031-4/+15
| | | | | | | | - General C++11 attributes were previously parsed and ignored. Now they are parsed and stored in AST. - Add support to parse arguments of attributes that in 'gnu' namespace. - Differentiate unknown attributes and known attributes that can't be applied to statements when emitting diagnostic. llvm-svn: 165082
* Recognize GNU attributes after 'enum class'. Fixes the libc++ build.John McCall2012-06-231-0/+5
| | | | llvm-svn: 159089
* Clean up a large number of C++11 attribute parse issues, including parsingAlexis Hunt2012-06-231-2/+128
| | | | | | | | | | | | | | | | | | attributes in more places where we didn't and catching a lot more issues. This implements nearly every aspect of C++11 attribute parsing, except for: - Attributes are permitted on explicit instantiations inside the declarator (but not preceding the decl-spec) - Attributes are permitted on friend declarations of functions. - Multiple instances of the same attribute in an attribute-list (e.g. [[noreturn, noreturn]], not [[noreturn]] [[noreturn]] which is conforming) are allowed. The first two are marked as expected-FIXME in the test file and the latter is probably a defect and is currently untested. Thanks to Richard Smith for providing the lion's share of the testcases. llvm-svn: 159072
* Support C++11 attributes at the start of a parameter-declaration.Richard Smith2012-04-111-0/+4
| | | | llvm-svn: 154476
* Parsing of C++11 attributes:Richard Smith2012-04-101-1/+8
| | | | | | | | | | * Alternative tokens (such as 'compl') are treated as identifiers in attribute names. * An attribute-list can start with a comma. * An ellipsis may not be used with either of our currently-supported C++11 attributes. llvm-svn: 154381
* Disambiguation of '[[':Richard Smith2012-04-101-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * In C++11, '[[' is ill-formed unless it starts an attribute-specifier. Reject array sizes and array indexes which begin with a lambda-expression. Recover by parsing the lambda as a lambda. * In Objective-C++11, either '[' could be the start of a message-send. Fully disambiguate this case: it turns out that the grammars of message-sends, lambdas and attributes do not actually overlap. Accept any occurrence of '[[' where either '[' starts a message send, but reject a lambda in an array index just like in C++11 mode. Implement a couple of changes to the attribute wording which occurred after our attributes implementation landed: * In a function-declaration, the attributes go after the exception specification, not after the right paren. * A reference type can have attributes applied. * An 'identifier' in an attribute can also be a keyword. Support for alternative tokens (iso646 keywords) in attributes to follow. And some bug fixes: * Parse attributes after declarator-ids, even if they are not simple identifiers. * Do not accept attributes after a parenthesized declarator. * Accept attributes after an array size in a new-type-id. * Partially disamiguate 'delete' followed by a lambda. More work is required here for the case where the lambda-introducer is '[]'. llvm-svn: 154369
* In C++11 mode, when an integral constant expression is desired and we have aRichard Smith2012-02-041-2/+2
| | | | | | | | | | | | | | | | | | value of class type, look for a unique conversion operator converting to integral or unscoped enumeration type and use that. Implements [expr.const]p5. Sema::VerifyIntegerConstantExpression now performs the conversion and returns the converted result. Some important callers of Expr::isIntegralConstantExpr have been switched over to using it (including all of those required for C++11 conformance); this switch brings a side-benefit of improved diagnostics and, in several cases, simpler code. However, some language extensions and attributes have not been moved across and will not perform implicit conversions on constant expressions of literal class type where an ICE is required. In passing, fix static_assert to perform a contextual conversion to bool on its argument. llvm-svn: 149776
* Stub out the Sema interface for lambda expressions, and change the parser to ↵Eli Friedman2012-01-041-1/+1
| | | | | | use it. Unconditionally error on lambda expressions because they don't work in any meaningful way yet. llvm-svn: 147515
* Update all tests other than Driver/std.cpp to use -std=c++11 rather thanRichard Smith2011-10-131-1/+1
| | | | | | -std=c++0x. Patch by Ahmed Charles! llvm-svn: 141900
* Add support for alignment-specifiers in C1X and C++11, removePeter Collingbourne2011-09-291-3/+3
| | | | | | | support for the C++0x draft [[align]] attribute and add the C1X standard header file stdalign.h llvm-svn: 140796
* Add support for parsing an attribute-specifier-seq containing multiplePeter Collingbourne2011-09-291-0/+1
| | | | | | attribute-specifiers llvm-svn: 140794
* Add support for parsing the optional attribute-specifier-seq at thePeter Collingbourne2011-09-291-0/+2
| | | | | | end of a decl-specifier-seq llvm-svn: 140793
* Parsing of C++0x lambda expressions, from John Freeman with help fromDouglas Gregor2011-08-041-1/+1
| | | | | | David Blaikie! llvm-svn: 136876
* Add -fcxx-exceptions to all tests that use C++ exceptions.Anders Carlsson2011-02-281-1/+1
| | | | llvm-svn: 126599
OpenPOWER on IntegriCloud