summaryrefslogtreecommitdiffstats
path: root/clang/test/Parser
Commit message (Collapse)AuthorAgeFilesLines
...
* [ObjC] Improve error message for a malformed objc-type-nameErik Pilkington2019-06-261-0/+3
| | | | | | | | | | | | If the type didn't exist, we used to emit a really bad error: t.m:3:12: error: expected ')' -(nullable NoSuchType)foo3; ^ rdar://50925632 llvm-svn: 364489
* Require commas to separate multiple GNU-style attributes in the same ↵Aaron Ballman2019-06-181-2/+10
| | | | | | | | attribute list. Fixes PR38352. llvm-svn: 363676
* PR42071: Reject weird names for non-type template parameters.Richard Smith2019-06-141-0/+8
| | | | | | Also reject default arguments appearing in invalid locations. llvm-svn: 363447
* Re-check in clang support gun asm goto after fixing tests.Jennifer Yu2019-06-032-0/+110
| | | | llvm-svn: 362410
* Revert "clang support gnu asm goto."Erich Keane2019-05-302-101/+0
| | | | | | | | | | | This reverts commit 954ec09aed4f2be04bb5f4e10dbb4ea8bd19ef9a. Reverting due to test failures as requested by Jennifer Yu. Conflicts: clang/test/CodeGen/asm-goto.c llvm-svn: 362106
* clang support gnu asm goto.Jennifer Yu2019-05-302-0/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Syntax: asm [volatile] goto ( AssemblerTemplate : : InputOperands : Clobbers : GotoLabels) https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html New llvm IR is "callbr" for inline asm goto instead "call" for inline asm For: asm goto("testl %0, %0; jne %l1;" :: "r"(cond)::label_true, loop); IR: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,X,X,~{dirflag},~{fpsr},~{flags}"(i32 %0, i8* blockaddress(@foo, %label_true), i8* blockaddress(@foo, %loop)) #1 to label %asm.fallthrough [label %label_true, label %loop], !srcloc !3 asm.fallthrough: Compiler need to generate: 1> a dummy constarint 'X' for each label. 2> an unique fallthrough label for each asm goto stmt " asm.fallthrough%number". Diagnostic 1> duplicate asm operand name are used in output, input and label. 2> goto out of scope. llvm-svn: 362045
* Part of P1091R3: permit structured bindings to be declared 'static' andRichard Smith2019-05-221-4/+6
| | | | | | 'thread_local' in C++20. llvm-svn: 361424
* Rearrange and clean up how we disambiguate lambda-introducers from ObjCRichard Smith2019-05-201-2/+2
| | | | | | | | | | | | | | | | message sends, designators, and attributes. Instead of having the tentative parsing phase sometimes return an indicator to say what diagnostic to produce if parsing fails and sometimes ask the caller to run it again, consistently ask the caller to try parsing again if tentative parsing would fail or is otherwise unable to completely parse the lambda-introducer without producing an irreversible semantic effect. Mostly NFC, but we should recover marginally better in some error cases (avoiding duplicate diagnostics). llvm-svn: 361182
* Added a better diagnostic when using the delete operator with lambdasNicolas Lesser2019-05-191-10/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This adds a new error for missing parentheses around lambdas in delete operators. ``` int main() { delete []() { return new int(); }(); } ``` This will result in: ``` test.cpp:2:3: error: '[]' after delete interpreted as 'delete[]' delete []() { return new int(); }(); ^~~~~~~~~ test.cpp:2:9: note: add parentheses around the lambda delete []() { return new int(); }(); ^ ( ) ``` Reviewers: rsmith Reviewed By: rsmith Subscribers: riccibruno, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D36357 llvm-svn: 361119
* Refactor constant evaluation of typeid(T) to track a symbolic type_infoRichard Smith2019-05-171-0/+2
| | | | | | | | | | | | | | object rather than tracking the originating expression. This is groundwork for supporting polymorphic typeid expressions. (Note that this somewhat regresses our support for DR1968, but it turns out that that never actually worked anyway, at least in non-trivial cases.) This reinstates r360974, reverted in r360988, with a fix for a static_assert failure on 32-bit builds: force Type base class to have 8-byte alignment like the rest of Clang's AST nodes. llvm-svn: 360995
* Revert Refactor constant evaluation of typeid(T) to track a symbolic ↵Chris Bieneman2019-05-171-2/+0
| | | | | | | | type_info object rather than tracking the originating expression. This reverts r360974 (git commit 7ee4307bd4450022c3c8777f43a40cc4f0ccc009) llvm-svn: 360988
* Refactor constant evaluation of typeid(T) to track a symbolic type_infoRichard Smith2019-05-171-0/+2
| | | | | | | | | | object rather than tracking the originating expression. This is groundwork for supporting polymorphic typeid expressions. (Note that this somewhat regresses our support for DR1968, but it turns out that that never actually worked anyway, at least in non-trivial cases.) llvm-svn: 360974
* Implement __builtin_LINE() et. al. to support source location capture.Eric Fiselier2019-05-161-0/+19
| | | | | | | | | | | | | | | | | Summary: This patch implements the source location builtins `__builtin_LINE(), `__builtin_FUNCTION()`, `__builtin_FILE()` and `__builtin_COLUMN()`. These builtins are needed to implement [`std::experimental::source_location`](https://rawgit.com/cplusplus/fundamentals-ts/v2/main.html#reflection.src_loc.creation). With the exception of `__builtin_COLUMN`, GCC also implements these builtins, and Clangs behavior is intended to match as closely as possible. Reviewers: rsmith, joerg, aaron.ballman, bogner, majnemer, shafik, martong Reviewed By: rsmith Subscribers: rnkovacs, loskutov, riccibruno, mgorny, kunitoki, alexr, majnemer, hfinkel, cfe-commits Differential Revision: https://reviews.llvm.org/D37035 llvm-svn: 360937
* Make tentative parsing to detect template-argument-lists less aggressiveRichard Smith2019-05-151-0/+11
| | | | | | | | | | | | | | | | | | (and less wrong). It's not correct to assume that X<something, Type> is always a template-id; there are a few cases where the comma takes us into a non-expression syntactic context in which 'Type' might be permissible. Stop doing that. This slightly regresses our error recovery on the cases where the construct is intended to be a template-id. We typically do still manage to diagnose a missing 'template' keyword, but we realize this too late to properly recover from the error. This fixes a regression introduced by r360308. llvm-svn: 360827
* Add a new language mode for C2x; enable [[attribute]] support by default in C2x.Aaron Ballman2019-05-141-0/+1
| | | | llvm-svn: 360667
* Make language option `GNUAsm` discoverable with `__has_extension` macro.Volodymyr Sapsai2019-05-132-0/+8
| | | | | | | | | | | | | | | | This can be used for better support of `-fno-gnu-inline-asm` builds. rdar://problem/49540880 Reviewers: aaron.ballman, rsmith Reviewed By: aaron.ballman Subscribers: eraman, jkorous, dexonsmith, craig.topper, cfe-commits Differential Revision: https://reviews.llvm.org/D61619 llvm-svn: 360625
* Remember to decay arrays to pointers before checking whether theRichard Smith2019-05-091-0/+13
| | | | | | left-hand side of an -> operator is a pointer to class type. llvm-svn: 360387
* [c++20] Implement P0846R0: allow (ADL-only) calls to template-ids whoseRichard Smith2019-05-093-17/+21
| | | | | | | | | | | | | | | | | | | | | | | | | template name is not visible to unqualified lookup. In order to support this without a severe degradation in our ability to diagnose typos in template names, this change significantly restructures the way we handle template-id-shaped syntax for which lookup of the template name finds nothing. Instead of eagerly diagnosing an undeclared template name, we now form a placeholder template-name representing a name that is known to not find any templates. When the parser sees such a name, it attempts to disambiguate whether we have a less-than comparison or a template-id. Any diagnostics or typo-correction for the name are delayed until its point of use. The upshot should be a small improvement of our diagostic quality overall: we now take more syntactic context into account when trying to resolve an undeclared identifier on the left hand side of a '<'. In fact, this works well enough that the backwards-compatible portion (for an undeclared identifier rather than a lookup that finds functions but no function templates) is enabled in all language modes. llvm-svn: 360308
* [hip] Fix ambiguity from `>>>` of CUDA.Michael Liao2019-05-081-0/+11
| | | | | | | | | | | | | | | | | Summary: - For template arguments ending with `>>>`, we should cease lookahead and treat it as type-id firstly, so that deduction could work properly. Reviewers: tra, yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61396 llvm-svn: 360214
* Improve function / variable disambiguation.Richard Smith2019-05-071-0/+2
| | | | | | | | Keep looking for decl-specifiers after an unknown identifier. Don't issue diagnostics about an error type specifier conflicting with later type specifiers. llvm-svn: 360117
* [C++] Interpret unknown identifier in parameter clause as unknown typeNicolas Lesser2019-05-051-1/+1
| | | | | | instead of as parameter name without a type. llvm-svn: 359979
* [c++20] Implement P0428R2 - Familiar template syntax for generic lambdasHamza Sood2019-05-041-0/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D36527 llvm-svn: 359967
* Consume unexpected "template" keywords after "using"Richard Trieu2019-05-011-0/+52
| | | | | | | | | | The parser was dealing with unexpected "template" keywords after "using" keywords too late and putting the parser into the wrong state, which could lead to a crash down the line. This change allows the parser to consume the bad "template" keywords earlier, and continue parsing as if "template" was never there to begin with for better error recovery. llvm-svn: 359740
* [Sema][MSVC] Fix bogus microsoft-pure-definition warning on member function ↵Bruno Ricci2019-04-211-0/+12
| | | | | | | | | | | | | | | | | | | | | | of class template Clang emits a warning when using a pure specifier =0 in a function definition at class scope (a MS-specific construct), when using -fms-extensions. However, to detect this, it was using FD->isCanonicalDecl() on function declaration, which was also detecting out-of-class definition of member functions of class templates. Fix this by using !FD->isOutOfLine() instead. Fixes PR21334. Differential Revision: https://reviews.llvm.org/D29707 Reviewed By: riccibruno Reviewers: rnk, riccibruno Patch By: Rudy Pons llvm-svn: 358849
* PR41192: fix cases where "missing ';' after class" error wouldRichard Smith2019-04-161-0/+11
| | | | | | incorrectly fire. llvm-svn: 358467
* Add support for attributes on @implementations in Objective-CErik Pilkington2019-04-113-5/+59
| | | | | | | | | We want to make objc_nonlazy_class apply to implementations, but ran into this. There doesn't seem to be any reason that this isn't supported. Differential revision: https://reviews.llvm.org/D60542 llvm-svn: 358200
* [OpenCL] Allow addr space spelling without __ prefix in C++.Anastasia Stulova2019-03-251-15/+17
| | | | | | | | | | | | | | For backwards compatibility we allow alternative spelling of address spaces - 'private', 'local', 'global', 'constant', 'generic'. In order to accept 'private' correctly, parsing has been changed to understand different use cases - access specifier vs address space. Fixes PR40707 and PR41011! Differential Revision: https://reviews.llvm.org/D59603 llvm-svn: 356888
* Add a __has_extension check for '#pragma clang attribute' as an ↵Erik Pilkington2019-03-201-0/+4
| | | | | | | | external-declaration This was added in r356075. llvm-svn: 356600
* Fix test after r356148Nico Weber2019-03-141-1/+4
| | | | llvm-svn: 356154
* Objective-C++11: Support static_assert() in @interface/@implementation ivar ↵Nico Weber2019-03-142-0/+128
| | | | | | | | | | | | | | | | | | | | | | lists and method declarations This adds support for static_assert() (and _Static_assert()) in @interface/@implementation ivar lists and in @interface method declarations. It was already supported in @implementation blocks outside of the ivar lists. The assert AST nodes are added at file scope, matching where other (non-Objective-C) declarations at @interface / @implementation level go (cf `allTUVariables`). Also add a `__has_feature(objc_c_static_assert)` that's true in C11 (and `__has_extension(objc_c_static_assert)` that's always true) and `__has_feature(objc_cxx_static_assert)` that's true in C++11 modea fter this patch, so it's possible to check if this is supported. Differential Revision: https://reviews.llvm.org/D59223 llvm-svn: 356148
* Fix a failing test.Erik Pilkington2019-03-131-2/+2
| | | | llvm-svn: 356087
* [Parse] Parse '#pragma clang attribute' as an external-declarationErik Pilkington2019-03-131-0/+34
| | | | | | | | | | | Previously, we parsed it only in the top level, which excludes namespaces and extern "C" blocks. rdar://problem/48818890 Differential revision: https://reviews.llvm.org/D59282 llvm-svn: 356075
* Add two new pragmas for controlling software pipelining optimizations.Aaron Ballman2019-01-043-2/+35
| | | | | | | | This patch adds #pragma clang loop pipeline and #pragma clang loop pipeline_initiation_interval for debugging or reducing compile time purposes. It is possible to disable SWP for concrete loops to save compilation time or to find bugs by not doing SWP to certain loops. It is possible to set value of initiation interval to concrete number to save compilation time by not doing extra pipeliner passes or to check created schedule for specific initiation interval. Patch by Alexey Lapshin. llvm-svn: 350414
* Refactor the way we handle diagnosing unused expression results.Aaron Ballman2019-01-042-5/+5
| | | | | | | | Rather than sprinkle calls to DiagnoseUnusedExprResult() around in places where we want diagnostics, we now diagnose unused expression statements and full expressions in a more generic way when acting on the final expression statement. This results in more appropriate diagnostics for [[nodiscard]] where we were previously lacking them, such as when the body of a for loop is not a compound statement. This patch fixes PR39837. llvm-svn: 350404
* Add support for namespaces on #pragma clang attributeErik Pilkington2018-12-201-1/+1
| | | | | | | | | | | | | | | | Namespaces are introduced by adding an "identifier." before a push/pop directive. Pop directives with namespaces can only pop a attribute group that was pushed with the same namespace. Push and pop directives that don't opt into namespaces have the same semantics. This is necessary to prevent a pitfall of using multiple #pragma clang attribute directives spread out in a large file, particularly when macros are involved. It isn't easy to see which pop corripsonds to which push, so its easy to inadvertently pop the wrong group. Differential revision: https://reviews.llvm.org/D55628 llvm-svn: 349845
* Move AST tests into their own test directory; NFC.Aaron Ballman2018-11-301-21/+0
| | | | | | This moves everything primarily testing the functionality of -ast-dump and -ast-print into their own directory, rather than leaving the tests spread around the testing directory. llvm-svn: 348017
* [MS] Push outermost class DeclContexts only in -fdelayed-template-parsingReid Kleckner2018-11-271-0/+30
| | | | | | | This is more or less a complete rewrite of r347627, and it fixes PR38460 I added a reduced test case to DelayedTemplateParsing.cpp. llvm-svn: 347713
* Revert r347627 "[MS] Push fewer DeclContexts for delayed template parsing"Reid Kleckner2018-11-271-17/+0
| | | | | | | | | | | It broke the Windows self-host: http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/1799/steps/stage%202%20build/logs/stdio I can build lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/MachinePostDominators.cpp.obj to repro. llvm-svn: 347630
* [MS] Push fewer DeclContexts for delayed template parsingReid Kleckner2018-11-271-0/+17
| | | | | | | | | | | | | Only push the outermost record as a DeclContext when parsing a function body. See the comments in Sema::getContainingDC about the way the parser pushes contexts. This is intended to match the behavior the parser normally displays where it parses all method bodies from all nested classes at the end of the outermost class, when all nested classes are complete. Fixes PR38460. llvm-svn: 347627
* [clang][Parse] Diagnose useless null statements / empty init-statementsRoman Lebedev2018-11-202-0/+160
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: clang has `-Wextra-semi` (D43162), which is not dictated by the currently selected standard. While that is great, there is at least one more source of need-less semis - 'null statements'. Sometimes, they are needed: ``` for(int x = 0; continueToDoWork(x); x++) ; // Ugly code, but the semi is needed here. ``` But sometimes they are just there for no reason: ``` switch(X) { case 0: return -2345; case 5: return 0; default: return 42; }; // <- oops ;;;;;;;;;;; <- OOOOPS, still not diagnosed. Clearly this is junk. ``` Additionally: ``` if(; // <- empty init-statement true) ; switch (; // empty init-statement x) { ... } for (; // <- empty init-statement int y : S()) ; } As usual, things may or may not go sideways in the presence of macros. While evaluating this diag on my codebase of interest, it was unsurprisingly discovered that Google Test macros are *very* prone to this. And it seems many issues are deep within the GTest itself, not in the snippets passed from the codebase that uses GTest. So after some thought, i decided not do issue a diagnostic if the semi is within *any* macro, be it either from the normal header, or system header. Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=39111 | PR39111 ]] Reviewers: rsmith, aaron.ballman, efriedma Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52695 llvm-svn: 347339
* [NFC] Fix formatting in inline nested namespace definition.Erich Keane2018-11-121-11/+11
| | | | | | | | Apparently my invocation of clang-format in VIM didn't get this right, but the patch-version DID. This patch just runs CF on this file. Change-Id: Ied462a2d921cbb813fa427740d3ef6e97959b56d llvm-svn: 346696
* Implement P1094R2 (nested inline namespaces)Erich Keane2018-11-121-0/+51
| | | | | | | | As approved for the Working Paper in San Diego, support annotating inline namespaces with 'inline'. Change-Id: I51a654e11ffb475bf27cccb2458768151619e384 llvm-svn: 346677
* Introduce the _Clang scoped attribute token.Aaron Ballman2018-11-091-0/+8
| | | | | | Currently, we only accept clang as the scoped attribute identifier for double square bracket attributes provided by Clang, but this has the potential to conflict with user-defined macros. To help alleviate these concerns, this introduces the _Clang scoped attribute identifier as an alias for clang. It also introduces a warning with a fixit on the off chance someone attempts to use __clang__ as the scoped attribute (which is a predefined compiler identification macro). llvm-svn: 346521
* Revert "Revert "Support for groups of attributes in #pragma clang attribute""Erik Pilkington2018-10-291-3/+4
| | | | | | | This reverts commit r345487, which reverted r345486. I think the crashes were caused by an OOM on the builder, trying again to confirm... llvm-svn: 345517
* Revert "Support for groups of attributes in #pragma clang attribute"Erik Pilkington2018-10-291-4/+3
| | | | | | | | | This reverts commit r345486. Looks like it causes some old versions of GCC to crash, I'll see if I can work around it and recommit... llvm-svn: 345487
* Support for groups of attributes in #pragma clang attributeErik Pilkington2018-10-291-3/+4
| | | | | | | | | | | | | | | | | | This commit enables pushing an empty #pragma clang attribute push, then adding multiple attributes to it, then popping them all with #pragma clang attribute pop, just like #pragma clang diagnostic. We still support the current way of adding these, #pragma clang attribute push(__attribute__((...))), by treating it like a combined push/attribute. This is needed to create macros like: DO_SOMETHING_BEGIN(attr1, attr2, attr3) // ... DO_SOMETHING_END rdar://45496947 Differential revision: https://reviews.llvm.org/D53621 llvm-svn: 345486
* PR31978: Don't crash if CodeGen sees a top-level BindingDecl.Richard Smith2018-10-261-0/+1
| | | | llvm-svn: 345362
* [cxx2a] P0614R1: Support init-statements in range-based for loops.Richard Smith2018-09-281-0/+34
| | | | | | | We don't yet support this for the case where a range-based for loop is implicitly rewritten to an ObjC for..in statement. llvm-svn: 343350
* [CUDA] Fixed parsing of optional template-argument-list.Artem Belevich2018-09-212-2/+8
| | | | | | | | | We need to consider all tokens that start with '>' when we're checking for the end of an empty template argument list. Differential Revision: https://reviews.llvm.org/D52321 llvm-svn: 342752
* Allow all supportable non-type attributes to be used with #pragma clang ↵Richard Smith2018-09-051-1/+3
| | | | | | | | | | | | | | | | | attribute. Summary: We previously disallowed use of undocumented attributes with #pragma clang attribute, but the justification for doing so was weak and it prevented many reasonable use cases. Reviewers: aaron.ballman, arphaman Subscribers: cfe-commits, rnk, benlangmuir, dexonsmith, erik.pilkington Differential Revision: https://reviews.llvm.org/D51507 llvm-svn: 341437
OpenPOWER on IntegriCloud