summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* A static_assert declaration cannot be a template; adding the diagnostic for ↵Aaron Ballman2014-08-041-3/+4
| | | | | | this instead of silently accepting and producing possibly-unexpected behavior. llvm-svn: 214770
* Diagnose GNU-style attributes preceding virt-specifiers, but only when the ↵Aaron Ballman2014-08-041-3/+12
| | | | | | | | attribute is known to GCC. Clang accepts attributes in this position, but GCC does not, so this is a GCC-compat warning. If the attribute is not known to GCC, then the diagnostic is suppressed. llvm-svn: 214730
* Improve error recovery around colon.Serge Pavlov2014-07-161-15/+16
| | | | | | | | | | | | Recognize additional cases, when '::' is mistyped as ':'. This is a fix to RP18587 - colons have too much protection in member-declarations Review is tracked by http://reviews.llvm.org/D3653. This is an attempt to recommit the fix, initially committed as r212957 but then reverted in r212965 as it broke self-build. In the updated patch ParseDirectDeclarator turns on colon protection in for context as well. llvm-svn: 213120
* Revert "Improve error recovery around colon."Reid Kleckner2014-07-141-16/+15
| | | | | | | | This reverts commit r212957. It broke the self-host on code like this from LLVM's option library: for (auto Arg: filtered(Id0, Id1, Id2)) llvm-svn: 212965
* Improve error recovery around colon.Serge Pavlov2014-07-141-15/+16
| | | | | | | | | Recognize additional cases, when '::' is mistyped as ':'. This is a fix to RP18587 - colons have too much protection in member-declarations. Differential Revision: http://reviews.llvm.org/D3653 llvm-svn: 212957
* [C++1z] Implement N3928: message in static_assert is optional.Richard Smith2014-06-201-14/+24
| | | | llvm-svn: 211394
* [c++1z] Implement N3994: a range-based for loop can declare a variable with ↵Richard Smith2014-06-191-8/+14
| | | | | | | | | | | | super-terse notation for (x : range) { ... } which is equivalent to for (auto &&x : range) { ... } llvm-svn: 211267
* PR19993: don't assert/crash if a static data member is initialized by '= ↵Richard Smith2014-06-111-2/+2
| | | | | | delete;'. llvm-svn: 210617
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-9/+9
| | | | | | takeAs to getAs. llvm-svn: 209800
* Fix line endings.Nikola Smiljanic2014-05-281-9/+9
| | | | llvm-svn: 209727
* [C++11] Use 'nullptr'. Parser edition.Craig Topper2014-05-211-59/+63
| | | | llvm-svn: 209275
* Refactor all the checking for missing 'template<>'s when a declaration has aRichard Smith2014-04-171-12/+5
| | | | | | template-id after its scope specifier into a single place. llvm-svn: 206442
* Partial revert of r206229, to get the build bots green again.Aaron Ballman2014-04-151-8/+9
| | | | llvm-svn: 206237
* Fixing a typo, updating the diagnostic wording and logic based on ↵Aaron Ballman2014-04-151-5/+5
| | | | | | post-commit review feedback. Amends r206186. llvm-svn: 206229
* Properly diagnose standard C++ attributes which have optional argument lists ↵Aaron Ballman2014-04-141-9/+29
| | | | | | | | | | | when the arguments are elided. eg) [[deprecated()]] // error [[deprecated]] // OK [[deprecated("")]] // OK [[gnu::deprecated()]] // OK llvm-svn: 206186
* [MS-ABI] Add support for #pragma section and related pragmasWarren Hunt2014-04-081-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for the msvc pragmas section, bss_seg, code_seg, const_seg and data_seg as well as support for __declspec(allocate()). Additionally it corrects semantics and adds diagnostics for __attribute__((section())) and the interaction between the attribute and the msvc pragmas and declspec. In general conflicts should now be well diganosed within and among these features. In supporting the pragmas new machinery for uniform lexing for msvc pragmas was introduced. The new machinery always lexes the entire pragma and stores it on an annotation token. The parser is responsible for parsing the pragma when the handling the annotation token. There is a known outstanding bug in this implementation in C mode. Because these attributes and pragmas apply _only_ to definitions, we process them at the time we detect a definition. Due to tentative definitions in C, we end up processing the definition late. This means that in C mode, everything that ends up in a BSS section will end up in the _last_ BSS section rather than the one that was live at the time of tentative definition, even if that turns out to be the point of actual definition. This issue is not known to impact anything as of yet because we are not aware of a clear use or use case for #pragma bss_seg but should be fixed at some point. Differential Revision=http://reviews.llvm.org/D3065#inline-16241 llvm-svn: 205810
* Render anonymous entities as '(anonymous <thing>)' (and lambdas as '(lambda ↵David Blaikie2014-04-021-1/+1
| | | | | | | | | | | | at ... )') For namespaces, this is consistent with mangling and GCC's debug info behavior. For structs, GCC uses <anonymous struct> but we prefer consistency between all anonymous entities but don't want to confuse them with template arguments, etc, so we'll just go with parens in all cases. llvm-svn: 205398
* Introduced an attribute syntax-neutral method for parsing attribute ↵Aaron Ballman2014-03-311-28/+52
| | | | | | 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
* [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
* Add [extern_c] attribute for modules, allowing a C module to be imported ↵Richard Smith2014-03-021-5/+36
| | | | | | within an extern "C" block in C++ code. llvm-svn: 202615
* argument -> parameter terminology fixes for FunctionTypeInfoAlp Toker2014-02-261-7/+6
| | | | | | This is a continuation of r199686. llvm-svn: 202307
* PR18870: Parse language linkage specifiers properly if the string-literal isRichard Smith2014-02-171-23/+14
| | | | | | spelled in an interesting way. llvm-svn: 201536
* MS ABI: Add support for #pragma pointers_to_membersDavid Majnemer2014-02-101-0/+5
| | | | | | | | | | | | | | | | | | | Introduce a notion of a 'current representation method' for pointers-to-members. When starting out, this is set to 'best case' (representation method is chosen by examining the class, selecting the smallest representation that would work given the class definition or lack thereof). This pragma allows the translation unit to dictate exactly what representation to use, similar to how the inheritance model keywords operate. N.B. PCH support is forthcoming. Differential Revision: http://llvm-reviews.chandlerc.com/D2723 llvm-svn: 201105
* Allow virt-specifiers after GNU attributes in member-declarators. GCC doesn'tRichard Smith2014-01-241-3/+9
| | | | | | | | | | | allow this, and we should warn on it, but it turns out that people were already relying on this. We should introduce a -Wgcc-compat warning for this if the attributes are known to GCC, but we don't currently track enough information about attributes to do so reliably. llvm-svn: 200045
* Factor out repeated parsing of a member-declarator when parsing aRichard Smith2014-01-231-69/+77
| | | | | | | | | | member-declaration. In the process, fix a couple of bugs that had crept in where we would parse the first and subsequent member-declarators differently (in particular, we didn't accept an asm-label on a member function definition within a class, and we would accept virt-specifiers and attributes in the wrong order on the first declarator but not on subsequent ones). llvm-svn: 199957
* Fix for PR9812: warn about bool instead of _Bool.Erik Verbruggen2014-01-151-9/+17
| | | | llvm-svn: 199311
* Add a new attribute 'enable_if' which can be used to control overload ↵Nick Lewycky2014-01-111-1/+1
| | | | | | resolution based on the values of the function arguments at the call site. llvm-svn: 198996
* TryConsume parser cleanupsAlp Toker2014-01-101-33/+14
| | | | | | Also move some comments into the block they were meant to describe. llvm-svn: 198935
* Implement isCXX11FinalKeyword() in terms of isCXX11VirtSpecifier()Alp Toker2014-01-091-34/+19
| | | | | | | | | | | | It's not worth keeping two copies of the identifier init and comparison code just to save a pointer coparison. This should reduce further once we get proper contextual keywords in the token stream, so having the identifier checks in one place is a step towards that. Cleanup only. llvm-svn: 198814
* PR18234: Mark a tag definition as invalid early if it appears in aRichard Smith2014-01-081-3/+4
| | | | | | | | 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
* Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth2014-01-071-1/+1
| | | | | | | encodes the canonical rules for LLVM's style. I noticed this had drifted quite a bit when cleaning up LLVM, so wanted to clean up Clang as well. llvm-svn: 198686
* Simplify diagnostic tag type using the token kind formatterAlp Toker2014-01-061-7/+2
| | | | | | As far as the parser is concerned the tag type is always a keyword. llvm-svn: 198606
* Parse: Token consumption modernization and loop de-nestingAlp Toker2014-01-051-8/+4
| | | | | | Cleanup only. llvm-svn: 198539
* ExpectAndConsume: Diagnose errors automaticallyAlp Toker2014-01-011-22/+25
| | | | | | | | | | | | | | 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
* Switch over more of the parser to err_expectedAlp Toker2013-12-301-17/+11
| | | | | | | Includes a fix for a missing highlight range caused by a ',' typo in the PP diagnostics. llvm-svn: 198252
* Support and use token kinds as diagnostic argumentsAlp Toker2013-12-241-11/+17
| | | | | | | | | | | | | | | | | | | 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
* Refactor the Microsoft inheritance attribute handling so that it no longer ↵Aaron Ballman2013-12-181-1/+1
| | | | | | has special treatment. Also fixes a minor bug where the attributes were being parsed as though they were GNU-style attributes when they were in fact keyword attributes. llvm-svn: 197629
* Simplify RevertibleTypeTraits as a form of contextual keywordAlp Toker2013-12-171-25/+11
| | | | | | | | | | | Now that we emit diagnostics for keyword-as-identifier hacks (-Wkeyword-compat) we can go ahead and simplify some of the old revertible keyword support. This commit adds a TryIdentKeywordUpgrade() function to mirror the recently added TryKeywordIdentFallback() and uses it to replace the hard-coded list of REVERTIBLE_TYPE_TRAITs. llvm-svn: 197496
* Parse: Recover better from bad definitions with base specifiersDavid Majnemer2013-12-051-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | We would skip until the next comma, hoping good things whould lie there, however this would fail when we have such things as this: struct A {}; template <typename> struct D; template <> struct D<C> : B, A::D; Once this happens, we would believe that D with a nested namespace specifier of A was a variable that was being declared. We would go on to complain that there was an extraneous 'template <>' on their variable declaration. Crashes would happen when 'A' gets defined as 'enum class A {}' as various asserts would fire. Instead, we should skip up until the semicolon if we see that we are in the middle of a definition and the current token is a ':' This fixes PR17084. llvm-svn: 196453
* Fix several crash-on-invalids when using template-ids that aren'tRichard Smith2013-12-041-0/+1
| | | | | | simple-template-ids (eg, 'operator+<int>') in weird places. llvm-svn: 196333
* Emit an extension warning when changing system header tokensAlp Toker2013-12-031-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Parse Microsoft __declspec appearing after class bodyAlp Toker2013-11-241-0/+1
| | | | | | | | | | MSVC applies these to the following declaration only if present, otherwise silently ignores them whereas we'll issue a warning. Handling differs from ordinary attributes appearing in the same place, so add a Sema test to make sure we get it right. llvm-svn: 195577
* Generate a marker token when entering or leaving a submodule when building aRichard Smith2013-11-231-5/+5
| | | | | | | | | 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
* PR9547: If we're parsing a simple-declaration that contains a tag definition,Richard Smith2013-11-191-0/+8
| | | | | | | | 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-30/+29
| | | | llvm-svn: 194994
* PR17949: Fix crash if someone puts a namespace inside a class template.Richard Smith2013-11-151-5/+5
| | | | llvm-svn: 194872
* Try to recover a bit better if a close brace is missing from the end of a classRichard Smith2013-11-091-5/+30
| | | | | | | definition. If we see something that looks like a namespace definition inside a class, that strongly indicates that a close brace was missing somewhere. llvm-svn: 194319
* Fix %select numbering confusion between diagnostic and Diag call.Richard Smith2013-11-081-1/+1
| | | | llvm-svn: 194281
* Untabify.Richard Smith2013-11-081-29/+25
| | | | llvm-svn: 194274
* Support GNU attributes in alias-declarations now that GCC has implemented themRichard Smith2013-10-241-4/+3
| | | | | | and we know where they go. llvm-svn: 193297
OpenPOWER on IntegriCloud