summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Parsing of C++11 attributes:Richard Smith2012-04-101-26/+68
| | | | | | | | | | * 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-16/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* Support for definitions of member enumerations of class templates outside theRichard Smith2012-03-231-11/+4
| | | | | | | class template's definition, and for explicit specializations of such enum members. llvm-svn: 153304
* Fix a crash-on-invalid found by -Wlogical-op-parentheses.David Blaikie2012-03-121-1/+1
| | | | llvm-svn: 152559
* Fix parsing of trailing-return-type. Types are syntactically prohibited fromRichard Smith2012-03-121-17/+17
| | | | | | | | being defined here: [] () -> struct S {} does not define struct S. In passing, implement DR1318 (syntactic disambiguation of 'final'). llvm-svn: 152551
* Fix parsing of type-specifier-seq's. Types are syntactically allowed to beRichard Smith2012-03-121-14/+12
| | | | | | | | | | | | | | | | | | defined here, but not semantically, so new struct S {}; is always ill-formed, even if there is a struct S in scope. We also had a couple of bugs in ParseOptionalTypeSpecifier caused by it being under-loved (due to it only being used in a few places) so merge it into ParseDeclarationSpecifiers with a new DeclSpecContext. To avoid regressing, this required improving ParseDeclarationSpecifiers' diagnostics in some cases. This also required teaching ParseSpecifierQualifierList about constexpr... which incidentally fixes an issue where we'd allow the constexpr specifier in other bad places. llvm-svn: 152549
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-22/+22
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* User-defined literals: reject string and character UDLs in all places where theRichard Smith2012-03-061-1/+8
| | | | | | | | | | grammar requires a string-literal and not a user-defined-string-literal. The two constructs are still represented by the same TokenKind, in order to prevent a combinatorial explosion of different kinds of token. A flag on Token tracks whether a ud-suffix is present, in order to prevent clients from needing to look at the token's spelling. llvm-svn: 152098
* static_assert: Allow any string-literal as the message, not just a characterRichard Smith2012-03-051-1/+1
| | | | | | | string literal, and adjust the diagnostic code to match. This also causes us to escape any control characters in the message. llvm-svn: 152069
* Make late-parsed attributes follow the conventions of ordinaryDeLesley Hutchins2012-03-021-3/+13
| | | | | | | GNU attributes to a better extent, by allowing them in more places on a declator. llvm-svn: 151945
* Fix decltype crash-on-invalid, if we don't find a matching ')' for an ill-formedRichard Smith2012-02-271-2/+2
| | | | | | decltype expression. llvm-svn: 151515
* Back out __decltype warning from r151377: we should either warn on all the GNURichard Smith2012-02-241-2/+2
| | | | | | __keywords or none of them. llvm-svn: 151401
* __decltype is a GNU extension, not a C++11 extension.Richard Smith2012-02-241-0/+3
| | | | llvm-svn: 151377
* Handle "#pragma GCC visibility" in a few more places. Switch over "#pragma ↵Eli Friedman2012-02-231-0/+10
| | | | | | | | pack" to use the same handling that gcc does. Fixes <rdar://problem/10871094> and <rdar://problem/10893316>. (Hopefully, common usage of these pragmas isn't irregular enough to break our current handling. Doug has ideas for a more crazy approach if necessary.) llvm-svn: 151307
* Fix parsing and processing initializer lists in return statements and as ↵Sebastian Redl2012-02-221-9/+8
| | | | | | direct member initializers. llvm-svn: 151155
* Implement C++11 [expr.call]p11: If the operand to a decltype-specifier is aRichard Smith2012-02-221-2/+8
| | | | | | | | | | | | | | | | | | function call (or a comma expression with a function call on its right-hand side), possibly parenthesized, then the return type is not required to be complete and a temporary is not bound. Other subexpressions inside a decltype expression do not get this treatment. This is implemented by deferring the relevant checks for all calls immediately within a decltype expression, then, when the expression is fully-parsed, checking the relevant constraints and stripping off any top-level temporary binding. Deferring the completion of the return type exposed a bug in overload resolution where completion of the argument types was not attempted, which is also fixed by this change. llvm-svn: 151117
* Implement name mangling for lambda expressions that occur within theDouglas Gregor2012-02-211-2/+5
| | | | | | initializers of data members (both static and non-static). llvm-svn: 151017
* Fix crash-on-invalid for 'operator int[]()' in C++11.David Blaikie2012-02-141-3/+4
| | | | | | Signed off by Richard Smith. llvm-svn: 150464
* Added location for template keyword in TemplateSpecializationTypeLoc. In the ↵Abramo Bagnara2012-02-061-3/+3
| | | | | | process removed some naming ambiguities. llvm-svn: 149870
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-1/+1
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Move a method from IdentifierTable.h out of line and remove the SmallString ↵Benjamin Kramer2012-02-041-0/+1
| | | | | | | | include. Fix all the transitive include users. llvm-svn: 149783
* Added source location for the template keyword in AST template-id expressions.Abramo Bagnara2012-01-271-3/+7
| | | | llvm-svn: 149127
* Avoid redundant NNS qualification in constructor/destructor names.Abramo Bagnara2012-01-271-0/+1
| | | | llvm-svn: 149124
* Support decltype in member initializers.David Blaikie2012-01-241-8/+21
| | | | | | | | | | This is the last piece of N3031 (decltype in weird places) - supporting the use of decltype in a class ctor's member-initializer-list to specify the base classes to initialize. Reviewed by Richard Smith. llvm-svn: 148789
* Fix code so that a SkipUntil will ignore semicolons when skipping aRichard Trieu2012-01-211-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function body. This keeps the brace count accurate to prevent additional errors. Also, moved the caret from the brace to the function name. Code: class F{ int Foo{ return 1; } }; Fixed error: parameters.cc:1:14: error: function definition does not declare parameters class F{ int Foo{ return 1; } }; ^ 1 error generated. Old errors: parameters.cc:1:17: error: function definition does not declare parameters class F{ int Foo{ return 1; } }; ^ parameters.cc:1:30: error: expected ';' after class class F{ int Foo{ return 1; } }; ^ ; parameters.cc:1:31: error: expected external declaration class F{ int Foo{ return 1; } }; ^ 3 errors generated. llvm-svn: 148621
* Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:Richard Smith2012-01-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | - If the declarator is at the start of a line, and the previous line contained another declarator and ended with a comma, then that comma was probably a typo for a semicolon: int n = 0, m = 1, l = 2, // k = 5; myImportantFunctionCall(); // oops! - If removing the parentheses would correctly initialize the object, then produce a note suggesting that fix. - Otherwise, if there is a simple initializer we can suggest which performs value-initialization, then provide a note suggesting a correction to that initializer. Sema::Declarator now tracks the location of the comma prior to the declarator in the declaration, if there is one, to facilitate providing the note. The code to determine an appropriate initializer from the -Wuninitialized warning has been factored out to allow use in both that and -Wvexing-parse. llvm-svn: 148072
* Update C++11 scoped enumeration support to match the final proposal:Richard Smith2012-01-101-3/+4
| | | | | | | | - reject definitions of enums within friend declarations - require 'enum', not 'enum class', for non-declaring references to scoped enumerations llvm-svn: 147824
* Extend the diagnostic for a ',' at the end of a declaration where a ';' wasRichard Smith2012-01-091-4/+17
| | | | | | intended to cover C++ class definitions. llvm-svn: 147808
* Mass rename C1x references to C11. The name hasn't proliferated like "C++0x" ↵Benjamin Kramer2011-12-231-4/+4
| | | | | | | | so this patch is surprisingly small. Also drop -Wc1x-extensions in favor of -Wc11-extensions. I don't think we need to keep this around for compatibility. llvm-svn: 147221
* Use the real end of the decltype expression.David Blaikie2011-12-081-2/+1
| | | | llvm-svn: 146138
* Support decltype in nested-name-specifiers.David Blaikie2011-12-041-25/+73
| | | | llvm-svn: 145785
* When we notice that a member function is defined with "= delete" or "=Douglas Gregor2011-11-071-7/+9
| | | | | | | | | | | | default", make a note of which is used when creating the initial declaration. Previously, we would wait until later to handle default/delete as a definition, but this is too late: when adding the declaration, we already treated the declaration as "user-provided" when in fact it was merely "user-declared". Fixes PR10861 and PR10442, along with a bunch of FIXMEs. llvm-svn: 144011
* Tighten up the conditions under which we consider ourselves to beDouglas Gregor2011-11-071-7/+10
| | | | | | | entering the context of a nested-name-specifier. Fixes <rdar://problem/10397846>. llvm-svn: 143967
* Handle redundant 'typename' on base class specifications.David Blaikie2011-10-251-0/+7
| | | | llvm-svn: 142937
* Fix erroneous name-specifiers prior to decltypes better/correctly as per ↵David Blaikie2011-10-251-8/+9
| | | | | | Doug's feedback. llvm-svn: 142935
* Initialize the BaseLoc for decltype base type specifications.David Blaikie2011-10-251-0/+2
| | | | llvm-svn: 142929
* Fix cases where the optional nested-name-specifier erroneously preceeded a ↵David Blaikie2011-10-251-21/+22
| | | | | | decltype-specification when specifying a base type. llvm-svn: 142928
* Support the use of decltype for specifying base types. Fixes PR11216.David Blaikie2011-10-251-11/+27
| | | | llvm-svn: 142926
* Rework Microsoft __if_exists/__if_not_exists parsing and semanticDouglas Gregor2011-10-241-15/+18
| | | | | | | | | | | | | | | | | analysis to separate dependent names from non-dependent names. For dependent names, we'll behave differently from Visual C++: - For __if_exists/__if_not_exists at class scope, we'll just warn and then ignore them. - For __if_exists/__if_not_exists in statements, we'll treat the inner statement as a compound statement, which we only instantiate in templates where the dependent name (after instantiation) exists. This behavior is different from VC++, but it's as close as we can get without encroaching ridiculousness. The latter part (dependent statements) is not yet implemented. llvm-svn: 142864
* Add -Wc++98-compat warnings for uses of the new keywords 'alignof', 'char16_t',Richard Smith2011-10-171-0/+4
| | | | | | 'char32_t', 'constexpr', 'decltype', 'noexcept', 'nullptr' and 'static_assert'. llvm-svn: 142302
* When we end up having to parse the initializer of a C++ member earlyDouglas Gregor2011-10-171-9/+14
| | | | | | | in -fms-extensions mode, make sure we actually use that initializer after having handled the declaration. Fixes PR11150. llvm-svn: 142195
* Fixed merge-mistake where ActOnAccessSpecifier was called twice for every ↵Erik Verbruggen2011-10-171-6/+7
| | | | | | access specifier. The testcase has been changed to catch this too. llvm-svn: 142186
* Implement -Wc++98-compat warnings for the parser.Richard Smith2011-10-151-12/+19
| | | | llvm-svn: 142056
* Refactor: remove redundant check for 'final' specifier when parsing ↵Richard Smith2011-10-151-13/+4
| | | | | | class/struct definition. llvm-svn: 142054
* Rename an ExtWarn to ext_ for consistency.Richard Smith2011-10-151-1/+1
| | | | llvm-svn: 142049
* Don't warn about use of 'final' in ill-formed C++98 code which didn't useRichard Smith2011-10-151-3/+4
| | | | | | | 'final', and don't accept (then silently discard) braced init lists in C++98 new-expressions. llvm-svn: 142048
* -Wc++98-compat: warn on C++11 attributes and alignas.Richard Smith2011-10-141-0/+3
| | | | llvm-svn: 141999
* Allow for annotate attributes after access specifiers. When suchErik Verbruggen2011-10-131-5/+20
| | | | | | attributes are found, propagate them to subsequent declarations. llvm-svn: 141861
* Fix crash-on-invalid, improve error recovery, and test coverage for missing ↵David Blaikie2011-10-131-5/+16
| | | | | | colon after access specifiers in C++ llvm-svn: 141852
* Introduce BalancedDelimiterTracker, to better track open/closeDouglas Gregor2011-10-121-67/+58
| | | | | | | delimiter pairs and detect when we exceed the implementation limit for nesting depth, from Aaron Ballman! llvm-svn: 141782
OpenPOWER on IntegriCloud