summaryrefslogtreecommitdiffstats
path: root/clang/test/Parser
Commit message (Collapse)AuthorAgeFilesLines
...
* Check for backtraces in tests which are verifying pretty stack traces from a ↵Pete Cooper2015-02-101-1/+2
| | | | | | | | | | crashing clang. PrettyStackTrace now requires the ENABLE_BACKTRACES option. We need to check for that here or these tests fail llvm-lit. Reviewed by chandlerc llvm-svn: 228735
* Sema: Add support for __declspec(restrict)David Majnemer2015-02-041-1/+1
| | | | | | | | | | __declspec(restrict) and __attribute(malloc) are both handled identically by clang: they are allowed to the noalias LLVM attribute. Seeing as how noalias models the C99 notion of 'restrict', rename the internal clang attribute to Restrict from Malloc. llvm-svn: 228120
* MS ABI: Implement support for 'novtable'David Majnemer2015-02-021-1/+1
| | | | | | | | | | It is common for COM interface classes to be marked as 'novtable' to tell the compiler that constructors and destructors should not reference virtual function tables. This commit implements this feature in clang. llvm-svn: 227796
* Follow-up to r217302: Don't crash on ~A::A in a postfix expr suffix followed ↵Nico Weber2015-02-021-0/+5
| | | | | | | | | | | | | | | | | by '<'. This used to crash, complaining "ObjectType and scope specifier cannot coexist": struct A { } b = b.~A::A <int>; The only other caller of ParseOptionalCXXScopeSpecifier() that passes in a non-empty ObjectType clears the ObjectType of the scope specifier comes back non-empty (see the tok::period case in Parser::ParsePostfixExpressionSuffix()), so do that here too. Found by SLi's bot. llvm-svn: 227781
* Follow-up to r217302 and r227555: Don't crash on inline ~A::A() if A is an int.Nico Weber2015-01-301-0/+15
| | | | | | | | | | | | | | | | | | | Even with r227555, this still crashed: struct S { int A; ~A::A() {} }; That's because ParseOptionalCXXScopeSpecifier()'s call to ActOnCXXNestedNameSpecifier() doesn't mark the scope spec as invalid if sema thought it's a good idea to fixit-correct "::" to ":". For the diagnostic improvement done in r217302, we never want :: to be interpreted as :, so fix this by setting ColonSacred to false temporarily. Found by SLi's bot. llvm-svn: 227581
* Follow-up to r217302: Don't crash on ~A::A() if A is undeclared.Nico Weber2015-01-301-0/+2
| | | | llvm-svn: 227555
* Disable a couple of crash-* tests for now. It seems they might be ↵NAKAMURA Takumi2015-01-291-0/+3
| | | | | | incompatible to win32. llvm-svn: 227434
* Update error message text.Serge Pavlov2015-01-181-9/+9
| | | | | | | | | Previously if an enumeration was used in a nested name specifier in pre-C++11 language dialect, error message was 'XXX is not a class, namespace, or scoped enumeration'. This patch removes the word 'scoped' as in C++11 any enumeration may be used in this context. llvm-svn: 226410
* If a function decl cannot be merged, mark it as invalid.Nico Weber2015-01-172-4/+4
| | | | | | | | | | | | | | | | | | | Clang currently crashes on class C { C() = default; C() = delete; }; My cunning plan for fixing this was to change the `if (!FnD)` in Parser::ParseCXXInlineMethodDef() to `if (!FnD || FnD->isInvalidDecl)` – but alas, the second constructor decl wasn't marked as invalid. This lets Sema::MergeFunctionDecl() return true on function redeclarations, which leads to them being marked invalid. This also improves error messages when functions are redeclared. llvm-svn: 226365
* Adding option -fno-inline-asm to disallow inline asmSteven Wu2015-01-162-0/+9
| | | | | | | | | | | | | | | | Summary: This patch add a new option to dis-allow all inline asm. Any GCC style inline asm will be reported as an error. Reviewers: rnk, echristo Reviewed By: rnk, echristo Subscribers: bob.wilson, rnk, echristo, rsmith, cfe-commits Differential Revision: http://reviews.llvm.org/D6870 llvm-svn: 226340
* Fix crash-on-invalid and name lookup when recovering from ~X::X() typo.Richard Smith2015-01-151-2/+8
| | | | llvm-svn: 226067
* Parse: Don't crash when default argument in typedef consists of sole '='David Majnemer2015-01-131-0/+1
| | | | | | | | We'd crash trying to make the SourceRange for the tokens we'd like to highlight. Don't assume there is more than one token makes up the default argument. llvm-svn: 225774
* Parse: Don't crash if missing an initializer expressionDavid Majnemer2015-01-131-0/+4
| | | | llvm-svn: 225768
* Parse: use the EOF token method to lex inline method bodiesDavid Majnemer2015-01-131-2/+2
| | | | | | | | Mark the end of the method body with an EOF token, collect it once we expect to be done with method body parsing. No functionality change intended. llvm-svn: 225765
* If we don't find a matching ) for a ( in an exception specification, keep ↵Richard Smith2015-01-131-0/+8
| | | | | | the tokens around so we can diagnose an error rather than silently discarding them. llvm-svn: 225755
* [PowerPC]To provide better compatibility with gcc I added the __bool keyword ↵Bill Seurer2015-01-121-0/+14
| | | | | | | | | | | | | | | | | to the Alitivec support in clang. __bool is functionally identical to using bool when declaring vector types. For example: vector bool char v_bc; vector __bool char v___bc; clang already supported vector/__vector and pixel/__pixel but was missing __bool. http://llvm.org/bugs/show_bug.cgi?id=19220 For reference: https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/PowerPC-AltiVec_002fVSX-Built-in-Functions.html http://reviews.llvm.org/D6882 llvm-svn: 225664
* Parse: It's cleaner to handle cxx_defaultarg_end in SkipUntil directlyDavid Majnemer2015-01-121-2/+2
| | | | llvm-svn: 225616
* Parse: Don't let BalancedDelimiterTracker consume cxx_defaultarg_endDavid Majnemer2015-01-121-0/+5
| | | | | | | | It is not correct to let it consume the cxx_defaultarg_end token. I'm starting to wonder if it makes more sense to stop SkipUntil from consuming such tokens. llvm-svn: 225615
* Parse: Don't parse beyond the end of the synthetic default argument tokDavid Majnemer2015-01-121-0/+5
| | | | | | | | Recovery from malformed lambda introducers would find us consuming the synthetic default argument token, which is bad. Instead, stop right before that token. llvm-svn: 225613
* Parse: Don't crash when an annotation token shows up in a C++11 attrDavid Majnemer2015-01-091-0/+7
| | | | | | | It's not safe to blindly call getIdentifierInfo without checking the token is not an annotation token. llvm-svn: 225533
* Parse: Don't crash when namespace is in GNU statement exprDavid Majnemer2015-01-091-1/+5
| | | | | | | | | | | Parser::ParseNamespace can get a little confused when it found itself inside a compound statement inside of a non-static data member initializer. Try to determine that the statement expression's scope makes sense before trying to parse it's contents. llvm-svn: 225514
* Parse: Don't crash when trailing return type is missingDavid Majnemer2015-01-091-0/+7
| | | | | | | | | Sema::CheckParmsForFunctionDef can't cope with a null TypeSourceInfo. Don't let the AST contain the malformed lambda. This fixes PR22122. llvm-svn: 225505
* Parse: __attribute__((keyword)) shouldn't errorDavid Majnemer2015-01-032-2/+2
| | | | | | | Weird constructs like __attribute__((inline)) or __attibute__((typename)) should result in warnings, not errors. llvm-svn: 225118
* Crash even less on malformed attributes in an incorrect location.Nico Weber2014-12-291-4/+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/+4
| | | | | | | | | | | | | | | | | | 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
* Don't crash on surprising tokens in default parameter template lists.Nico Weber2014-12-281-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | Fixes this snippet from SLi's afl fuzzer output: class { i (x = <, enum This parsed i as a function, x as a paramter, and the stuff after < as a template list. This then called TryConsumeDeclarationSpecifier() which called TryAnnotateCXXScopeToken() without checking the preconditions of this function. Check them before calling, like all other callers of TryAnnotateCXXScopeToken() do. A more readable reproducer that causes the same crash is class { void i(int x = MyTemplateClass<int, union int>::foo()); }; The reduced version used an eof token as surprising token, but kw_int works just as well to repro and is easier to insert into a test file. llvm-svn: 224906
* Parse: Don't crash when 'typename' shows up in an attributeDavid Majnemer2014-12-282-1/+3
| | | | | | | | | isDeclarationSpecifier performs error recovers which jostles the token stream. Specifically, TryAnnotateTypeOrScopeToken will end up consuming a typename token which will confuse the attribute parsing machinery as we no-longer have something identifier-like. llvm-svn: 224903
* Parse: Don't parse after the eof has been consumedDavid Majnemer2014-12-181-0/+4
| | | | | | | | | | | | | | ParseCXXNonStaticMemberInitializer stashes away all the tokens for the initializer and an additional EOF token to denote where the initializer ends. However, it is possible for ParseLexedMemberInitializer to get its hands on the "real" EOF token; since the two tokens are indistinguishable, we end up consuming the EOF and descend into madness. Instead, make it possible to tell which EOF token we are looking at. This fixes PR21872. llvm-svn: 224505
* [Objective-C]. Modern property getters have side-effects.Fariborz Jahanian2014-12-181-1/+1
| | | | | | | | So, place warning about property getter should not be used for side-effect under its own group so warning can be turned off. rdar://19137815 llvm-svn: 224479
* Parse: Consume tokens more carefully in CheckForLParenAfterColonColonDavid Majnemer2014-12-171-1/+9
| | | | | | | | | We would consume the lparen even if it wasn't followed by an identifier or a star-identifier pair. This fixes PR21815. llvm-svn: 224403
* Diagnose function template definitions inside functionsReid Kleckner2014-12-151-0/+13
| | | | | | | | | | | | | | | The parser can only be tricked into parsing a function template definition by inserting a typename keyword before the function template declaration. This used to make us crash, and now it's fixed. While here, remove an unneeded boolean parameter from ParseDeclGroup. This boolean always corresponded to non-typedef declarators at file scope. ParseDeclGroup already has precise diagnostics for the function definition typedef case, so we can let that through. Fixes PR21839. llvm-svn: 224287
* Sema: Don't leave switch stack inconsistent when recoveringDavid Majnemer2014-12-151-0/+9
| | | | | | | | | We would exit Sema::ActOnFinishSwitchStmt early if we didn't have a body. This would leave an extra SwitchStmt on the SwitchStack. This fixes PR21841. llvm-svn: 224237
* Sema: attribute((annotate)) must have at least one argumentDavid Majnemer2014-12-141-0/+1
| | | | | | | | | | Sema::handleAnnotateAttr expects that some basic validation is done on the given AttributeList. However, ProcessAccessDeclAttributeList called it directly. Instead, pass the list to ProcessDeclAttribute. This fixes PR21847. llvm-svn: 224204
* Parse: MS property members cannot have an in-class initializerDavid Majnemer2014-12-131-0/+1
| | | | | | | | | 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
* Parse: Concatenated string literals should be verified in inline asmDavid Majnemer2014-12-111-0/+1
| | | | | | | | | | While we would correctly handle asm("foo") and reject asm(L"bar"), we weren't careful to handle cases where an ascii literal could be concatenated with a wide literal. This fixes PR21822. llvm-svn: 223992
* Added a testcase to make sure the parser allowsSean Callanan2014-12-101-0/+6
| | | | | | | but ignores module imports in debugger mode, even inside functions. llvm-svn: 223935
* Parse qualifiers after comma in declarator lists as a Microsoft extensionNico Rieck2014-12-042-0/+16
| | | | | | MSVC parses and ignores these with a warning. llvm-svn: 223413
* [OpenCL] Generic address space parsing and diagnostics test (forgotten ↵Anastasia Stulova2014-11-261-0/+26
| | | | | | previously) llvm-svn: 222832
* Fix crash when using __if_exists in C modeNico Rieck2014-11-241-0/+87
| | | | llvm-svn: 222665
* Improve diagnostics if _Noreturn is placed after a function declarator. ↵Richard Smith2014-11-101-1/+1
| | | | | | (This sometimes happens when a macro is used that expands to either the GNU noreturn attribute or _Noreturn.) llvm-svn: 221630
* Missing testcase from r221581.Aaron Ballman2014-11-081-0/+2
| | | | llvm-svn: 221582
* Updated the wording for a diagnostic to be more grammatically correct, and ↵Aaron Ballman2014-11-081-2/+2
| | | | | | 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-082-2/+15
| | | | llvm-svn: 221580
* [c++1z] Implement nested-namespace-definitions.Richard Smith2014-11-082-24/+38
| | | | | | | | | | | | | 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
* [c++1z] N4295: fold-expressions.Richard Smith2014-11-081-0/+29
| | | | | | | | | | | | | | | | This is a new form of expression of the form: (expr op ... op expr) where one of the exprs is a parameter pack. It expands into (expr1 op (expr2onwards op ... op expr)) (and likewise if the pack is on the right). The non-pack operand can be omitted; in that case, an empty pack gives a fallback value or an error, depending on the operator. llvm-svn: 221573
* [PowerPC] Initial VSX intrinsic support, with min/max for vector doubleBill Schmidt2014-10-313-12/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that we have initial support for VSX, we can begin adding intrinsics for programmer access to VSX instructions. This patch performs the necessary enablement in the front end, and tests it by implementing intrinsics for minimum and maximum using the vector double data type. The main change in the front end is to no longer disallow "vector" and "double" in the same declaration (lib/Sema/DeclSpec.cpp), but "vector" and "long double" must still be disallowed. The new intrinsics are accessed via vec_max and vec_min with changes in lib/Headers/altivec.h. Note that for v4f32, we already access corresponding VMX builtins, but with VSX enabled we should use the forms that allow all 64 vector registers. The new built-ins are defined in include/clang/Basic/BuiltinsPPC.def. I've added a new test in test/CodeGen/builtins-ppc-vsx.c that is similar to, but much smaller than, builtins-ppc-altivec.c. This allows us to test VSX IR generation without duplicating CHECK lines for the existing bazillion Altivec tests. Since vector double is now legal when VSX is available, I've modified the error message, and changed where we test for it and for vector long double, since the target machine isn't visible in the old place. This serendipitously removed a not-pertinent warning about 'long' being deprecated when used with 'vector', when "vector long double" is encountered and we just want to issue an error. The existing tests test/Parser/altivec.c and test/Parser/cxx-altivec.cpp have been updated accordingly, and I've added test/Parser/vsx.c to verify that "vector double" is now legitimate with VSX enabled. There is a companion patch for LLVM. llvm-svn: 220989
* PR21367: Don't accept rvalue references as an extension in C++98 mode if ↵Richard Smith2014-10-281-0/+4
| | | | | | we're in a new-type-id or conversion-type-id, since those things can legitimately be followed by a binary && operator. llvm-svn: 220785
* c++11 patch to issue warning on missing 'override' on Fariborz Jahanian2014-10-271-2/+2
| | | | | | | overriding methods. Patch review by Richard Smith. rdar://18295240 llvm-svn: 220703
* Switch C compilations to C11 by default.Richard Smith2014-10-202-2/+2
| | | | | | | | This is long-since overdue, and matches GCC 5.0. This should also be backwards-compatible, because we already supported all of C11 as an extension in C99 mode. llvm-svn: 220244
* Allow constant expressions in pragma loop hints.Tyler Nowicki2014-10-122-26/+117
| | | | | | | | Previously loop hints such as #pragma loop vectorize_width(#) required a constant. This patch allows a constant expression to be used as well. Such as a non-type template parameter or an expression (2 * c + 1). Reviewed by Richard Smith llvm-svn: 219589
OpenPOWER on IntegriCloud