summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX
Commit message (Collapse)AuthorAgeFilesLines
* Merging r155293:Bill Wendling2012-05-121-0/+30
| | | | | | | | | | | | | | ------------------------------------------------------------------------ r155293 | rsmith | 2012-04-21 11:42:51 -0700 (Sat, 21 Apr 2012) | 4 lines Fix regression in r154844. If necessary, defer computing adjusted destructor exception specifications in C++11 until after we've parsed the exception specifications for nested classes. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_31@156683 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r155608:Bill Wendling2012-05-121-0/+5
| | | | | | | | | | | | | ------------------------------------------------------------------------ r155608 | rsmith | 2012-04-25 20:16:45 -0700 (Wed, 25 Apr 2012) | 3 lines PR12660: Don't crash when initializing a const reference from a braced init list which creates a temporary by calling a constructor. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_31@156678 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r155975:Bill Wendling2012-05-122-4/+6
| | | | | | | | | | | | | | ------------------------------------------------------------------------ r155975 | rsmith | 2012-05-01 18:29:43 -0700 (Tue, 01 May 2012) | 4 lines Disable our non-standard delayed parsing of exception specifications. Delaying the parsing of such things appears to be a conforming extension, but it breaks libstdc++4.7's std::pair. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_31@156672 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r155728:Bill Wendling2012-04-271-1/+5
| | | | | | | | | | | | | | ------------------------------------------------------------------------ r155728 | rsmith | 2012-04-27 12:33:05 -0700 (Fri, 27 Apr 2012) | 4 lines PR12224 (sort of): Diagnose inheriting constructor declarations in C++11 mode. We do not support IRGen for these, and get some parts of the semantic analysis wrong. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_31@155731 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement the last part of C++ [class.mem]p2, delaying the parsing ofDouglas Gregor2012-04-162-9/+3
| | | | | | | | | | 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
* Implement C++11 [expr.prim.general]p3, which permits the use of 'this'Douglas Gregor2012-04-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | in the declaration of a non-static member function after the (optional) cv-qualifier-seq, which in practice means in the exception specification and late-specified return type. The new scheme here used to manage 'this' outside of a member function scope is more general than the Scope-based mechanism previously used for non-static data member initializers and late-parsesd attributes, because it can also handle the cv-qualifiers on the member function. Note, however, that a separate pass is required for static member functions to determine whether 'this' was used, because we might not know that we have a static function until after declaration matching. Finally, this introduces name mangling for 'this' and for the implicit 'this', which is intended to match GCC's mangling. Independent verification for the new mangling test case would be appreciated. Fixes PR10036 and PR12450. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154799 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix tests that weren't actually verifying anything.David Blaikie2012-04-151-4/+4
| | | | | | | | | | | | | | Passing -verify to clang without -cc1 or -Xclang silently passes (with a printed warning, but lit doesn't care about that). This change adds -cc1 or, as is necessary in one case, -Xclang to fix this so that these tests are actually verifying as intended. I'd like to change the driver so this kind of mistake could not be made, but I'm not entirely sure how. Further, since the driver only warns about unknown flags in general, we could have similar bugs with a misspellings of arguments that would be nice to find. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154776 91177308-0d34-0410-b5e6-96231b3b80d8
* PR12226: don't generate wrong code if a braced string literal is used toRichard Smith2012-04-151-0/+4
| | | | | | | | | | initialize an array of unsigned char. Outside C++11 mode, this bug was benign, and just resulted in us emitting a constant which was double the required length, padded with 0s. In C++11, it resulted in us generating an array whose first element was something like i8 ptrtoint ([n x i8]* @str to i8). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154756 91177308-0d34-0410-b5e6-96231b3b80d8
* PR12500: Improve the wording of the diagnostic for a redefinition of a nameRichard Smith2012-04-132-2/+2
| | | | | | | in the wrong namespace scope. Patch by Jonathan Sauer! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154656 91177308-0d34-0410-b5e6-96231b3b80d8
* When we're flagging a protected scope to prevent jumps into theJohn McCall2012-04-131-0/+10
| | | | | | | | shadow of a block expression with non-trivial destructed cleanups, we should flag that in the enclosing function, not in the block that we're about to pop. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154646 91177308-0d34-0410-b5e6-96231b3b80d8
* Add -Wuninitialized test for C++11 lambdas.Ted Kremenek2012-04-121-1/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154608 91177308-0d34-0410-b5e6-96231b3b80d8
* Compute standard conversion sequences for conversions to atomicDouglas Gregor2012-04-121-0/+23
| | | | | | | | | | | | | types. The second and third conversions in the sequence are based on the conversion for the underlying type, so that we get sensible overloading behavior for, e.g., _Atomic(int) vs. _Atomic(float). As part of this, actually implement the lvalue-to-rvalue conversion for atomic types. There is probably a pile of code in SemaExpr that can now be deleted, but I haven't tracked it down yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154596 91177308-0d34-0410-b5e6-96231b3b80d8
* Part of PR10101: after a parse error in a declaration, try harder to find theRichard Smith2012-04-111-2/+2
| | | | | | | | right place to pick up parsing. In C++, this had a tendency to skip everything declared within headers if the TU starts with garbage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154530 91177308-0d34-0410-b5e6-96231b3b80d8
* When we determine that an initialization sequence failed due to anDouglas Gregor2012-04-101-0/+14
| | | | | | | | | incomplete type, keep track of the actual type that was incomplete. Otherwise, we might fail to produce a diagnostic. Fixes PR12498. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154432 91177308-0d34-0410-b5e6-96231b3b80d8
* Disambiguation of '[[':Richard Smith2012-04-102-2/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* Thread safety analysis: downgraded requirement that mutex expressions refer ↵DeLesley Hutchins2012-04-061-49/+49
| | | | | | to a lockable type from error to warning. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154198 91177308-0d34-0410-b5e6-96231b3b80d8
* Test for r154189/PR12481Matt Beaumont-Gay2012-04-061-0/+17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154193 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixed scoping error for late parsed attributes in nested classes.DeLesley Hutchins2012-04-061-3/+41
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154173 91177308-0d34-0410-b5e6-96231b3b80d8
* Point the caret at the error for the 'expected namespace name' diagnostic inRichard Smith2012-04-051-2/+6
| | | | | | | a namespace alias declaration. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154138 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve diagnostics for invalid use of non-static members / this:Richard Smith2012-04-054-12/+14
| | | | | | | | | | | | | * s/nonstatic/non-static/ in the diagnostics, since the latter form outvoted the former by 28-2 in our diagnostics. * Fix the "use of member in static member function" diagnostic to correctly detect this situation inside a block or lambda. * Produce a more specific "invalid use of non-static member" diagnostic for the case where a nested class member refers to a member of a lexically-surrounding class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154073 91177308-0d34-0410-b5e6-96231b3b80d8
* Add triples to these tests to keep them working on Windows,Richard Smith2012-04-052-2/+2
| | | | | | | where wchar_t is only 16 bits wide. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154072 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix assertions and wrong output from StmtPrinter's string literal printing.Richard Smith2012-04-052-2/+9
| | | | | | | | | | | String literals (including unicode ones) can contain non-Unicode codepoints if they were written using \x or similar. Write those out using \x, but be careful that the following character can't be misinterpreted as part of the \x escape sequence. Convert UTF-16 surrogate pairs back to codepoints before rendering them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154069 91177308-0d34-0410-b5e6-96231b3b80d8
* Enable warn_impcast_literal_float_to_integer by default.David Blaikie2012-04-052-4/+4
| | | | | | | | | | | | | | | | | This diagnostic seems to be production ready, it's just an oversight that it wasn't turned on by default. The test changes are a bit of a mixed bag. Some tests that seemed like they clearly didn't need to use this behavior have been modified not to use it. Others that I couldn't be sure about, I added the necessary expected-warnings to. It's possible the diagnostic message could be improved to make it clearer that this warning can be suppressed by using a value that won't lose precision when converted to the target type (but can still be a floating point literal, such as "bool b = 1.0;"). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154068 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow a conversion from the empty initializer list {} to anDouglas Gregor2012-04-041-0/+9
| | | | | | | | std::initializer_list<T> so long as <T> is known. This conversion has identity rank. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154065 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement C++11 [temp.arg.nontype]'s permission to use the address of an objectRichard Smith2012-04-041-0/+8
| | | | | | | or function with internal linkage as a non-type template argument. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154053 91177308-0d34-0410-b5e6-96231b3b80d8
* When performing template argument deduction for an initializer list,Douglas Gregor2012-04-041-0/+16
| | | | | | | | | | | | | | | | | | be sure to perform the argument type adjustments in [temp.deduct.call]p2, e.g., array decay. And, when performing these deductions in the context of 'auto', make sure that we're deducing the P' in std::initializer_list<P'> rather than the whole initializer list. Together, this makes code like for( auto s : {"Deferred", "New", "Open", "Review"}) { } work properly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153998 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove more redundant lookups. Add a new "all_lookups_iterator" which providesNick Lewycky2012-04-033-2/+17
| | | | | | | | | a view over the contents of a DeclContext without exposing the implementation details of the StoredDeclsMap. Use this in LookupVisibleDecls to find the visible declarations. Fixes PR12339! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153970 91177308-0d34-0410-b5e6-96231b3b80d8
* Finish PR10217: Ensure we say that a special member was implicitly, notRichard Smith2012-04-022-5/+5
| | | | | | | explicitly, deleted in all relevant cases, and explain why. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153894 91177308-0d34-0410-b5e6-96231b3b80d8
* Properly handle explicit constructors in list-initialization. Fixes PR12120.Sebastian Redl2012-04-011-6/+14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153849 91177308-0d34-0410-b5e6-96231b3b80d8
* PR10217: Provide diagnostics explaining why an implicitly-deleted specialRichard Smith2012-03-307-50/+45
| | | | | | | member function is deleted. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153773 91177308-0d34-0410-b5e6-96231b3b80d8
* Unify and fix our checking of C++ [dcl.meaning]p1's requirementsDouglas Gregor2012-03-281-1/+1
| | | | | | | | | | concerning qualified declarator-ids. We now diagnose extraneous qualification at namespace scope (which we had previously missed) and diagnose these qualification errors for all kinds of declarations; it was rather uneven before. Fixes <rdar://problem/11135644>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153577 91177308-0d34-0410-b5e6-96231b3b80d8
* Even more careful consideration of C++11 13.3.3.1p4. Fixes PR12241.Sebastian Redl2012-03-271-11/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153523 91177308-0d34-0410-b5e6-96231b3b80d8
* When we see 'Class(X' or 'Class::Class(X' and we suspect that it names aRichard Smith2012-03-271-7/+2
| | | | | | | | | | | | | | constructor, but X is not a known typename, check whether the tokens could possibly match the syntax of a declarator before concluding that it isn't a constructor. If it's definitely ill-formed, assume it is a constructor. Empirical evidence suggests that this pattern is much more often a constructor with a typoed (or not-yet-declared) type name than any of the other possibilities, so the extra cost of the check is not expected to be problematic. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153488 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a special-case diagnostic for one of the more obnoxious special cases ofRichard Smith2012-03-261-0/+39
| | | | | | | | | | | | | | | | unscoped enumeration members: an enumerator name which is visible in the out-of-class definition of a member of a templated class might not actually exist in the instantiation of that class, if the enumeration is also lexically defined outside the class definition and is explicitly specialized. Depending on the result of a CWG discussion, we may have a different resolution for a class of problems in this area, but this fixes the immediate issue of a crash-on-invalid / accepts-invalid (depending on +Asserts). Thanks to Johannes Schaub for digging into the standard wording to find how this case is currently specified to behave. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153461 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle instantiations of redeclarations of forward-declared enumerations withinRichard Smith2012-03-261-0/+24
| | | | | | | | templated functions. Build a redeclaration chain, and only instantiate the definition of the enum when visiting the defining declaration. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153427 91177308-0d34-0410-b5e6-96231b3b80d8
* Delay checking of dependent underlying types for redeclarations of memberRichard Smith2012-03-261-0/+21
| | | | | | | enumerations in templates until the template is instantiated. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153426 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach APValue printer to print boolean 0 and 1 as 'false' and 'true'. Fix upRichard Smith2012-03-231-0/+4
| | | | | | | some calling code to actually pass in a non-null type, to avoid a crash. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153358 91177308-0d34-0410-b5e6-96231b3b80d8
* When defining a forward-declared enum, don't try to attach the definition toRichard Smith2012-03-231-0/+11
| | | | | | | | a previous declaration if the redeclaration is invalid. That way lies madness. Fixes a crash-on-invalid reported by Abramo. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153349 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix broken CFG when an initializer is a statement expression that starts ↵Ted Kremenek2012-03-221-0/+15
| | | | | | with a while loop (PR 12325). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153242 91177308-0d34-0410-b5e6-96231b3b80d8
* Test case for rdar://problem/11055105, a bug with the instantiationJohn McCall2012-03-211-1/+14
| | | | | | | | of references to function template parameters in noexcept clauses when the instantiation is forced from a point during parsing when a block is in scope. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153152 91177308-0d34-0410-b5e6-96231b3b80d8
* More careful consideration of C++11 13.3.3.1p4. Fixes PR12257.Sebastian Redl2012-03-201-0/+28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153130 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the other place where C++98 work for initializer lists was necessary.Sebastian Redl2012-03-201-0/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153129 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix crash when querying the CFG reported when using the thread safety analysisTed Kremenek2012-03-191-0/+13
| | | | | | | on code using multi-dimensional arrays. Fix by DeLesley Hutchins, and reported in PR 12271. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153067 91177308-0d34-0410-b5e6-96231b3b80d8
* Add the missing compatibility warning for braced initializers as default ↵Sebastian Redl2012-03-181-1/+2
| | | | | | arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153026 91177308-0d34-0410-b5e6-96231b3b80d8
* Diagnose tag and class template declarations with qualifiedDouglas Gregor2012-03-171-1/+2
| | | | | | | declarator-ids that occur at class scope. Fixes PR8019. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153002 91177308-0d34-0410-b5e6-96231b3b80d8
* Suppress macro expansion of NULL in NULL warnings.David Blaikie2012-03-161-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For "int i = NULL;" we would produce: null.cpp:5:11: warning: implicit conversion of NULL constant to integer [-Wconversion] int i = NULL; ~ ^~~~ null.cpp:1:14: note: expanded from macro 'NULL' \#define NULL __null ^~~~~~ But we really shouldn't trace that macro expansion back into the header, yet we still want macro back traces for code like this: \#define FOO NULL int i = FOO; or \#define FOO int i = NULL; FOO While providing appropriate tagging at different levels of the expansion, etc. The included test case exercises these cases & does some basic validation (to ensure we don't have macro expansion notes where we shouldn't, and do where we should) - but doesn't go as far as to validate the source location/ranges used in those notes and warnings. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152940 91177308-0d34-0410-b5e6-96231b3b80d8
* Skip through transparent contexts when deciding where to add a friend function.Nick Lewycky2012-03-161-0/+8
| | | | | | | This fixes g++.dg/parse/friend5.C. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152938 91177308-0d34-0410-b5e6-96231b3b80d8
* Support deducing template arguments from nested initializer lists. PR12119.Sebastian Redl2012-03-151-0/+13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152848 91177308-0d34-0410-b5e6-96231b3b80d8
* Provide the specific target type in the -Wnull-conversion warning.David Blaikie2012-03-151-4/+8
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152835 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r152745 (reverted in 152765) now that compiler-rt is fixed.David Blaikie2012-03-152-2/+6
| | | | | | | | | | | | | | | | | Original commit message: Provide -Wnull-conversion separately from -Wconversion. Like GCC, provide a NULL conversion to non-pointer conversion as a separate flag, on by default. GCC's flag is "conversion-null" which we provide for cross compatibility, but in the interests of consistency (with -Wint-conversion, -Wbool-conversion, etc) the canonical Clang flag is called -Wnull-conversion. Patch by Lubos Lunak. Review feedback by myself, Chandler Carruth, and Chad Rosier. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152774 91177308-0d34-0410-b5e6-96231b3b80d8