summaryrefslogtreecommitdiffstats
path: root/lib/Parse/ParseDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merging r155788:Bill Wendling2012-05-121-1/+1
| | | | | | | | | | | | | | ------------------------------------------------------------------------ r155788 | rsmith | 2012-04-29 00:31:09 -0700 (Sun, 29 Apr 2012) | 4 lines PR12688: ParseCXXClassMemberDeclaration's sometimes-null ThisDecl takes another victim. Don't crash if we have a delay-parsed exception specification for a class member which is invalid in a way which precludes building a FunctionDecl. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_31@156676 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement the last part of C++ [class.mem]p2, delaying the parsing ofDouglas Gregor2012-04-161-16/+87
| | | | | | | | | | exception specifications on member functions until after the closing '}' for the containing class. This allows, for example, a member function to throw an instance of its own class. Fixes PR12564 and a fairly embarassing oversight in our C++98/03 support. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154844 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154381 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 '[]'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154369 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153304 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a crash-on-invalid found by -Wlogical-op-parentheses.David Blaikie2012-03-121-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152559 91177308-0d34-0410-b5e6-96231b3b80d8
* 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'). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152551 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152549 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152536 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152098 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152069 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151945 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix decltype crash-on-invalid, if we don't find a matching ')' for an ill-formedRichard Smith2012-02-271-2/+2
| | | | | | | decltype expression. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151515 91177308-0d34-0410-b5e6-96231b3b80d8
* Back out __decltype warning from r151377: we should either warn on all the GNURichard Smith2012-02-241-2/+2
| | | | | | | __keywords or none of them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151401 91177308-0d34-0410-b5e6-96231b3b80d8
* __decltype is a GNU extension, not a C++11 extension.Richard Smith2012-02-241-0/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151377 91177308-0d34-0410-b5e6-96231b3b80d8
* 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.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151307 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix parsing and processing initializer lists in return statements and as ↵Sebastian Redl2012-02-221-9/+8
| | | | | | direct member initializers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151155 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151117 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement name mangling for lambda expressions that occur within theDouglas Gregor2012-02-211-2/+5
| | | | | | | initializers of data members (both static and non-static). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151017 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix crash-on-invalid for 'operator int[]()' in C++11.David Blaikie2012-02-141-3/+4
| | | | | | Signed off by Richard Smith. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150464 91177308-0d34-0410-b5e6-96231b3b80d8
* Added location for template keyword in TemplateSpecializationTypeLoc. In the ↵Abramo Bagnara2012-02-061-3/+3
| | | | | | process removed some naming ambiguities. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149870 91177308-0d34-0410-b5e6-96231b3b80d8
* 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.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149799 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149783 91177308-0d34-0410-b5e6-96231b3b80d8
* Added source location for the template keyword in AST template-id expressions.Abramo Bagnara2012-01-271-3/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149127 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid redundant NNS qualification in constructor/destructor names.Abramo Bagnara2012-01-271-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149124 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148789 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148621 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148072 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147824 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147808 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147221 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the real end of the decltype expression.David Blaikie2011-12-081-2/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146138 91177308-0d34-0410-b5e6-96231b3b80d8
* Support decltype in nested-name-specifiers.David Blaikie2011-12-041-25/+73
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145785 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144011 91177308-0d34-0410-b5e6-96231b3b80d8
* 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>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143967 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle redundant 'typename' on base class specifications.David Blaikie2011-10-251-0/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142937 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix erroneous name-specifiers prior to decltypes better/correctly as per ↵David Blaikie2011-10-251-8/+9
| | | | | | Doug's feedback. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142935 91177308-0d34-0410-b5e6-96231b3b80d8
* Initialize the BaseLoc for decltype base type specifications.David Blaikie2011-10-251-0/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142929 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix cases where the optional nested-name-specifier erroneously preceeded a ↵David Blaikie2011-10-251-21/+22
| | | | | | decltype-specification when specifying a base type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142928 91177308-0d34-0410-b5e6-96231b3b80d8
* Support the use of decltype for specifying base types. Fixes PR11216.David Blaikie2011-10-251-11/+27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142926 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142864 91177308-0d34-0410-b5e6-96231b3b80d8
* 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'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142302 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142195 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142186 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement -Wc++98-compat warnings for the parser.Richard Smith2011-10-151-12/+19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142056 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactor: remove redundant check for 'final' specifier when parsing ↵Richard Smith2011-10-151-13/+4
| | | | | | class/struct definition. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142054 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename an ExtWarn to ext_ for consistency.Richard Smith2011-10-151-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142049 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142048 91177308-0d34-0410-b5e6-96231b3b80d8
* -Wc++98-compat: warn on C++11 attributes and alignas.Richard Smith2011-10-141-0/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141999 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow for annotate attributes after access specifiers. When suchErik Verbruggen2011-10-131-5/+20
| | | | | | | | attributes are found, propagate them to subsequent declarations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141861 91177308-0d34-0410-b5e6-96231b3b80d8