summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse
Commit message (Collapse)AuthorAgeFilesLines
* Parse/Sema: Add support for '#pragma options align=packed', which, it should beDaniel Dunbar2010-05-271-0/+2
| | | | | | noted, is not the same as __attribute__((packed)). That would be ridiculous! llvm-svn: 104865
* Parse/Sema: Add support for '#pragma options align=native'.Daniel Dunbar2010-05-271-3/+5
| | | | llvm-svn: 104864
* When we've parsed a nested-name-specifier in a member accessDouglas Gregor2010-05-271-0/+2
| | | | | | | expression, "forget" about the object type; only the nested-name-specifier matters for name lookup purposes. Fixes PR7239. llvm-svn: 104834
* Parse: Add support for '#pragma options align'.Daniel Dunbar2010-05-263-2/+67
| | | | | | Also, fix a source location bug with the rparen in #pragma pack. llvm-svn: 104784
* Improve code completion in failure cases in two ways:Douglas Gregor2010-05-257-44/+64
| | | | | | | | | | | 1) Suppress diagnostics as soon as we form the code-completion token, so we don't get any error/warning spew from the early end-of-file. 2) If we consume a code-completion token when we weren't expecting one, go into a code-completion recovery path that produces the best results it can based on the context that the parser is in. llvm-svn: 104585
* improve the fixit for the missing : error when parsing ?:. WhenChris Lattner2010-05-241-1/+22
| | | | | | | | | | | | | | | | | | | | there are already two spaces before the token where the : was expected, put the : in between the spaces. This means we get it right in both of these cases: t.c:2:17: error: expected ':' return a ? b c; ^ : t.c:3:16: error: expected ':' return a ? b c; ^ : In the later case, the diagnostic says to insert ": ", in the former case it says to insert ":" between the spaces. This fixes rdar://8007231 llvm-svn: 104569
* Improve recovery when we see a dependent template name that is missingDouglas Gregor2010-05-212-1/+31
| | | | | | | | | | | | | | | the required "template" keyword, using the same heuristics we do for dependent template names in member access expressions, e.g., test/SemaTemplate/dependent-template-recover.cpp:11:8: error: use 'template' keyword to treat 'getAs' as a dependent template name T::getAs<U>(); ^ template Fixes PR5404. llvm-svn: 104409
* Improve parser recovery when we encounter a dependent template nameDouglas Gregor2010-05-214-8/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | that is missing the 'template' keyword, e.g., t->getAs<T>() where getAs is a member of an unknown specialization. C++ requires that we treat "getAs" as a value, but that would fail to parse since T is the name of a type. We would then fail at the '>', since a type cannot be followed by a '>'. This is a very common error for C++ programmers to make, especially since GCC occasionally allows it when it shouldn't (as does Visual C++). So, when we are in this case, we use tentative parsing to see if the tokens starting at "<" can only be parsed as a template argument list. If so, we produce a diagnostic with a fix-it that states that the 'template' keyword is needed: test/SemaTemplate/dependent-template-recover.cpp:5:8: error: 'template' keyword is required to treat 'getAs' as a dependent template name t->getAs<T>(); ^ template This is just a start of this patch; I'd like to apply the same approach to everywhere that a template-id with dependent template name can be parsed. llvm-svn: 104406
* Propagate access specifiers to anonymous union members nested within classes.John McCall2010-05-214-5/+6
| | | | | | Fixes <rdar://problem/7987650>. llvm-svn: 104376
* Improve parser recovery when a switch condition is invalid; fixesDouglas Gregor2010-05-201-3/+4
| | | | | | <rdar://problem/7971948>. llvm-svn: 104291
* Added basic source locations to Elaborated and DependentName types.Abramo Bagnara2010-05-191-1/+1
| | | | llvm-svn: 104169
* Add clang support for IBOutletCollection.Ted Kremenek2010-05-191-0/+1
| | | | llvm-svn: 104135
* Add support for Microsoft's __thiscall, from Steven Watanabe!Douglas Gregor2010-05-183-4/+15
| | | | llvm-svn: 104026
* mutable is a storage class that can follow a class/struct/union definition. ↵Douglas Gregor2010-05-171-0/+1
| | | | | | Fixes PR7153 llvm-svn: 103954
* Improve error recovery in C/ObjC when the first argument of a functionChris Lattner2010-05-141-5/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | declarator is incorrect. Not being a typename causes the parser to dive down into the K&R identifier list handling stuff, which is almost never the right thing to do. Before: r.c:3:17: error: expected ')' void bar(intptr y); ^ r.c:3:9: note: to match this '(' void bar(intptr y); ^ r.c:3:10: error: a parameter list without types is only allowed in a function definition void bar(intptr y); ^ After: r.c:3:10: error: unknown type name 'intptr'; did you mean 'intptr_t'? void bar(intptr y); ^~~~~~ intptr_t r.c:1:13: note: 'intptr_t' declared here typedef int intptr_t; ^ This fixes rdar://7980651 - poor recovery for bad type in the first arg of a C function llvm-svn: 103783
* Refactor ParseFunctionDeclaratorIdentifierList to have the firstChris Lattner2010-05-141-11/+18
| | | | | | | identifier in the identifier list consumed before it is called. No functionality change. llvm-svn: 103781
* Namespaces can only be defined at global or namespace scope. Fixes PR6596.Douglas Gregor2010-05-141-0/+8
| | | | llvm-svn: 103767
* Fixed DISABLE_SMART_POINTERS breakageDouglas Gregor2010-05-061-1/+3
| | | | llvm-svn: 103198
* Rework our handling of temporary objects within the conditions ofDouglas Gregor2010-05-062-33/+75
| | | | | | | | | | | | | | | | | | | if/switch/while/do/for statements. Previously, we would end up either: (1) Forgetting to destroy temporaries created in the condition (!), (2) Destroying the temporaries created in the condition *before* converting the condition to a boolean value (or, in the case of a switch statement, to an integral or enumeral value), or (3) In a for statement, destroying the condition's temporaries at the end of the increment expression (!). We now destroy temporaries in conditions at the right times. This required some tweaking of the Parse/Sema interaction, since the parser was building full expressions too early in many places. Fixes PR7067. llvm-svn: 103187
* This patch deals with Sema Part of Setter/Getter synthesisFariborz Jahanian2010-05-051-5/+5
| | | | | | | of properties which are of C++ objects. Code Gen to follow (Radar 7468090). llvm-svn: 103123
* Support for 'template' as a disambiguator (PR7030)Douglas Gregor2010-05-051-12/+30
| | | | | | | | | | | | | ParseOptionalCXXScopeSpecifier() only annotates the subset of template-ids which are not subject to lexical ambiguity. Add support for the more general case in ParseUnqualifiedId() to handle cases such as A::template B(). Also improve some diagnostic locations. Fixes PR7030, from Alp Toker! llvm-svn: 103081
* It's okay to reference an enum in a template definition, even thoughDouglas Gregor2010-05-031-9/+12
| | | | | | it's ill-formed to form an enum template. Fixes <rdar://problem/7933063>. llvm-svn: 102926
* Replace a char*/size pair with stringref.Benjamin Kramer2010-05-031-1/+1
| | | | llvm-svn: 102902
* Add calling convention related attributes to related declaration. Mark ↵Abramo Bagnara2010-04-301-1/+1
| | | | | | attributes invalid on type related checking so to add them to declarations only when everything is ok. llvm-svn: 102710
* Fix a tentative-parse error with unqualified template ids in cast expressions.John McCall2010-04-301-0/+13
| | | | | | Also resolve a long-working FIXME in the test case I modified. llvm-svn: 102688
* Cleanup error recovery for a missing '-'|'+'Fariborz Jahanian2010-04-261-32/+24
| | | | | | on a method declaration (radar 7822196). llvm-svn: 102383
* Be more careful around dependent nested-name-specifiers, complainingDouglas Gregor2010-04-241-4/+38
| | | | | | | | when they are not complete (since we could not match them up to anything) and ensuring that enum parsing can cope with dependent elaborated-type-specifiers. Fixes PR6915 and PR6649. llvm-svn: 102247
* Rework Parser-Sema interface for Objective-C @catch exception objectDouglas Gregor2010-04-231-4/+2
| | | | | | | | | arguments. Rather than having the parser call ActOnParamDeclarator (which is a bit of a hack), call a new ActOnObjCExceptionDecl action. We'll be moving more functionality into this handler to perform earlier checking of @catch. llvm-svn: 102222
* Improve the AST representation of Objective-C @try/@catch/@finallyDouglas Gregor2010-04-231-5/+12
| | | | | | | | | | statements. Instead of the @try having a single @catch, where all of the @catch's were chained (using an O(n^2) algorithm nonetheless), @try just holds an array of its @catch blocks. The resulting AST is slightly more compact (not important) and better represents the actual language semantics (good). llvm-svn: 102221
* Make Parser::ConsumeAndStoreUntil() more consistent with Parser::SkipUntil().Argyrios Kyrtzidis2010-04-233-17/+16
| | | | | | | | | ConsumeAndStoreUntil would stop at tok::unknown when caching an inline method definition while SkipUntil would go past it while parsing the method. Fixes PR 6903. llvm-svn: 102214
* When parsing a cast-expression that starts with a scope annotation,Douglas Gregor2010-04-231-0/+8
| | | | | | | try to annotate as a type first to determine whether we have a functional-style cast. Patch by Eli Friedman, fixes PR6830. llvm-svn: 102161
* Implement parsing for message sends in Objective-C++. Message sends inDouglas Gregor2010-04-214-59/+216
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Objective-C++ have a more complex grammar than in Objective-C (surprise!), because (1) The receiver of an instance message can be a qualified name such as ::I or identity<I>::type. (2) Expressions in C++ can start with a type. The receiver grammar isn't actually ambiguous; it just takes a bit of work to parse past the type before deciding whether we have a type or expression. We do this in two places within the grammar: once for message sends and once when we're determining whether a []'d clause in an initializer list is a message send or a C99 designated initializer. This implementation of Objective-C++ message sends contains one known extension beyond GCC's implementation, which is to permit a typename-specifier as the receiver type for a class message, e.g., [typename compute_receiver_type<T>::type method]; Note that the same effect can be achieved in GCC by way of a typedef, e.g., typedef typename computed_receiver_type<T>::type Computed; [Computed method]; so this is merely a convenience. Note also that message sends still cannot involve dependent types or values. llvm-svn: 102031
* Migrate the responsibility for turning the receiver name in anDouglas Gregor2010-04-213-51/+34
| | | | | | | | | Objective-C class message expression into a type from the parser (which was doing so in two places) to Action::getObjCMessageKind() which, in the case of Sema, reduces the number of name lookups we need to perform. llvm-svn: 102026
* Rework the Parser-Sema interaction for Objective-C messageDouglas Gregor2010-04-213-39/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sends. Major changes include: - Expanded the interface from two actions (ActOnInstanceMessage, ActOnClassMessage), where ActOnClassMessage also handled sends to "super" by checking whether the identifier was "super", to three actions (ActOnInstanceMessage, ActOnClassMessage, ActOnSuperMessage). Code completion has the same changes. - The parser now resolves the type to which we are sending a class message, so ActOnClassMessage now accepts a TypeTy* (rather than an IdentifierInfo *). This opens the door to more interesting types (for Objective-C++ support). - Split ActOnInstanceMessage and ActOnClassMessage into parser action functions (with their original names) and semantic functions (BuildInstanceMessage and BuildClassMessage, respectively). At present, this split is onyl used by ActOnSuperMessage, which decides which kind of super message it has and forwards to the appropriate Build*Message. In the future, Build*Message will be used by template instantiation. - Use getObjCMessageKind() within the disambiguation of Objective-C message sends vs. array designators. Two notes about substandard bits in this patch: - There is some redundancy in the code in ParseObjCMessageExpr and ParseInitializerWithPotentialDesignator; this will be addressed shortly by centralizing the mapping from identifiers to type names for the message receiver. - There is some #if 0'd code that won't likely ever be used---it handles the use of 'super' in methods whose class does not have a superclass---but could be used to model GCC's behavior more closely. This code will die in my next check-in, but I want it in Subversion. llvm-svn: 102021
* fix the ?: fixit that ted added to recover properly.Chris Lattner2010-04-201-5/+5
| | | | llvm-svn: 101943
* Fix crash on invalid code where a @throw statement is not followed by a ';'Ted Kremenek2010-04-201-1/+2
| | | | llvm-svn: 101941
* Keep track of the actual storage specifier written on a variable orDouglas Gregor2010-04-191-0/+1
| | | | | | | | function declaration, since it may end up being changed (e.g., "extern" can become "static" if a prior declaration was static). Patch by Enea Zaffanella and Paolo Bolzoni. llvm-svn: 101826
* Audit uses of Sema::LookupSingleName for those lookups that areDouglas Gregor2010-04-151-0/+5
| | | | | | | | | | | intended for redeclarations, fixing those that need it. Fixes PR6831. This uncovered an issue where the C++ type-specifier-seq parsing logic would try to perform name lookup on an identifier after it already had a type-specifier, which could also lead to spurious ambiguity errors (as in PR6831, but with a different test case). llvm-svn: 101419
* Feed proper source-location information into Sema::LookupSingleResult,Douglas Gregor2010-04-151-3/+3
| | | | | | | | in case it ends up doing something that might trigger diagnostics (template instantiation, ambiguity reporting, access reporting). Noticed while working on PR6831. llvm-svn: 101412
* Fix 80-cols violtaionsAlexis Hunt2010-04-141-4/+7
| | | | llvm-svn: 101311
* Fix a -pedantic spurious warning involving @dynamic.Fariborz Jahanian2010-04-141-1/+5
| | | | llvm-svn: 101284
* Introduce a parsing action to distinguish between class, instance, andDouglas Gregor2010-04-142-10/+25
| | | | | | | | super message sends in Objective-C. No actual functionality change here, but it provides a hook so that Sema can typo-correct the receiver in some cases. llvm-svn: 101207
* Parse friend template ids as types instead of ending up inJohn McCall2010-04-141-4/+8
| | | | | | | ActOnClassTemplateSpecialization and being very confused. Fixes PR6514 (for non-templated-scope friends). llvm-svn: 101198
* Parse constructor names in friend declarations. Part of the fix forJohn McCall2010-04-131-8/+16
| | | | | | PR6207. llvm-svn: 101119
* Add fixit hint for missing ':' in ternary expressions.Ted Kremenek2010-04-121-1/+2
| | | | llvm-svn: 101073
* tighten the check for cast of super to avoid rejecting valid code,Chris Lattner2010-04-121-1/+2
| | | | | | rdar://7853261 llvm-svn: 101048
* fix a bug I noticed by inspection, correcting two reject-valid bugs.Chris Lattner2010-04-122-4/+8
| | | | llvm-svn: 101026
* fix a rejects-valid bug that I introduced, pointed out Chris Lattner2010-04-121-5/+5
| | | | | | by David Chisnall llvm-svn: 101024
* use pointer comparison instead of isStrChris Lattner2010-04-121-3/+2
| | | | llvm-svn: 101022
* fix a rejects-valid testcase involving super that I dreamt up.Chris Lattner2010-04-121-1/+3
| | | | | | | This also fixes cases where super is used in a block in a method which isn't valid. llvm-svn: 101021
OpenPOWER on IntegriCloud