summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX
Commit message (Collapse)AuthorAgeFilesLines
* Allow TransformTypos to ignore corrections to a specified VarDecl.Kaelyn Takata2015-05-051-0/+8
| | | | | | | | | | | | | This is needed to prevent a TypoExpr from being corrected to a variable when the TypoExpr is a subexpression of that variable's initializer. Also exclude more keywords from the correction candidate pool when the subsequent token is .* or ->* since keywords like "new" or "return" aren't valid on the left side of those operators. Fixes PR23140. llvm-svn: 236519
* Diagnose delayed typos when parsing a postfix expression with anKaelyn Takata2015-05-021-0/+6
| | | | | | | | unmatched l_paren before setting the LHS to ExprError(). Fixes PR23285. llvm-svn: 236371
* Also correct typos in the middle of a ternary expression when the RHS is ↵Kaelyn Takata2015-05-011-0/+5
| | | | | | | | | | | | invalid. The LHS was already being corrected before being set to ExprError when the RHS is invalid, but when it was present the middle of a ternary expression would be dropped in the error paths. Fixes PR23350. llvm-svn: 236347
* Add -Wpessimizing-move and -Wredundant-move warnings.Richard Trieu2015-04-292-0/+271
| | | | | | | | | | | | | | | -Wpessimizing-move warns when a call to std::move would prevent copy elision if the argument was not wrapped in a call. This happens when moving a local variable in a return statement when the variable is the same type as the return type or using a move to create a new object from a temporary object. -Wredundant-move warns when an implicit move would already be made, so the std::move call is not needed, such as when moving a local variable in a return that is different from the return type. Differential Revision: http://reviews.llvm.org/D7633 llvm-svn: 236075
* Fix Sema tests using __try by adding tripleReid Kleckner2015-04-282-3/+3
| | | | llvm-svn: 236057
* Check whether the operand to a noexcept expression is valid or not. Fixes ↵Aaron Ballman2015-04-271-0/+19
| | | | | | PR15842. llvm-svn: 235931
* PR23334: Perform semantic checking of lambda capture initialization in the ↵Richard Smith2015-04-273-2/+23
| | | | | | | | | | | | | | | | | | right context. Previously we'd try to perform checks on the captures from the middle of parsing the lambda's body, at the point where we detected that a variable needed to be captured. This was wrong in a number of subtle ways. In PR23334, we couldn't correctly handle the list of potential odr-uses resulting from the capture, and our attempt to recover from that resulted in a use-after-free. We now defer building the initialization expression until we leave the lambda body and return to the enclosing context, where the initialization does the right thing. This patch only covers lambda-expressions, but we should apply the same change to blocks and captured statements too. llvm-svn: 235921
* [Sema] Do not permit binding a reference to a compound literalDavid Majnemer2015-04-261-0/+4
| | | | | | | | | We could probably make this work if we cared enough. However, we are far outside any language rules at this point. This fixes PR21834. llvm-svn: 235818
* [MS ABI] Fix the preferred alignment of member pointersDavid Majnemer2015-04-241-7/+7
| | | | | | | Member pointers in the MS ABI have different alignment depending on whether they were created on the stack or live in a record. llvm-svn: 235681
* Extend format specifier checking to include field function pointers in ↵Aaron Ballman2015-04-231-0/+15
| | | | | | addition to variable function pointers. Addresses PR21082. llvm-svn: 235606
* Don't dllimport/export class members with internal linkage (PR23308)Hans Wennborg2015-04-221-0/+6
| | | | | | | | | | For example, a function taking a parameter with internal linkage will itself have internal linkage since it cannot be called outside the translation unit. Differential Revision: http://reviews.llvm.org/D9182 llvm-svn: 235471
* Follow-up to r235046: selectany only causes a definition if it's not inherited.Nico Weber2015-04-171-0/+4
| | | | | | | | (For example needed to parse system header inputscope.h, which first has an extern "C" selectany IID and then later an extern "C" declaration of that same IID.) llvm-svn: 235174
* Move fixit for const init from note to diag, weaken to warning in MS mode.Nico Weber2015-04-175-8/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r235046 turned "extern __declspec(selectany) int a;" from a declaration into a definition to fix PR23242 (required for compatibility with mc.exe output). However, this broke parsing Windows headers: A d3d11 headers contain something like struct SomeStruct {}; extern const __declspec(selectany) SomeStruct some_struct; This is now a definition, and const objects either need an explicit default ctor or an initializer so this errors out with d3d11.h(1065,48) : error: default initialization of an object of const type 'const CD3D11_DEFAULT' without a user-provided default constructor (cl.exe just doesn't implement this rule, independent of selectany.) To work around this, weaken this error into a warning for selectany decls in microsoft mode, and recover with zero-initialization. Doing this is a bit hairy since it adds a fixit on an error emitted by InitializationSequence – this means it needs to build a correct AST, which in turn means InitializationSequence::Failed() cannot return true when this fixit is applied. As a workaround, the patch adds a fixit member to InitializationSequence, and InitializationSequence::Perform() prints the diagnostic if the fixit member is set right after its call to Diagnose. That function is usually called when InitializationSequences are used – InitListChecker::PerformEmptyInit() doesn't call it, but the InitListChecker case never performs default-initialization, so this is technically OK. This is the alternative, original fix for PR20208 that got reviewed in the thread "[patch] Improve diagnostic on default-initializing const variables (PR20208)". This change basically reverts r213725, adds the original fix for PR20208, and makes the error a warning in Microsoft mode. llvm-svn: 235166
* Fix for PR20402 in -Wconsumed.DeLesley Hutchins2015-04-151-0/+12
| | | | | | | https://llvm.org/bugs/show_bug.cgi?id=20402 Patch by Chris Wailes. llvm-svn: 235051
* [SemaCXX patch] Patch to fix a crash when a 'delete' constructorFariborz Jahanian2015-04-141-0/+40
| | | | | | | is being accessed. Reviewed by Richard Smith. rdar://20281011 llvm-svn: 234912
* Add new warning -Wrange-loop-analysis to warn on copies during loops.Richard Trieu2015-04-131-0/+299
| | | | | | | | | | | | -Wrange-loop-analysis is a subgroup of -Wloop-analysis and will warn when a range-based for-loop makes copies of the elements in the range. If possible, suggest the proper type to prevent copies, or the non-reference to help distinguish copy versus non-copy forms. Existing warnings in -Wloop-analysis are moved to -Wfor-loop-analysis, also a subgroup of -Wloop-analysis. Differential Revision: http://reviews.llvm.org/D4169 llvm-svn: 234804
* Revert r234786, it contained a bunch of stuff I did not mean to commit.Nico Weber2015-04-131-5/+1
| | | | llvm-svn: 234787
* Revert r234613 (and follow-ups 234614, 234616, 234618), it caused PR23216.Nico Weber2015-04-131-1/+5
| | | | llvm-svn: 234786
* Improve the error message for assigning to read-only variables.Richard Trieu2015-04-116-11/+388
| | | | | | | | | | Previously, many error messages would simply be "read-only variable is not assignable" This change provides more information about why the variable is not assignable, as well as note to where the const is located. Differential Revision: http://reviews.llvm.org/D4479 llvm-svn: 234677
* Don't eagerly typo-correct to a keyword if the next token is a right paren.Kaelyn Takata2015-04-101-0/+17
| | | | | | | | | Take advantage of the delayed typo no longer being eagerly corrected to a keyword to filter out keyword corrections (and other things like unresolved & overloaded expressions, which have placeholder types) when correcting typos inside of a decltype(). llvm-svn: 234623
* [Sema] Don't assume that an initializer list has an initializerDavid Majnemer2015-04-101-2/+3
| | | | | | | | Given something like 'int({}, 1)', we would try to emit a diagnostic regarding the excess element in the scalar initializer. However, we assumed that the initializer list had an element in it. llvm-svn: 234565
* [Sema] Diagnose references to unbound arrays in function definitionsDavid Majnemer2015-04-091-0/+3
| | | | | | | | A [*] is only allowed in a declaration for a function, not in its definition. We didn't correctly recurse on reference types while looking for it, causing us to crash in CodeGen instead of rejecting it. llvm-svn: 234528
* Properly implement warn_unused_result checking for classes/structs.Kaelyn Takata2015-04-091-2/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation would copy the attribute from the class to functions that have the class as their return type when the functions are first declared. This proved to have two flaws: 1) if the class is forward-declared without the attribute and a function or method with the class as a its return type is declared, and afterward the class is defined with warn_unused_result, the function or method would never inherit the attribute, and 2) the check simply failed for functions and methods that are part of a template instantiation, regardless of whether the class with warn_unused_result is part of a specific instantiation or part of the template itself (presumably because those function/method declaration does not hit the same code path as a non-template one and so never inherits the attribute). The new approach is to instead modify the two places where a function or method call is checked for the warn_unused_result attribute on the decl by extending the checks to also look for the attribute on the decl's return type. Additionally, the check for return types that have the warn_unused_result now excludes pointers and references to such types, as such return types do not necessarily imply a transfer of ownership for the underlying object being referred to by the return value. This does not change the behavior of functions that are directly given the warn_unused_result attribute. llvm-svn: 234526
* Generate a diagnostic when a catch handler cannot execute due to class ↵Aaron Ballman2015-04-082-4/+79
| | | | | | hierarchy inversion with regards to other catch handlers for the same block. llvm-svn: 234375
* [Sema] Don't permit dependent alignments on non-dependent typedef-namesDavid Majnemer2015-04-071-0/+13
| | | | | | | | | | | | | | | | | A dependent alignment attribute (like __attribute__((aligned(...))) or __declspec(align(...))) on a non-dependent typedef or using declaration poses a considerable challenge: the type is _not_ dependent, the size _may_ be dependent if the type is used as an array type, the alignment _is_ dependent. It is reasonable for a compiler to be able to query the size and alignment of a complete type. Let's help that become an invariant. This fixes PR22042. Differential Revision: http://reviews.llvm.org/D8693 llvm-svn: 234280
* Switch test from wchar_t to char32_tDavid Majnemer2015-04-051-2/+2
| | | | | | | Windows has a 16-bit wchar_t, most Unix platforms have a 32-bit wchar_t. Use a char32_t to keep the test's output stable. llvm-svn: 234111
* [AST] String literal operator templates have two template args, not oneDavid Majnemer2015-04-051-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | StmtPrinter assumed that the first template arg was the pack and attempted to iterate it. However, the GNU extension (which is really just N3599), has two template arguments. In this case, the second argument is the pack containing the string contents. Handle this by desugaring the call to the explicit operator. For example: "qux" _zombocom will be shown as operator "" _zombocom<char, 'q', 'u', 'x'>() in diagnostics and AST dumps. N.B. It is actually impossible to render the arguments back to the source form without storing more information in the AST. For example, we cannot tell if the user wrote u8"qux" or "qux". We also lose fidelity when it comes to non-char types for this exact reason (e.g. it is hard to render a list of wchar_t back to something that can be printed to the screen even if you don't have to consider surrogate pairs). This fixes PR23120. llvm-svn: 234110
* Unify warnings/errors from "maybe you meant" to "did you mean".Eric Christopher2015-04-022-5/+5
| | | | llvm-svn: 233981
* Re-land "MS ABI: lambda call operators are instance methods and should use ↵Reid Kleckner2015-04-011-3/+19
| | | | | | | | | | | | | thiscall" Update the test cases to pass when lambda call operators use thiscall. Update the lambda-to-block conversion operator to use the default free function calling convention instead of the call operator's convention. This reverts commit r233082 and re-instates r233023. llvm-svn: 233835
* [lex] Provide a valid token when __has_include is found outside of a pp ↵Benjamin Kramer2015-03-291-0/+6
| | | | | | | | | | | directive ExpandBuiltinMacro would strip the identifier and downstream users crash when they encounter an identifier token with nullptr identifier info. Found by afl-fuzz. llvm-svn: 233497
* A conversion from a scoped enumeration bitfield to an integral type is anRichard Smith2015-03-281-0/+8
| | | | | | | | integral promotion only if it converts to the underlying type or its promoted type, not if it converts to the promoted type that the bitfield would have it if were of the underlying type. llvm-svn: 233457
* Diagnose delayed typos in an expr list that is in an invalid expression.Kaelyn Takata2015-03-271-0/+5
| | | | | | | | | | Previously, if the expr list parsed fine but the expr to the left of the open parenthesis was invalid (when parsing the suffix of a postfix-expression), the parsed expr list was just ignored. Fixes PR23005. llvm-svn: 233347
* Reverting r233023 -- it caused test failures on Windows with MSVC x86.Aaron Ballman2015-03-241-19/+3
| | | | | | http://bb.pgr.jp/builders/ninja-clang-i686-msc18-R/builds/572 llvm-svn: 233082
* MS ABI: lambda call operators are instance methods and should use thiscallReid Kleckner2015-03-231-3/+19
| | | | | | Fixes an issue reported by Daniel Berenyi on cfe-dev. llvm-svn: 233023
* -Wdynamic-class-memaccess: Also warn about array types.Nico Weber2015-03-212-1/+7
| | | | | | | It looks like not warning on this was an oversight in the original implementation of this warning. llvm-svn: 232900
* When cloning LocalInstantiationScope's, don't update the current scope in Sema.Richard Trieu2015-03-181-0/+17
| | | | | | | | | | Construction of LocalInstantiationScope automatically updates the current scope inside Sema. However, when cloning a scope, the current scope does not change. Change the cloning function to preserve the current scope. Review: http://reviews.llvm.org/D8407 BUG: https://llvm.org/bugs/show_bug.cgi?id=22931 llvm-svn: 232675
* MS ABI: Define _HAS_CHAR16_T_LANGUAGE_SUPPORT when appropriateDavid Majnemer2015-03-181-2/+6
| | | | | | | If we are in MSVC 2015 compatibility mode and C++11 language conformance is enabled, define _HAS_CHAR16_T_LANGUAGE_SUPPORT to 1. llvm-svn: 232615
* MSVC Compat: Permit char16_t, char32_t and _Atomic when targeting > 2013David Majnemer2015-03-181-3/+9
| | | | | | | | We disabled support for _Atomic because the STL had name conflicts, they've been resolved in 2015. Similarly, reenable char16_t and char32_t. llvm-svn: 232611
* Fix a crash when the size of an 'auto' is needed and its initalizerKaelyn Takata2015-03-171-0/+17
| | | | | | | | contained a typo correction (the auto decl was being marked as dependent unnecessarily, which triggered an assertion in cases where the size of the type is needed). llvm-svn: 232568
* Take the non-reference type when constructing a dummy expression.Richard Trieu2015-03-161-0/+17
| | | | | | Otherwise, Expr will assert during construction with a reference type. llvm-svn: 232425
* -Wempty-body: fix false negative triggered by macrosDmitri Gribenko2015-03-151-0/+7
| | | | | | | | | | | | | When if statement condition ended in a macro: if (ptr == NULL); the check used to consider the definition location of NULL, instead of the current line. Patch by Manasij Mukherjee. llvm-svn: 232295
* Sema: Don't emit a missing prototype warning for deleted functions.Benjamin Kramer2015-03-121-1/+3
| | | | | | | | | | | | | This is a bit more involved than I anticipated, so here's a breakdown of the changes: 1. Call ActOnFinishFunctionBody _after_ we parsed =default and =delete specifiers. Saying that we finished the body before parsing =default is just wrong. Changing this allows us to use isDefaulted and isDeleted on a decl in ActOnFinishFunctionBody. 2. Check for -Wmissing-prototypes after we parsed the function body. 3. Disable -Wmissing-prototypes when the Decl isDeleted. llvm-svn: 232040
* Use Sema's PrintingPolicy when diagnosing DeclSpecs.Benjamin Kramer2015-03-121-21/+0
| | | | | | | | | | | | | Sema overrides ASTContext's policy on the first emitted diagnostic (doesn't matter if it's ignored or not). This means changing the order of diagnostic emission in Sema suddenly changes the text of diagnostic emitted from the parser. In the test case -Wmissing-prototypes (ignored) was the culprit, use 'int main' to suppress that warning so we see when this regresses. Also move it into Sema/ as it's not testing any C++. llvm-svn: 232039
* Reverted OpenCL2.0 atomic type commits r231932, r231935Anastasia Stulova2015-03-112-1/+2
| | | | | | (caused undesirable update of -std flag to use _Atomic) llvm-svn: 231942
* OpenCL: CL2.0 atomic typesAnastasia Stulova2015-03-112-2/+1
| | | | | | | | | | | | OpenCL C Spec v2.0 Section 6.13.11 - Made c11 _Atomic being accepted only for c11 compilations - Implemented CL2.0 atomics by aliasing them to the corresponding c11 atomic types using implicit typedef - Added diagnostics for atomics Khronos extension enabling llvm-svn: 231932
* Warn when jumping out of a __finally block via goto.Nico Weber2015-03-091-10/+8
| | | | | | | | | | | | | | This only warns on direct gotos and indirect gotos with a unique label (`goto *&&label;`). Jumping out ith a true indirect goto is already an error. This isn't O(1), but goto statements are less common than continue, break, and return. Also, the GetDeepestCommonScope() call in the same function does the same amount of work, so this isn't worse than what's there in a complexity sense, and it should be pretty fast in practice. This is the last piece that was missing in r231623. llvm-svn: 231628
* Sema: The i8 suffix should yield a literal of type charDavid Majnemer2015-03-061-0/+5
| | | | | | | | | We would make i8 literals turn into signed char instead of char. This is incompatible with MSVC. This fixes PR22824. llvm-svn: 231494
* Temporary XFAILs for HexagonRick Foos2015-03-041-0/+1
| | | | | | | | | | | | | | Summary: Temporary XFAIL's until patches done. Reviewers: echristo, adasgupt, colinl Reviewed By: colinl Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8044 llvm-svn: 231318
* Move one more diagnostic into the new -Wformat-pedantic group.Daniel Jasper2015-03-041-0/+10
| | | | | | This was apparently overlooked in r231211. llvm-svn: 231242
* Add a format warning for "%p" with non-void* argsSeth Cantrell2015-03-041-0/+3
| | | | | | | | | | | | | | | | | | GCC -pedantic produces a format warning when the "%p" specifier is used with arguments that are not void*. It's useful for portability to be able to catch such warnings with clang as well. The warning is off by default in both gcc and with this patch. This patch enables it either when extensions are disabled with -pedantic, or with the specific flag -Wformat-pedantic. The C99 and C11 specs do appear to require arguments corresponding to 'p' specifiers to be void*: "If any argument is not the correct type for the corresponding conversion specification, the behavior is undefined." [7.19.6.1 p9], and of the 'p' format specifier "The argument shall be a pointer to void." [7.19.6.1 p8] Both printf and scanf format checking are covered. llvm-svn: 231211
OpenPOWER on IntegriCloud