summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX
Commit message (Collapse)AuthorAgeFilesLines
* If a non-noreturn virtual member function is guaranteed not to return,Douglas Gregor2010-04-161-0/+5
| | | | | | | do *not* suggest that the function could be attribute 'noreturn'; overridden functions may end up returning. llvm-svn: 101572
* More work on wide bit-fields, WIP.Anders Carlsson2010-04-161-1/+19
| | | | llvm-svn: 101467
* Start working on handling wide bitfields in C++Anders Carlsson2010-04-161-0/+12
| | | | llvm-svn: 101464
* Audit uses of Sema::LookupSingleName for those lookups that areDouglas Gregor2010-04-151-0/+13
| | | | | | | | | | | 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
* Diagnose attempts to throw an abstract class type.Douglas Gregor2010-04-151-0/+10
| | | | llvm-svn: 101381
* Fix a few cases where enum constant handling was usingDouglas Gregor2010-04-151-3/+7
| | | | | | | | | | ASTContext::getTypeSize() rather than ASTContext::getIntWidth() for the width of an integral type. The former includes padding for bools (to the target's size) while the latter does not, so we woud end up zero-extending bools to the target width when we shouldn't. Fixes a crash-on-valid in the included test. llvm-svn: 101372
* Warn about non-aggregate classes with no user-declared constructorsDouglas Gregor2010-04-153-6/+10
| | | | | | | that have reference or const scalar members, since those members can never be initializer or modified. Fixes <rdar://problem/7804350>. llvm-svn: 101316
* Always diagnose and complain about problems inDouglas Gregor2010-04-141-0/+16
| | | | | | | | | | ResolveAddressOfOverloadedFunction when asked to complain. Previously, we had some weird handshake where ResolveAddressOfOverloadedFunction expected its caller to handle some of the diagnostics but not others, and yet there was no way for the caller to know which case we were in. Eliminate this madness, fixing <rdar://problem/7765884>. llvm-svn: 101312
* Once we've emitted a fatal diagnostic, keep counting errors but with aDouglas Gregor2010-04-141-0/+9
| | | | | | | | | | | | | | separate count of "suppressed" errors. This way, semantic analysis bits that depend on the error count to determine whether problems occured (e.g., some template argument deduction failures, jump-scope checking) will not get confused. The actual problem here is that a missing #include (which is a fatal error) could cause the jump-scope checker to run on invalid code, which it is not prepared to do. Trivial fix for both <rdar://problem/7775941> and <rdar://problem/7775709>. llvm-svn: 101297
* When diagnosing suspicious precedence or assignments, move the fix-itDouglas Gregor2010-04-141-16/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | that adds parentheses from the main diagnostic down to a new note. This way, when the fix-it represents a choice between two options, each of the options is associted with a note. There is no default option in such cases. For example: /Users/dgregor/t.c:2:9: warning: & has lower precedence than ==; == will be evaluated first [-Wparentheses] if (x & y == 0) { ^~~~~~~~ /Users/dgregor/t.c:2:9: note: place parentheses around the & expression to evaluate it first if (x & y == 0) { ^ ( ) /Users/dgregor/t.c:2:9: note: place parentheses around the == expression to silence this warning if (x & y == 0) { ^ ( ) llvm-svn: 101249
* When returning the result of a call to an object of class type, do notDouglas Gregor2010-04-131-0/+15
| | | | | | | return a NULL expression; return either an error or a proper expression. Fixes PR6078. llvm-svn: 101133
* Allow classes to befriend implicitly-declared members. Fixes PR6207 forJohn McCall2010-04-131-4/+4
| | | | | | members of non-templated classes. llvm-svn: 101122
* Diagnose declarations of conversion functions with declarators other than '()'.John McCall2010-04-131-0/+11
| | | | llvm-svn: 101098
* Improve source-location information for C++ conversion functions, byDouglas Gregor2010-04-121-0/+34
| | | | | | | | | | | | | | | | | copying the type location information from the conversion-type-id into the type location information for the function type. Do something similar for constructors and destructors, by giving their "void" return type source-location information. In all of these cases, we previously left this type-source information uninitialized, which led to various unfortunate crashes. We still aren't tracking good source-location information for the actual names. That's PR6357. John, please check my sanity on this. llvm-svn: 101088
* When creating the implicitly-declared special member functions, beDouglas Gregor2010-04-121-0/+27
| | | | | | | | sure to introduce them into the current Scope (when we have one) in addition to the DeclContext for the class, so that they can be found by name lookup for inline members of the class. Fixes PR6570. llvm-svn: 101047
* When a member pointer is dereferenced, the class it points into must be ↵Sebastian Redl2010-04-101-2/+2
| | | | | | complete. Enforce this. llvm-svn: 100925
* Diagnose more cases of initializing distinct members of an anonymous unionJohn McCall2010-04-103-2/+38
| | | | | | | member. Use a better diagnostic for this case. Also fix a bug with nested anonymous structs/unions for -Wreorder; this last was PR6575. llvm-svn: 100923
* Diagnose misordered initializers in constructor templates immediately instead ofJohn McCall2010-04-102-22/+30
| | | | | | | | | | when they're instantiated. Merge the note into the -Wreorder warning; it doesn't really contribute much, and it was splitting a thought across diagnostics anyway. Don't crash in the parser when a constructor's initializers end in a comma and there's no body; the recovery here is still terrible, but anything's better than a crash. llvm-svn: 100922
* Turn access control on by default in -cc1.John McCall2010-04-0912-10/+14
| | | | | | | | Remove -faccess-control from -cc1; add -fno-access-control. Make the driver pass -fno-access-control by default. Update a bunch of tests to be correct under access control. llvm-svn: 100880
* Remove all "used" static functions *after* we have performed all ofDouglas Gregor2010-04-091-0/+8
| | | | | | | | | the implicit template instantiations we need to perform. Otherwise, we end up erroneously diagnosing static functions as used if they were only used within an implicit template instantiation. Fixes a bunch of spurious failures when building Clang with Clang. llvm-svn: 100872
* Improve diagnostics when we fail to convert from a source type to aDouglas Gregor2010-04-093-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | destination type for initialization, assignment, parameter-passing, etc. The main issue fixed here is that we used rather confusing wording for diagnostics such as t.c:2:9: warning: initializing 'char const [2]' discards qualifiers, expected 'char *' [-pedantic] char *name = __func__; ^ ~~~~~~~~ We're not initializing a 'char const [2]', we're initializing a 'char *' with an expression of type 'char const [2]'. Similar problems existed for other diagnostics in this area, so I've normalized them all with more precise descriptive text to say what we're initializing/converting/assigning/etc. from and to. The warning for the code above is now: t.c:2:9: warning: initializing 'char *' from an expression of type 'char const [2]' discards qualifiers [-pedantic] char *name = __func__; ^ ~~~~~~~~ Fixes <rdar://problem/7447179>. llvm-svn: 100832
* Downgrade the "declaration does not declare anything" error to aDouglas Gregor2010-04-082-2/+2
| | | | | | | warning. It's not harmful to have such pointless declarations, and GCC does not diagnose this issue consistently. llvm-svn: 100814
* Introduce an egregious hack to work around a bug in libstdc++ 4.2.x'sDouglas Gregor2010-04-082-0/+31
| | | | | | | | | <tr1/hashtable> header, where a friend class template std::tr1::__detail::_Map_base is declared with the wrong template parameters. GCC doesn't catch the problem, so Clang does a little back-flip to avoid diagnosing just this one instance of the problem. llvm-svn: 100790
* Make CXXScopeSpec invalid when incomplete, and propagate that into anyJeffrey Yasskin2010-04-081-5/+3
| | | | | | | Declarator that depends on it. This fixes several redundant errors and bad recoveries. llvm-svn: 100779
* Fix some redundant errors by changing CXXScopeSpec::isSet calls intoJeffrey Yasskin2010-04-071-3/+3
| | | | | | isNotEmpty calls. llvm-svn: 100722
* rename llvm::llvm_report_error -> llvm::report_fatal_errorChris Lattner2010-04-071-1/+1
| | | | llvm-svn: 100708
* Rework our handling of copy construction of temporaries, which was aDouglas Gregor2010-04-022-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | poor (and wrong) approximation of the actual rules governing when to build a copy and when it can be elided. The correct implementation is actually simpler than the approximation. When we only enumerate constructors as part of initialization (e.g., for direct initialization or when we're copying from a class type or one of its derived classes), we don't create a copy. When we enumerate all conversion functions, we do create a copy. Before, we created some extra copies and missed some others. The new test copy-initialization.cpp shows a case where we missed creating a (required, non-elidable) copy as part of a user-defined conversion, which resulted in a miscompile. This commit also fixes PR6757, where the missing copy made us reject well-formed code in the ternary operator. This commit also cleans up our handling of copy elision in the case where we create an extra copy of a temporary object, which became necessary now that we produce the right copies. The code that seeks to find the temporary object being copied has moved into Expr::getTemporaryObject(); it used to have two different not-quite-the-same implementations, one in Sema and one in CodeGen. Note that we still do not attempt to perform the named return value optimization, so we miss copy elisions for return values and throw expressions. llvm-svn: 100196
* Diagnose multiple base and member initializers in class templates.Anders Carlsson2010-04-021-0/+25
| | | | llvm-svn: 100179
* Improve diagnostics when an elaborated-type-specifer containing aDouglas Gregor2010-03-311-1/+1
| | | | | | | | | | | | | | | | nested-name-specifier (e.g., "class T::foo") fails to find a tag member in the scope nominated by the nested-name-specifier. Previously, we gave a bland error: 'Nested' does not name a tag member in the specified scope which didn't actually say where we were looking, which was rather horrible when the nested-name-specifier was instantiated. Now, we give something a bit better: error: no class named 'Nested' in 'NoDepBase<T>' llvm-svn: 100060
* Fix PR6327: restore invariants when there's a parse error in an initializer.John McCall2010-03-311-0/+18
| | | | llvm-svn: 99980
* Fix a bug where we would incorrectly report an error about initializing two ↵Anders Carlsson2010-03-301-6/+15
| | | | | | fields in an anonymous struct. llvm-svn: 99891
* Support __attribute__((packed)) (along with other attributes) at theDouglas Gregor2010-03-291-0/+7
| | | | | | end of a struct/class/union in C++, from Justin Bogner! llvm-svn: 99811
* Fix a nasty bug in the virtual base computation which would lead to us ↵Anders Carlsson2010-03-291-0/+12
| | | | | | initializing virtual bases in the wrong order. llvm-svn: 99806
* Compare namespaces properly when looking for redeclarations ofDouglas Gregor2010-03-261-1/+9
| | | | | | namespace aliases. Fixes PR6341. llvm-svn: 99664
* When trying to determine whether one operand of a conditionalDouglas Gregor2010-03-261-0/+15
| | | | | | | | | expression can be converted to the type of another, only apply the lvalue-to-rvalue conversion to the type of the expression we're converting, *not* the array-to-pointer or function-to-pointer conversions. Fixes PR6595. llvm-svn: 99652
* Switch semantic analysis of the conditional operator from usingDouglas Gregor2010-03-261-1/+2
| | | | | | CheckReferenceInit to using the new initialization sequence code. llvm-svn: 99647
* Do not mark the destructor of a function parameter's type. Fixes PR6709.Douglas Gregor2010-03-261-0/+5
| | | | llvm-svn: 99615
* Switch static_cast from the old reference-initialization code (viaDouglas Gregor2010-03-241-2/+2
| | | | | | | | CheckReferenceInit) over to the new initialization code (InitializationSequence), which is better-tested and doesn't require us to compute the entire conversion sequence twice. llvm-svn: 99452
* When a declaration of a function is missing an exception specificationDouglas Gregor2010-03-241-3/+3
| | | | | | | | | | | | | | | | | | | | | that was present in a prior declaration, emit a warning rather than a hard error (which we did before, and still do with mismatched exception specifications). Moreover, provide a fix-it hint with the throw() clause that should be added, e.g., t.C:10:7: warning: 'operator new' is missing exception specification 'throw(std::bad_alloc)' void *operator new(unsigned long sz) ^ throw(std::bad_alloc) As part of this, disable the warning when we're missing an exception specification on operator new, operator new[], operator delete, or operator delete[] when exceptions are turned off (-fno-exceptions). Fixes PR5957. llvm-svn: 99388
* When performing name lookup for the allocation or deallocationDouglas Gregor2010-03-241-0/+13
| | | | | | | operators, make sure that the implicitly-declared global new and delete operators are always available. Fixes PR5904. llvm-svn: 99382
* Make sure to properly track the anonymous namespace that lives insideDouglas Gregor2010-03-241-0/+22
| | | | | | | | | | each namespace, even when the outer namespace has multiple definitions. As part of this, collapsed two pointers worth of storage (original namespace and inner anonymous namespace) into a single pointer with a distinguishing bit, since the two are mutually exclusive, saving a pointer per NamespaceDecl. Fixes PR6620. llvm-svn: 99368
* When recovering from a qualified typedef name, don't clear out theDouglas Gregor2010-03-231-0/+9
| | | | | | | DeclContext because we don't want a NULL DeclContext. Instead, use the current context. llvm-svn: 99281
* Fix PR6618.Rafael Espindola2010-03-211-0/+13
| | | | | | | If a struct has an invalid field, mark it as invalid. Also avoid producing errors about incomplete types that are invalid. llvm-svn: 99150
* Implement -Wshadow for parameter declarations as well.John McCall2010-03-201-0/+6
| | | | llvm-svn: 99037
* Promote enum types during -Wsign-compare. Fixes some spurious warnings,John McCall2010-03-192-3/+75
| | | | | | mostly during conditional expressions. llvm-svn: 98975
* Pretty-print anonymous types using their kind and presumed location.John McCall2010-03-191-1/+1
| | | | | | Fixes PR6643. Patch by Mike M! llvm-svn: 98946
* When elevating access along an inheritance path, initialize the computedJohn McCall2010-03-181-2/+3
| | | | | | | | | | | | | | | | access to the (elevated) access of the accessed declaration, if applicable, rather than plunking that access onto the end after we've calculated the inheritance access. Also, being a friend of a derived class gives you public access to its members (subject to later modification by further inheritance); it does not simply ignore a single location of restricted inheritance. Also, when computing the best unprivileged path to a subobject, preserve the information that the worst path might be AS_none (forbidden) rather than a minimum of AS_private. llvm-svn: 98899
* Provide a test case for PR6629.John McCall2010-03-171-0/+18
| | | | llvm-svn: 98702
* Forgot the testcases.John McCall2010-03-161-0/+38
| | | | llvm-svn: 98685
* Fix PR6562. If a type is dependent, we don't know if it will have implicitRafael Espindola2010-03-131-0/+10
| | | | | | destructors. llvm-svn: 98440
OpenPOWER on IntegriCloud