Commit Graph

1138 Commits

Author SHA1 Message Date
Douglas Gregor 3999e15d93 Reject the allocation of variably-modified types in C++ 'new'
expressions. Fixes PR8209 in the narrowest way possible. I'm still
considering whether I want to implement the extension that permits the
use of VLA types in a 'new' expression.

llvm-svn: 115790
2010-10-06 16:00:31 +00:00
Anders Carlsson 0f7e94fd7b When checking for uninitialized fields in member initializers, special case static variables and enums. Fixes PR8075.
llvm-svn: 115732
2010-10-06 02:43:25 +00:00
Argyrios Kyrtzidis a992bbc08a Add test case for r115588.
llvm-svn: 115590
2010-10-05 03:15:43 +00:00
Gabor Greif 594ce3573a Doug's feedback
llvm-svn: 115356
2010-10-01 22:12:38 +00:00
Gabor Greif 16e028617c Factor out enumerator APSInt adjustment into
a helper function (AdjustAPSInt) and use that
for adjusting the high bounds of case ranges
before APSInt comparisons. Fixes
http://llvm.org/bugs/show_bug.cgi?id=8135

Some minor refacorings while I am here.

llvm-svn: 115355
2010-10-01 22:05:14 +00:00
Francois Pichet 6d76e6cd92 Better diagnostic for superfluous scope specifier inside a class definition for member functions. + Fixit.
Example: 
class A {
   void A::foo(); //warning: extra qualification on member 'foo'
};

llvm-svn: 115347
2010-10-01 21:19:28 +00:00
Douglas Gregor 7fb25418ed Implement the C++0x "trailing return type" feature, e.g.,
auto f(int) -> int

from Daniel Wallin!

(With a few minor bug fixes from me).

llvm-svn: 115322
2010-10-01 18:44:50 +00:00
Douglas Gregor 4ed49f375d When performing template argument deduction of a function template
against a function type, be sure to check the type of the resulting
function template specialization against the desired function type
after substituting the deduced/defaulted template arguments. Fixes PR8196.

llvm-svn: 115086
2010-09-29 21:14:36 +00:00
Douglas Gregor 9d5938ae8a Centralize the management of CXXRecordDecl::DefinitionData's Empty bit
in CXXRecordDecl itself. Yes, this is also part of <rdar://problem/8459981>.

This reinstates r114924, with one crucial bug fix: we were ignoring
the implicit fields created by anonymous structs/unions when updating
the bits in CXXRecordDecl, which means that a class/struct containing
only an anonymous class/struct would be considered "empty". Hilarity
follows. 

llvm-svn: 114980
2010-09-28 20:38:10 +00:00
Argyrios Kyrtzidis d6ea6bd2a3 Don't warn with -Wbool-conversions if the user wrote an explicit cast like "(void *)false".
Fixes rdar://8459342.

llvm-svn: 114955
2010-09-28 14:54:11 +00:00
Anders Carlsson 991285e425 Allow the use of C++0x deleted functions as an extension in C++98.
llvm-svn: 114762
2010-09-24 21:25:25 +00:00
Argyrios Kyrtzidis e619e99a1b Fix bogus compiler errors when declaring anonymous union, outside a class, with
members with the same name as a decl outside the scope where the members are actually introduced.
Fixes http://llvm.org/PR6741

llvm-svn: 114641
2010-09-23 14:26:01 +00:00
Argyrios Kyrtzidis 03f0e2b5b4 Do not warn with -Wuninitialized when the member is used in a sizeof or address-of expression.
Fixes rdar://8331312.

llvm-svn: 114426
2010-09-21 10:47:20 +00:00
Argyrios Kyrtzidis 40cec8326c Revert r114316, -Wunused-value enabled by default was intended.
llvm-svn: 114318
2010-09-19 23:03:35 +00:00
Argyrios Kyrtzidis 3698bf1c6d Make -Wunused-value off by default, matching GCC. Fixes rdar://7126194.
llvm-svn: 114316
2010-09-19 21:21:44 +00:00
John McCall 386dfc738e static local variables with destructors don't require a global destructor
unless we're on a platform without __cxa_atexit (or use thereof has been
disabled).  This patch actually just disables the check completely for
static locals, but I've filed http://llvm.org/bugs/show_bug.cgi?id=8176 to
track the platform-specific fix.

llvm-svn: 114269
2010-09-18 05:25:11 +00:00
Douglas Gregor eda7e545e6 Continue parsing more postfix expressions, even after semantic
errors. Improves code completion in yet another case.

llvm-svn: 114255
2010-09-18 01:28:11 +00:00
Douglas Gregor 29d907de03 When we run into an error parsing or type-checking the left-hand side
of a binary expression, continue on and parse the right-hand side of
the binary expression anyway, but don't call the semantic actions to
type-check. Previously, we would see the error and then, effectively,
skip tokens until the end of the statement. 

The result should be more useful recovery, both in the normal case
(we'll actually see errors beyond the first one in a statement), but
it also helps code completion do a much better job, because we do
"real" code completion on the right-hand side of an invalid binary
expression rather than completing with the recovery completion. For
example, given

  x = p->y

if there is no variable named "x", we can still complete after the p->
as a member expression. Along the recovery path, we would have
completed after the "->" as if we were in an expression context, which
is mostly useless.

llvm-svn: 114225
2010-09-17 22:25:06 +00:00
John McCall 7a626f63f7 one piece of code is responsible for the lifetime of every aggregate
slot.  The easiest way to do that was to bundle up the information
we care about for aggregate slots into a new structure which demands
that its creators at least consider the question.

I could probably be convinced that the ObjC 'needs GC' bit should
be rolled into this structure.
Implement generalized copy elision.  The main obstacle here is that
IR-generation must be much more careful about making sure that exactly

llvm-svn: 113962
2010-09-15 10:14:12 +00:00
Sebastian Redl 058fc820d7 Fix destructor and assignment operator lookup in the has_nothrow traits.
llvm-svn: 113897
2010-09-14 23:40:14 +00:00
John McCall d3be2c83d5 The paired 'operator delete' for a placement 'operator new' is always a
placement 'operator delete', even if there are no placement args (i.e.
overload resolution selected an operator new with default arguments).

llvm-svn: 113861
2010-09-14 21:34:24 +00:00
Sebastian Redl 5c649bc7bb Don't crash when using type traits on a class with a constructor template.
llvm-svn: 113796
2010-09-13 22:18:28 +00:00
Sebastian Redl c15c326b51 Remove CXXRecordDecl::getDefaultConstructor(), an inherently unsafe function due to lazy declaration of default constructors. Now that __has_nothrow_constructor doesn't use it anymore, part of PR8101 is fixed.
llvm-svn: 113794
2010-09-13 22:02:47 +00:00
Sebastian Redl 951006f510 Have __has_nothrow_copy use Sema's lookup routines. This fixes the problem with not finding implicitly declared copy constructors, part of PR8107.
llvm-svn: 113784
2010-09-13 21:10:20 +00:00
Argyrios Kyrtzidis 14ec9f674a When applying 'delete' on a pointer-to-array type match GCC and EDG behavior and treat it as 'delete[]'.
Also offer a fix-it hint adding '[]'.

llvm-svn: 113778
2010-09-13 20:15:54 +00:00
Douglas Gregor bdd7b2358b Don't assert when attempting to take the address of an overloaded
function fails due to ambiguities in partial ordering of function
templates. Fixes PR8033.

llvm-svn: 113725
2010-09-12 08:16:09 +00:00
Douglas Gregor d5b730c9d5 When performing overload resolution, only compare the final conversion
sequences for two conversion functions when in fact we are in the text
of initialization by a user-defined conversion sequences. Fixes PR8034.

llvm-svn: 113724
2010-09-12 08:07:23 +00:00
Douglas Gregor 6309e3d18e Don't complain about useless user-defined conversion functions when
they were instantiated from a template. In template metaprogramming,
stuff happens. Fixes PR8065.

llvm-svn: 113722
2010-09-12 07:22:28 +00:00
Francois Pichet 488b4a7d94 Add basic support for Microsoft enum forward declaration.
Assigning an underlying integral type to an enum forward declaration will come in a next patch.

llvm-svn: 113716
2010-09-12 05:06:55 +00:00
Douglas Gregor c87f4d4aba Don't perform integral promotions from an incompletion enumeration
type. Fixes PR8089 in a slightly different way than had been suggested.

llvm-svn: 113711
2010-09-12 03:38:25 +00:00
John McCall db76892e72 Support in-class initialization of static const floating-point data members.
llvm-svn: 113663
2010-09-10 23:21:22 +00:00
Dawn Perchik a42039d5eb Add support for a few MS extensions supported by the Borland compiler
(__uuidof, _fastcall, etc.).

llvm-svn: 113434
2010-09-08 22:56:24 +00:00
Douglas Gregor 8ec5173f9a Use the new-initialization code for initializing scalars with a
function-style cast. Previously, we had a (redundant, incorrect)
semantic-checking path for non-class types, which allowed
value-initialization of a reference type and then crashed.

llvm-svn: 113415
2010-09-08 21:40:08 +00:00
Francois Pichet 4ad4b58639 Allow type definitions inside anonymous struct/union in Microsoft mode.
llvm-svn: 113354
2010-09-08 11:32:25 +00:00
Sebastian Redl 02f1eebdc0 Don't give 'global constructor' warnings for function statics, even if they have a direct initializer. Fixes PR8095.
llvm-svn: 113344
2010-09-08 04:46:19 +00:00
Sebastian Redl a190d3605f Allow (cv) void and incomplete arrays to be passed to the type traits.
Fixes PR8110, and thus PR8109, PR8097, and parts of PR8101, PR8105 and PR8107. Only a few traits have tests for incomplete arrays, since I'm not yet clear what the result for them should be; Howards wants to file a DR to change the standard.

llvm-svn: 113326
2010-09-08 00:48:43 +00:00
Daniel Dunbar 53c9ac30f9 tests: Use -ffreestanding when including stdint.h, to avoid platform dependencies.
llvm-svn: 113301
2010-09-07 22:54:28 +00:00
Chris Lattner d7ff9f91bf remove curly quotes, patch by Dimitry Andric!
llvm-svn: 113156
2010-09-06 17:52:29 +00:00
Eli Friedman abebebf742 Update test for r113128.
llvm-svn: 113131
2010-09-06 00:30:50 +00:00
Eli Friedman 8ed2bac65d PR8023: Don't crash on invalid uses of __real__ on class types in C++.
llvm-svn: 113124
2010-09-05 23:15:52 +00:00
Chris Lattner 24b89469ac 'const std::type_info*' instead of 'std::type_info const*'
llvm-svn: 113092
2010-09-05 00:17:29 +00:00
Chris Lattner 9dd55103c1 print "const intptr_t" instead of "intptr_t const"
llvm-svn: 113091
2010-09-05 00:07:29 +00:00
Chris Lattner 53fa04909c make clang print types as "const int *" instead of "int const*",
which is should have done from the beginning.  As usual, the most
fun with this sort of change is updating all the testcases.

llvm-svn: 113090
2010-09-05 00:04:01 +00:00
Fariborz Jahanian 087206dbcd Truncate block variable of bool type to i1 when its
value is used. This matches with non-block variable
use of bool type. (Fixes radar 8390062).

llvm-svn: 113027
2010-09-03 23:07:53 +00:00
Anders Carlsson f849774495 It's OK for classes to have flexible array elements (but not unions).
llvm-svn: 113018
2010-09-03 21:53:49 +00:00
Fariborz Jahanian 9d798d13f3 Cope with llvm's reference to bool type of 'i1' vs. clang's
type of 'i8' for the same for __block variables of
type bool. refixes radar 8382559.

llvm-svn: 113015
2010-09-03 21:36:02 +00:00
Dawn Perchik 335e16bad4 Add symantic support for the Pascal calling convention via
"__attribute((pascal))" or "__pascal" (and "_pascal" under
-fborland-extensions).  Support still needs to be added to llvm.

llvm-svn: 112939
2010-09-03 01:29:35 +00:00
Anders Carlsson 4013404eff Static local variables don't result in global constructors being emitted.
llvm-svn: 112933
2010-09-03 01:11:38 +00:00
Anders Carlsson af7534f084 Get rid of the "functions declared 'noreturn' should have a 'void' result type" warning.
The rationale behind this is that it is normal for callback functions to have a non-void return type
and it should still be possible to mark them noreturn. (JavaScriptCore is a good example of this).

llvm-svn: 112918
2010-09-03 00:25:02 +00:00
Dawn Perchik 68bb1b441f Add support for Borland extensions via option -fborland-extensions
(original patch r112791 was reverted due to a bug).

llvm-svn: 112915
2010-09-02 23:59:25 +00:00