Commit Graph

983 Commits

Author SHA1 Message Date
Chandler Carruth 139e96216a Reapply r107235, this time with both my typo fixed, and a logical bug fixed.
Previously we relied on the presence of a member which needs no initialization
to prevent us from creating an additional initialization of the outer anonymous
union field. We have already correctly marked that field as initialized by the
member of the union (repeatedly due to the original bug this patch fixes) so we
simply need to bail out.

llvm-svn: 107242
2010-06-30 02:59:29 +00:00
Chandler Carruth 0e783c2e86 Revert r107235, it had a silly typo in it, and fixing the typo breaks something
else. Get the build bots happy while I debug. Very sorry for the delay fixing
this...

llvm-svn: 107239
2010-06-30 02:06:16 +00:00
Chandler Carruth abb04f730e Fix PR7402: We were creating implicit member initializers for every field in an
anonymous union under the presumption that they didn't do anything. While this
is true, our checks for redundant initialization of an anonymous union still
fire when these overlap with explicit user initialization. A cleaner approach
is to avoid initializing multiple members of a union altogether, but this still
is in a rather fuzzy are especially when C++0x allows non-POD types into
unions.

llvm-svn: 107235
2010-06-30 00:54:29 +00:00
Douglas Gregor 4799d03ce8 Implement C++ DR299, which allows an implicit conversion from a class
type to an integral or enumeration type in the size of an array new
expression, e.g.,

  new int[ConvertibleToInt(10)];

This is a GNU and C++0x extension.

llvm-svn: 107229
2010-06-30 00:20:43 +00:00
Douglas Gregor c048c52734 When typo correction produces a result that is not of the kind we're
looking for, reset the name within the LookupResult structure in
addition to clearing out the results. Fixes PR7508.

llvm-svn: 107197
2010-06-29 19:27:42 +00:00
Douglas Gregor cdf87024ed Allow a using directive to refer to the implicitly-defined namespace
"std", with a warning, to improve GCC compatibility. Fixes PR7517.

As a drive-by, add typo correction for using directives.

llvm-svn: 107172
2010-06-29 17:53:46 +00:00
Daniel Dunbar 8452ef0798 tests: Use %clangxx when using driver for C++, in case C++ support is disabled.
llvm-svn: 107153
2010-06-29 16:52:24 +00:00
Chandler Carruth b6f991787b Suppress diagnosing access violations while looking up deallocation functions
much as we already do for allocation function lookup. Explicitly check access
for the function we actually select in one case that was previously missing,
but being caught behind the blanket diagnostics for all overload candidates.
This fixs PR7436.

llvm-svn: 106986
2010-06-28 00:30:51 +00:00
Douglas Gregor 689999da1f String literals enclosed in parentheses are still string
literals. Fixes PR7488.

llvm-svn: 106607
2010-06-22 23:47:37 +00:00
Douglas Gregor db48cf3c31 Don't allow vector conversions to sneak in under the guise of
floating-point conversions or floating-integral conversions. We
really, really, really need to make isFloatingType() and friends not
apply to vector types.

llvm-svn: 106551
2010-06-22 16:52:27 +00:00
Douglas Gregor c9ea2d5a67 In C++, allow a declaration of an enum to follow a definition of that
enum as a GNU extension.

llvm-svn: 106540
2010-06-22 14:26:35 +00:00
Fariborz Jahanian 0bf5ee74c4 More Sema Check and a test case for init_priority attr.
(radar 8076356).

llvm-svn: 106350
2010-06-18 23:14:53 +00:00
Douglas Gregor 77e274fbc6 Merge the "regparm" attribute from a previous declaration of a
function to redeclarations of that function. Fixes PR7025.

llvm-svn: 106317
2010-06-18 21:30:25 +00:00
Douglas Gregor 428119e39a When parsing cached C++ method declarations/definitions, save the
"previous token" location at the end of the class definition. This
eliminates a badly-placed error + Fix-It when the ';' following a
class definition is missing. Fixes <rdar://problem/8066414>.

llvm-svn: 106175
2010-06-16 23:45:56 +00:00
John McCall 38e5f433b2 Fix the build. Using declarations should not be considering when looking
for overridden virtual methods.

llvm-svn: 106096
2010-06-16 09:33:39 +00:00
John McCall e9cccd86da Fix a point of semantics with using declaration hiding: method templates
introduced by using decls are hidden even if their template parameter lists
or return types differ from the "overriding" declaration.

Propagate using shadow declarations around more effectively when looking up
template-ids.  Reperform lookup for template-ids in member expressions so that
access control is properly set up.

Fix some number of latent bugs involving template-ids with totally invalid
base types.  You can only actually get these with a scope specifier, since
otherwise the template-id won't parse as a template-id.

Fixes PR7384.

llvm-svn: 106093
2010-06-16 08:42:20 +00:00
Douglas Gregor f267edd8ac Update equality and relationship comparisons of pointers to reflect
C++ semantics, eliminating an extension diagnostic that doesn't match
C++ semantics (ordered comparison with NULL) and tightening some
extwarns to errors in C++ to match GCC and maintain conformance in
SFINAE contexts. Fixes <rdar://problem/7941392>.

llvm-svn: 106050
2010-06-15 21:38:40 +00:00
Chris Lattner c548be9ab3 Remove a dead argument to ProcessUCNEscape.
Fix string concatenation to treat escapes in concatenated strings that
are wide because of other string chunks to process the escapes as wide
themselves.  Before we would warn about and miscompile the attached testcase.

This fixes rdar://8040728 - miscompile + warning: hex escape sequence out of range

llvm-svn: 106012
2010-06-15 18:06:43 +00:00
John McCall b86a6b830e Allow pseudo-destructors to be called on qualified pointers. Patch by
Troy Straszheim!

llvm-svn: 105823
2010-06-11 17:36:40 +00:00
Jeffrey Yasskin 2b99c6fc4f Add an option -fshow-overloads=best|all to limit the number of overload
candidates printed.  We default to 'all'.  At the moment, 'best' prints only
the first 4 overloads, but we'll improve that over time.

llvm-svn: 105815
2010-06-11 05:57:47 +00:00
Douglas Gregor 1fc3d66da4 Tweak our handling of the notion of a standard conversion sequence
being a subsequence of another standard conversion sequence. Instead
of requiring exact type equality for the second conversion step,
require type *similarity*, which is type equality with cv-qualifiers
removed at all levels. This appears to match the behavior of EDG and
VC++ (albeit not GCC), and feels more intuitive. Big thanks to John
for the line of reasoning that supports this change: since
cv-qualifiers are orthogonal to the second conversion step, we should
ignore them in the type comparison.

llvm-svn: 105678
2010-06-09 03:53:18 +00:00
Douglas Gregor 6f2e095f06 When referring to a tag that was previously declared only as a friend,
build a new declaration for that tag type that will be visible for
future lookups of that tag.

llvm-svn: 105643
2010-06-08 21:27:36 +00:00
Douglas Gregor ce21919bd6 A built-in overload candidate is consider a non-template function when
determining whether one overload candidate is better than
another. Fixes PR7319.

llvm-svn: 105642
2010-06-08 21:03:17 +00:00
Douglas Gregor ec170db73d Warn about comparisons between arrays and improve self-comparison
warnings, from Troy Straszheim! Fixes PR6163.

llvm-svn: 105631
2010-06-08 19:50:34 +00:00
Anders Carlsson 446872069f Correctly handle fields with virtual bases containing empty subobjects.
llvm-svn: 105628
2010-06-08 19:09:24 +00:00
Douglas Gregor 4038cf4b57 Implement a warning when converting the literal 'false' to a
pointer. Original patch by Troy D. Straszheim; fixes PR7283.

llvm-svn: 105621
2010-06-08 17:35:15 +00:00
Anders Carlsson 76f513f862 When deciding whether reinterpret_cast casts away constness we need to look at array qualifiers. Fixes rdar://problem/8018292.
llvm-svn: 105494
2010-06-04 22:47:55 +00:00
Anders Carlsson b1fcdd063c Turn on the new empty base subobject tracking code. It's a bit faster than the previous code. However, it still has quadratic performance, something which I intend to fix shortly in a subsequent patch.
llvm-svn: 105161
2010-05-30 06:52:33 +00:00
Anders Carlsson 6b0d914ad0 Rework the way virtual primary bases are added when laying out classes. Instead of doing it as a separate step, we now use the BaseSubobjectInfo and use it when laying out the bases. This fixes a bug where we would either not add a primary virtual base at all, or add it at the wrong offset.
llvm-svn: 105110
2010-05-29 19:44:50 +00:00
John McCall f9c94093f9 Disable exception-spec compatibility checking under -fno-exceptions.
Fixes PR7243.

llvm-svn: 104942
2010-05-28 08:37:35 +00:00
Douglas Gregor ed2540d205 When we complain about a member being inaccessible due to a constraint
along an access path, add another note pointing at the member we
actually found.

llvm-svn: 104937
2010-05-28 04:34:55 +00:00
Anders Carlsson 3e88da9fe5 Another empty class layout test.
llvm-svn: 104839
2010-05-27 16:15:06 +00:00
Anders Carlsson 1ff101cb1a Add more empty class layout tests.
llvm-svn: 104838
2010-05-27 16:07:49 +00:00
Fariborz Jahanian b0e28471a6 Improve on flexible array diagnostics (PR7029).
llvm-svn: 104739
2010-05-26 20:46:24 +00:00
Fariborz Jahanian 1138ba6693 Fixes misc. flexible array bugs in c++ (PR7029).
llvm-svn: 104733
2010-05-26 20:19:07 +00:00
Douglas Gregor b9f907bafc Make sure to strip off top-level cv-qualifiers as part of a
derived-to-base conversion on a pointer. Fixes PR7224.

llvm-svn: 104607
2010-05-25 15:31:05 +00:00
Douglas Gregor 9a414458ff Don't complain about VLAs of non-POD types when the array type is
dependent. Fixes <rdar://problem/8021385>.

llvm-svn: 104550
2010-05-24 20:42:30 +00:00
Douglas Gregor 5a5073e4d6 Make sure that we instantiate variably modified types, even if they
aren't dependent. Fixes <rdar://problem/8020206>.

llvm-svn: 104511
2010-05-24 17:22:01 +00:00
Douglas Gregor bb3348ed33 Downgrade deletion of a void* from an error (which is should be) to an
extension warning (which other compilers seem to use). Works around a
known bug in Xalan.

llvm-svn: 104509
2010-05-24 17:01:56 +00:00
Douglas Gregor e87561aa2e An identity conversion is better than any non-identity
conversion. Fixes PR7095.

llvm-svn: 104476
2010-05-23 22:10:15 +00:00
Douglas Gregor bea453a0fc In C++, one cannot assign from an arithmetic type to an enumeration
type. Fixes PR7051.

llvm-svn: 104475
2010-05-23 21:53:47 +00:00
Douglas Gregor a09387df9f It turns out that people love using VLAs in templates, too. Weaken our
VLA restrictions so that one can use VLAs in templates (even
accidentally), but not as part of a non-type template parameter (which
would be very bad).

llvm-svn: 104471
2010-05-23 19:57:01 +00:00
Douglas Gregor 2788782164 Complain about sizeof(overloaded function) rather than crashing.
llvm-svn: 104470
2010-05-23 19:43:23 +00:00
Anders Carlsson 5773205a8d When recording empty subobjects we should always look at the primary virtual base.
llvm-svn: 104464
2010-05-23 18:14:24 +00:00
Douglas Gregor 4b636a70d9 Put the VLA-is-an-extension warning into its own warning group (-Wvla)
so that it can be selectively enabled/disabled.

llvm-svn: 104462
2010-05-23 16:51:27 +00:00
Douglas Gregor 5e8c8c0e12 Even though we don't unique VLA types, we still need to build a
canonical type where the element type is canonical. Fixes PR7206.

llvm-svn: 104461
2010-05-23 16:10:32 +00:00
Douglas Gregor 0c6f539564 When determining whether we can use "this", make sure to look through
enum contexts (along with block contexts, which we already did). Fixes
PR7196.

llvm-svn: 104444
2010-05-22 16:25:05 +00:00
Douglas Gregor 959d5a0cbd Implement support for variable length arrays in C++. VLAs are limited
in several important ways:

  - VLAs of non-POD types are not permitted.
  - VLAs cannot be used in conjunction with C++ templates.

These restrictions are intended to keep VLAs out of the parts of the
C++ type system where they cause the most trouble. Fixes PR5678 and
<rdar://problem/8013618>.

llvm-svn: 104443
2010-05-22 16:17:30 +00:00
John McCall b54367d2f8 Propagate access specifiers to anonymous union members nested within classes.
Fixes <rdar://problem/7987650>.

llvm-svn: 104376
2010-05-21 20:45:30 +00:00
Douglas Gregor 27ac429624 Use CanQualType to enforce the use of a canonical type argument to
CXXBasePaths::isAmbiguous(), rather than just asserting that we have a
canonical type. Fixes PR7176.

llvm-svn: 104374
2010-05-21 20:29:55 +00:00