summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Parse: Don't crash when an annotation token shows up in a C++11 attrDavid Majnemer2015-01-091-3/+5
| | | | | | | 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-1/+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/+10
| | | | | | | | | | | | | | | | | | 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
* SemaCXX: Don't crash when annotation tokens show up before the tag nameDavid Majnemer2014-12-291-1/+2
| | | | | | | | Clang has a hack to accept definitions of structs with tag names which have the same name as intrinsics. However, this hack didn't guard against annotation tokens showing up in the token stream. llvm-svn: 224909
* Added a fixit to remove empty parens from a C++11 attribute argument list ↵Aaron Ballman2014-12-191-2/+2
| | | | | | when we diagnose this as an error. llvm-svn: 224595
* Parse: MS property members cannot have an in-class initializerDavid Majnemer2014-12-131-1/+4
| | | | | | | | | We would crash trying to treat a property member as a field. These shoudl be forbidden anyway, reject programs which contain them. This fixes PR21840. llvm-svn: 224193
* Recognize __unaligned keyword after type specifierNico Rieck2014-12-041-0/+1
| | | | | | | | The __unaligned keyword can appear after a struct definition: struct foo {...} __unaligned *x; llvm-svn: 223412
* Wire up delayed typo correction to DiagnoseEmptyLookup and set upKaelyn Takata2014-11-201-1/+1
| | | | | | | | | Sema::ActOnIdExpression to use the new functionality. Among other things, this allows recovery in several cases where it wasn't possible before (e.g. correcting a mistyped static_cast<>). llvm-svn: 222464
* PR21437, final part of DR1330: delay-parsing of exception-specifications. ThisRichard Smith2014-11-131-7/+75
| | | | | | | is a re-commit of Doug's r154844 (modernized and updated to fit into current Clang). llvm-svn: 221918
* Updated the wording for a diagnostic to be more grammatically correct, and ↵Aaron Ballman2014-11-081-1/+6
| | | | | | 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-5/+11
| | | | llvm-svn: 221580
* [c++1z] Implement nested-namespace-definitions.Richard Smith2014-11-081-19/+18
| | | | | | | | | | | | | This allows 'namespace A::B { ... }' as a shorthand for 'namespace A { namespace B { ... } }'. We already supported this correctly for error recovery; promote that support to a full implementation. This is not the right implementation: we do not maintain source fidelity because we desugar the nested namespace definition in the parser. This is tricky to avoid, since the definition genuinely does inject one named entity per level in the namespace name. llvm-svn: 221574
* Remove a couple typedefs for things in the clang namespace with the same ↵Craig Topper2014-10-311-4/+4
| | | | | | name. Remove a typedef that matches an identical one in the clang namespace. llvm-svn: 220954
* -ms-extensions: Implement __super scope specifier (PR13236).Nikola Smiljanic2014-09-261-1/+8
| | | | | | | | | We build a NestedNameSpecifier that records the CXXRecordDecl in which __super appeared. Name lookup is performed in all base classes of the recorded CXXRecordDecl. Use of __super is allowed only inside class and member function scope. llvm-svn: 218484
* Suggest fix-it for missing '{' after base-clauseIsmail Pazarbasi2014-09-251-6/+36
| | | | llvm-svn: 218468
* Follow-up to r218292: Add more REVERTIBLE_TYPE_TRAITs.Nico Weber2014-09-241-2/+35
| | | | | | | | | r218292 reverted r197496 because it broke things. In addition to breaking things, r197496 also made all traits starting with __is_ revertible. Reinstantiate that part of r197496 because code out there (e.g. libc++) depends on this behavior. Fixes PR21045. llvm-svn: 218365
* Revert r197496, as it broke REVERTIBLE_TYPE_TRAITs from PCH files.Nico Weber2014-09-231-11/+25
| | | | | | Also add a test to make sure that this doesn't break again. Fixes PR21036. llvm-svn: 218292
* Don't crash on access decls with invalid scope specifier, PR20887.Nico Weber2014-09-101-0/+5
| | | | llvm-svn: 217472
* C++1y is now C++14!Aaron Ballman2014-08-191-2/+2
| | | | | | Changes diagnostic options, language standard options, diagnostic identifiers, diagnostic wording to use c++14 instead of c++1y. It also modifies related test cases to use the updated diagnostic wording. llvm-svn: 215982
* Uniformed parsing of GNU attributes at line beginnning and added GNU ↵Abramo Bagnara2014-08-161-0/+3
| | | | | | attributes parsing FIXMEs. llvm-svn: 215814
* PR20634: add some more cases that can legitimately come after a struct ↵Richard Smith2014-08-131-4/+7
| | | | | | declaration to our list of special cases. llvm-svn: 215520
* Reject virt-specifiers on friend declarations. Give anonymous bitfields aRichard Smith2014-08-121-4/+21
| | | | | | location so their diagnostics have somewhere to point. llvm-svn: 215416
* 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
OpenPOWER on IntegriCloud