summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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 Microsoft __declspec attributes which have optional ↵Aaron Ballman2014-04-141-2/+13
| | | | | | | | | | argument lists when the arguments are elided. eg) __declspec(deprecated()) // error __declspec(deprecated) // OK __declspec(deprecated("")) // OK llvm-svn: 206191
* Properly diagnose standard C++ attributes which have optional argument lists ↵Aaron Ballman2014-04-141-2/+4
| | | | | | | | | | | when the arguments are elided. eg) [[deprecated()]] // error [[deprecated]] // OK [[deprecated("")]] // OK [[gnu::deprecated()]] // OK llvm-svn: 206186
* Unify __declspec attribute argument parsing with the common attribute ↵Aaron Ballman2014-03-311-109/+51
| | | | | | | | argument parsing code. This removes a diagnostic that is no longer required (the semantic engine now properly handles attribute syntax so __declspec and __attribute__ spellings no longer get mismatched). This caused several testcases to need updating for a slightly different wording. llvm-svn: 205234
* Introduced an attribute syntax-neutral method for parsing attribute ↵Aaron Ballman2014-03-311-52/+61
| | | | | | 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
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-121-1/+1
| | | | | | class. llvm-svn: 203641
* Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-071-2/+2
| | | | | | This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
* [cleanup] Re-sort includes with llvm/utils/sort_includes.py and fixChandler Carruth2014-03-041-1/+1
| | | | | | | | | | | | a missing include from CLog.h. CLog.h referenced most of the core libclang types but never directly included Index.h that provides them. Previously it got lucky and other headers were always included first but with the sorting it ended up first in one case and stopped compiling. Adding the Index.h include fixes it right up. llvm-svn: 202810
* Improve diagnostics for malformed constructor declarations (where lookup forRichard Smith2014-03-031-7/+30
| | | | | | the type of the first parameter fails, and it is the only, unnamed, parameter). llvm-svn: 202759
* argument -> parameter terminology fixes for FunctionTypeInfoAlp Toker2014-02-261-2/+2
| | | | | | This is a continuation of r199686. llvm-svn: 202307
* Do not add enums to prototype scope in C++ modes.Peter Collingbourne2014-02-221-3/+0
| | | | | | | | | | | | | | The language forbids defining enums in prototypes, so this check is normally redundant, but if an enum is defined during template instantiation it should not be added to the prototype scope. While at it, clean up the code that deals with tag definitions in prototype scope and expand the visibility warning to cover the case where an anonymous enum is defined. Differential Revision: http://llvm-reviews.chandlerc.com/D2742 llvm-svn: 201927
* Enable correcting a member declaration where the type is class template,Kaelyn Uhrain2014-02-131-1/+3
| | | | | | | | | and the class name is shadowed by another member. Recovery still needs to be figured out, which is non-trivial since the parser has already gone down a much different path than if it had recognized the class template as type instead of seeing the member that shadowed the class template. llvm-svn: 201360
* Consolidating several table-generated files containing parser-related string ↵Aaron Ballman2014-01-291-4/+12
| | | | | | | | switches into a single file. This reduces build-related complexity by replacing four separate projects (and table-gen instantiations) with a single one. No functional changes intended. llvm-svn: 200424
* Add a new attribute meta-spelling called "GCC" -- it widens into being a GNU ↵Aaron Ballman2014-01-271-1/+1
| | | | | | | | spelling, and a CXX11 spelling with the namespace "gnu". It also sets a bit on the spelling certifying that it is known to GCC. From this, we can warn about the extension appropriately. As a consequence, the FunctionDefinition functionality is completely removed. Replacing the functionality from r199676, which didn't solve the problem as elegantly. llvm-svn: 200252
* Remove some hard-coded specialness for thread-safety attributes from the ↵Aaron Ballman2014-01-201-34/+7
| | | | | | parser, and made it more declarative. If an attribute is allowed to appear on a function definition when late parsed, it can now use the FunctionDefinition attribute subject. It's treated as a FunctionDecl for most purposes, except it also gets exposed on the AttributeList so that it can be used while parsing. llvm-svn: 199676
* Don't allow 'this' within typedefs within classes that otherwise look like theyRichard Smith2014-01-171-0/+1
| | | | | | might be member function declarations. Patch by Harald van Dijk! llvm-svn: 199512
* Fix for PR9812: warn about bool instead of _Bool.Erik Verbruggen2014-01-151-48/+58
| | | | llvm-svn: 199311
* Simplifying the OpenCL image attribute. It does not need a semantic integer ↵Aaron Ballman2014-01-141-26/+2
| | | | | | parameter because the required information is encoded in the spelling. Added an appropriate subject to the attribute, and simplified the semantic checking (which will likely be expanded upon in a future patch). Also, removed the GNU spelling since it was unsupported in the first place. llvm-svn: 199229
* Removing some attribute magic related to the OpenCL keyword attributes. ↵Aaron Ballman2014-01-141-38/+17
| | | | | | Instead of mapping them to their semantics as a custom part of the parser, they instead map declaratively through the rest of the attribute system. llvm-svn: 199175
* __forceinline is a keyword, and not a GNU-style attribute. This FIXME ↵Aaron Ballman2014-01-131-3/+1
| | | | | | appears to be out-dated, and the attribute syntax is becoming more important these days. llvm-svn: 199143
* Add a new attribute 'enable_if' which can be used to control overload ↵Nick Lewycky2014-01-111-7/+24
| | | | | | resolution based on the values of the function arguments at the call site. llvm-svn: 198996
* TryConsume parser cleanupsAlp Toker2014-01-101-11/+3
| | | | | | Also move some comments into the block they were meant to describe. llvm-svn: 198935
* Attempting to appease the build bots on systems with ansi escape sequences.Aaron Ballman2014-01-091-5/+8
| | | | llvm-svn: 198887
* Removing a bit of custom parsing functionality used by the thread safety ↵Aaron Ballman2014-01-091-55/+13
| | | | | | analysis APIs. Now using tablegen to determine whether an attribute's arguments should be parsed in an unevaluated context instead of relying on a separate, hard-coded list of attributes. llvm-svn: 198883
* PR18234: Mark a tag definition as invalid early if it appears in aRichard Smith2014-01-081-7/+9
| | | | | | | | type-specifier in C++. Some checks will assert in this case otherwise (in particular, the access specifier may be missing if this happens inside a class definition, due to a violation of an AST invariant). llvm-svn: 198721
* Parse: Token consumption modernization and loop de-nestingAlp Toker2014-01-051-41/+42
| | | | | | Cleanup only. llvm-svn: 198539
* Using the quoted version of an attribute name for consistency with other ↵Aaron Ballman2014-01-021-1/+1
| | | | | | attribute diagnostics. llvm-svn: 198326
* ExpectAndConsume: Diagnose errors automaticallyAlp Toker2014-01-011-17/+16
| | | | | | | | | | | | | | 1) Teach ExpectAndConsume() to emit expected and expected-after diagnostics using the generic diagnostic descriptions added in r197972, eliminating another set of trivial err_expected_* variations while maintaining existing behaviour. 2) Lift SkipUntil() recovery out of ExpectAndConsume(). The Expect/Consume family of functions are primitive parser operations that now have the well-defined property of operating on single tokens. Factoring out recovery exposes opportunities for more consistent and tailored error recover at the call sites instead of just relying on a bottled SkipUntil formula. llvm-svn: 198270
* Recover from errors in enum definitionSerge Pavlov2013-12-311-5/+29
| | | | | | | | | | Previously any error in enum definition body stopped parsing it. With this change parser tries to recover from errors. The patch fixes PR10982. Differential Revision: http://llvm-reviews.chandlerc.com/D2018 llvm-svn: 198259
* Support and use token kinds as diagnostic argumentsAlp Toker2013-12-241-15/+14
| | | | | | | | | | | | | | | | | | | Introduce proper facilities to render token spellings using the diagnostic formatter. Replaces most of the hard-coded diagnostic messages related to expected tokens, which all shared the same semantics but had to be multiply defined due to variations in token order or quote marks. The associated parser changes are largely mechanical but they expose commonality in whole chunks of the parser that can now be factored away. This commit uses C++11 typed enums along with a speculative legacy fallback until the transition is complete. Requires corresponding changes in LLVM r197895. llvm-svn: 197972
* Remove OpenCL-specific type keywords and specifiersAlp Toker2013-12-181-62/+0
| | | | | | | | | | | | | | | This commit kills off custom type specifier and keyword handling of OpenCL C data types. Although the OpenCL spec describes them as keywords, we can handle them more elegantly as predefined types. This should provide better error correction and code completion as well as simplifying the implementation. The primary intention is however to simplify the C/C++ parser and save some packed bits on AST structures that had been extended in r170432 just for OpenCL. llvm-svn: 197578
* Move some more test-and-consumes over to TryConsumeToken()Alp Toker2013-12-171-36/+20
| | | | llvm-svn: 197537
* Bring order to the OpenCL keywordsAlp Toker2013-12-171-19/+1
| | | | | | | | | | | | Avoid the gratuitous repurposing of C++ keyword 'private' by using a keyword alias. Also attempt to document the OpenCL keywords based on scraps of information found online. The purpose of this commit is to reduce impact on the C++ parser. llvm-svn: 197511
* Refactor and micro-optimize ConsumeToken()Alp Toker2013-12-171-46/+30
| | | | | | | | | | | | 1) Introduce TryConsumeToken() to handle the common test-and-consume pattern. This brings about readability improvements in the parser and optimizes to avoid redundant checks in the common case. 2) Eliminate the ConsumeCodeCompletionTok special case from ConsumeToken(). This was used by only one caller which has been switched over to the more appropriate ConsumeCodeCompletionToken() function. llvm-svn: 197497
* Avoid extra error messages if method definition is inside function.Serge Pavlov2013-12-091-1/+2
| | | | llvm-svn: 196757
* ObjectiveC - Introducing objc_bridge_related attribute Fariborz Jahanian2013-12-041-0/+90
| | | | | | | | which specifies couple of (optional) method selectors for bridging a CFobject to or from an ObjectiveC object. This is wip. // rdsr://15499111 llvm-svn: 196408
* When parsing ignored attribute arguments, presuming the first argument is an ↵Aaron Ballman2013-12-041-1/+2
| | | | | | unresolved identifier the same way that we do for unknown arguments. This resolves PR18075, where we regressed the handling of OpenBSD's bounded attribute. llvm-svn: 196387
* Emit an extension warning when changing system header tokensAlp Toker2013-12-031-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | clang converts keywords to identifiers for compatibility with various system headers such as GNU libc. Implement a -Wkeyword-compat extension warning to diagnose those cases. The warning is on by default but will generally be ignored in system headers. It can however be enabled globally to aid standards conformance testing. This also changes the __uptr keyword avoidance from r195710 to no longer special-case system headers, bringing it in line with other similar workarounds in clang. Implementation returns bool for symmetry with token annotation functions. Some examples: warning: keyword '__is_pod' will be treated as an identifier for the remainder of the translation unit [-Wkeyword-compat] struct __is_pod warning: keyword '__uptr' will be treated as an identifier here [-Wkeyword-compat] union w *__uptr; llvm-svn: 196212
* Remove a whole lot of unused variablesAlp Toker2013-11-271-1/+0
| | | | | | | There are about 30 removed in this patch, generated by a new FixIt I haven't got round to submitting yet. llvm-svn: 195814
* Unbreak -fms-extensions with GNU libc headersAlp Toker2013-11-261-3/+12
| | | | | | | | | | | | | GNU libc uses '__uptr' as a member name in C mode, conflicting with the eponymous MSVC pointer modifier keyword. Detect and mark the token as an identifier when these specific conditions are met. __uptr will continue to work as a keyword for the remainder of the translation unit. Fixes PR17824. llvm-svn: 195710
* Generate a marker token when entering or leaving a submodule when building aRichard Smith2013-11-231-1/+4
| | | | | | | | | module. Use the marker to diagnose cases where we try to transition between submodules when not at the top level (most likely because a closing brace was missing at the end of a header file, but is also possible if submodule headers attempt to do something fundamentally non-modular, like our .def files). llvm-svn: 195543
* Fix new check for missing semicolon after struct definition to deal with theRichard Smith2013-11-201-43/+55
| | | | | | | case where the type in the following declaration is specified as a template-id, and refactor for clarity. llvm-svn: 195280
* PR9547: If we're parsing a simple-declaration that contains a tag definition,Richard Smith2013-11-191-2/+108
| | | | | | | | and we see an ill-formed declarator that would probably be well-formed if the tag definition were just missing a semicolon, use that as the diagnostic instead of producing some other mysterious error. llvm-svn: 195163
* Replaced bool parameters in SkipUntil function with single bit-based parameter.Alexey Bataev2013-11-181-41/+46
| | | | llvm-svn: 194994
* Warn on duplicate function specifierSerge Pavlov2013-11-131-5/+5
| | | | | | | | | This patch fixes PR8264. Duplicate qualifiers already are diagnozed, now the same diagnostics is issued for duplicate function specifiers. Differential Revision: http://llvm-reviews.chandlerc.com/D2025 llvm-svn: 194559
* Attributes which accept a type as their sole argument are no longer hard ↵Aaron Ballman2013-11-041-7/+17
| | | | | | coded into the parser. Instead, they are automatically listed through tablegen. llvm-svn: 193989
* Factor out custom parsing for iboutletcollection and vec_type_hint attributesRichard Smith2013-10-311-94/+47
| | | | | | | | | into a separate "parse an attribute that takes a type argument" codepath. This results in both codepaths being a lot cleaner and simpler, and fixes some bugs where the type argument handling bled into the expression argument handling and caused us to both accept invalid and reject valid attribute arguments. llvm-svn: 193731
* PR17666: Instead of allowing an initial identifier argument in any attributeRichard Smith2013-10-241-21/+38
| | | | | | | | | | | | which we don't think can't have one, only allow it in the tiny number of attributes which opts into this weird parse rule. I've manually checked that the handlers for all these attributes can in fact cope with an identifier as the argument. This is still somewhat terrible; we should move more fully towards picking the parsing rules based on the attribute, and make the Parse -> Sema interface more type-safe. llvm-svn: 193295
* PR17567: Improve diagnostic for a mistyped constructor name. If we see somethingRichard Smith2013-10-151-15/+32
| | | | | | | | | | | that looks like a function declaration, except that it's missing a return type, try typo-correcting it to the relevant constructor name. In passing, fix a bug where the missing-type-specifier recovery codepath would drop a preceding scope specifier on the floor, leading to follow-on diagnostics and incorrect recovery for the auto-in-c++98 hack. llvm-svn: 192644
* Don't get confused by a virt-specifier after a trailing-return-type - it's notRichard Smith2013-10-131-5/+10
| | | | | | an accidentally-included name for the declarator. llvm-svn: 192559
OpenPOWER on IntegriCloud