Commit Graph

1079 Commits

Author SHA1 Message Date
Alexis Hunt 79eb5469e0 Implement C++0x user-defined string literals.
The extra data stored on user-defined literal Tokens is stored in extra
allocated memory, which is managed by the PreprocessorLexer because there isn't
a better place to put it that makes sure it gets deallocated, but only after
it's used up. My testing has shown no significant slowdown as a result, but
independent testing would be appreciated.

llvm-svn: 112458
2010-08-29 21:26:48 +00:00
Ted Kremenek d7478d6010 Update test case, with comment to later investigate the correct behavior. Now the behavior is at least consistent.
llvm-svn: 112335
2010-08-28 00:19:12 +00:00
Ted Kremenek 82bfc86792 Explicitly handle CXXExprWithTemporaries during CFG construction by just visiting the subexpression. While we don't do anything intelligent right now, this obviates a bogus -Wunreahable-code warning reported in PR 6130.
llvm-svn: 112334
2010-08-28 00:19:02 +00:00
Douglas Gregor 7bddb3cac3 Improve wording of diagnostic complaining about a non-void* pointer as the first parameter of operator delete
llvm-svn: 112298
2010-08-27 21:39:15 +00:00
John McCall 1ababa63de Continue to instantiate sub-statements in a CompoundStmt as long as
we don't see a DeclStmt (failure to instantiate which generally causes
panic).

llvm-svn: 112282
2010-08-27 19:56:05 +00:00
John McCall 8d08b9b408 Propagate whether an id-expression is the immediate argument of
an '&' expression from the second caller of ActOnIdExpression.

Teach template argument deduction that an overloaded id-expression
doesn't give a valid type for deduction purposes to a non-static
member function unless the expression has the correct syntactic
form.

Teach ActOnIdExpression that it shouldn't try to create implicit
member expressions for '&function', because this isn't a        
permitted form of use for member functions.

Teach CheckAddressOfOperand to diagnose these more carefully.
Some of these cases aren't reachable right now because earlier
diagnostics interrupt them.

llvm-svn: 112258
2010-08-27 09:08:28 +00:00
Eric Christopher a613f56559 With lax vector conversions (the default) make sure we convert between two
vectors that are the same size. Fix up testcases accordingly and add a new one
to make sure we still error if lax vector conversions are disabled.

Fixes rdar://8328190

llvm-svn: 112122
2010-08-26 00:42:16 +00:00
Fariborz Jahanian f4677b201e Move the test for radar 8018252 to
SemaCXX/expressions.cpp.

llvm-svn: 111988
2010-08-24 22:55:33 +00:00
Fariborz Jahanian e0fd5a9299 It is not error in c++ to take address of
register variable (c++03 7.1.1P3). radar 8108252.

llvm-svn: 111977
2010-08-24 22:21:48 +00:00
Douglas Gregor 117db7e95a Parse all kinds of declarations as part of a linkage-specification,
from Francois Pichet! Fixes PR7754. 

llvm-svn: 111912
2010-08-24 14:14:45 +00:00
Eli Friedman 7fd5544bc9 PR7971: Compute the correct type for an address-of expression containing an
UnresolvedMemberExpr.

llvm-svn: 111899
2010-08-24 05:23:20 +00:00
Chandler Carruth c926240172 Relax the construction of a definition for implicit, trivial default
constructors. We perform semantic checking when creating the definition, and
this isn't needed in certain contexts (value initialization) but is in others
(default initialization). This fixes PR7948.

We add explicit code to the default initialization path to ensure the
definition is both present and valid.

Doug, please review. I think this follows your latest suggestion, and it ended
up remarkably cleaner than I anticipated. Also let me know if similar logic
should be followed for destructors and copy-constructors.

llvm-svn: 111802
2010-08-23 07:55:51 +00:00
Douglas Gregor c0afc67608 We don't actually need to check the implicit object argument's
conversion a second time for a conversion candidate (with the real
acting context), because the only problems we would find are access or
ambiguity issues that won't be diagnosed until we pick this
candidate. Add a test case to prove it to myself.

llvm-svn: 111526
2010-08-19 17:02:01 +00:00
Douglas Gregor c9ed4681a8 Properly implement the part of C++ [over.match.funcs]p4 that treats
conversion functions as if their acting context were the class that
we're converting from (the implicit object argument's
type). Retroactively tweaking the implicit conversion sequence, as we
were trying to do before, breaks the invariants of that implicit
conversion sequence (e.g., the types and conversions don't match
up). Fixes <rdar://problem/8018274>.

llvm-svn: 111520
2010-08-19 15:57:50 +00:00
Eli Friedman 4202c34539 Fix for PR7911 and PR7921: make isIntegralOrEnumerationType return false
for incomplete enum types.  An incomplete enum can't really be treated as
an "integral or enumeration" type, and the incorrect treatment leads to
bad behavior for many callers.

This makes isIntegralOrEnumerationType equivalent to isIntegerType; I think
we should globally replace the latter with the former; thoughts?

llvm-svn: 111512
2010-08-19 04:39:37 +00:00
John McCall 5cf48cd17c On second thought, don't warn about reinterpret_casts under -Wcast-align.
llvm-svn: 111497
2010-08-19 01:19:08 +00:00
Ted Kremenek 50e0105f1c Add warning for functions/blocks that have attribute 'noreturn' but return a non-void result. (<rdar://problem/7562925>)
llvm-svn: 111492
2010-08-19 00:52:13 +00:00
Douglas Gregor fb640869ed There is no pointer conversion between to similar types (i.e., same
type ignoring cv-qualifiers). These are qualification
conversions. Fixes PR7934.

llvm-svn: 111428
2010-08-18 21:25:30 +00:00
John McCall 8f42893aff Flesh out the test cases a little.
llvm-svn: 111359
2010-08-18 09:58:15 +00:00
John McCall 02db245d5e Rip out the existing retroactive abstract-class usage checker,
which in a fit of zeal wanted to walk the entire translation unit,
and replace it with a new checker that walks the types of declarations
nested within the class.  Also, look into templates when doing this.

llvm-svn: 111357
2010-08-18 09:41:07 +00:00
Argyrios Kyrtzidis beb71b315a Rename -Wunused-method -> -Wunused-member-function.
llvm-svn: 111305
2010-08-17 22:06:44 +00:00
Argyrios Kyrtzidis cad715fb9b Introduce -Wunused-method option for warning on unused class methods in anonymous namespace.
This option is not part of the Unused diagnostic group until the warnings on llvm codebase are fixed
and we are ready to turn it on. Suggestion by Daniel.

llvm-svn: 111298
2010-08-17 21:43:11 +00:00
Douglas Gregor 175ea046ee A member function never has "C" linkage. Fixes <rdar://problem/8318976>.
llvm-svn: 111238
2010-08-17 16:09:23 +00:00
John McCall 3696dcb171 Don't try to initialize a reference with a constructed temporary if either
of the classes is invalid.  A class is invalid if a base is invalid.

llvm-svn: 111227
2010-08-17 07:23:57 +00:00
John McCall 2677e10732 A field of incomplete type is sufficiently disruptive that we should mark
the record invalid.

llvm-svn: 111211
2010-08-16 23:42:35 +00:00
Argyrios Kyrtzidis 33aee3934a Emit diagnostic error when the field of an anonymous struct is non trivial.
llvm-svn: 111158
2010-08-16 17:27:08 +00:00
Charles Davis ebab1ed5d3 Error out if reinterpret_casting between member pointers of two different
sizes.

llvm-svn: 111119
2010-08-16 05:30:44 +00:00
Charles Davis 2d3694297d Err on incomplete class types in member pointers when compiling for the
Microsoft C++ ABI, for now.

llvm-svn: 111118
2010-08-16 04:01:50 +00:00
Argyrios Kyrtzidis 04c7fa09e4 Don't warn for the common pattern of disallowing copying:
class S {
  S(const S&); // DO NOT IMPLEMENT
  void operator=(const S&); // DO NOT IMPLEMENT
};

llvm-svn: 111100
2010-08-15 10:17:33 +00:00
Argyrios Kyrtzidis 1b30d9c0f0 Commit improved version of 111026 & 111027.
Unused warnings for functions:
-static functions
-functions in anonymous namespace
-class methods in anonymous namespace
-class method specializations in anonymous namespace
-function specializations in anonymous namespace

Unused warnings for variables:
-static variables
-variables in anonymous namespace
-static data members in anonymous namespace
-static data members specializations in anonymous namespace

Reveals lots of opportunities for dead code removal in llvm codebase that will
interest my esteemed colleagues.

llvm-svn: 111086
2010-08-15 01:15:20 +00:00
Argyrios Kyrtzidis 98703d3883 Revert 111026 & 111027, build breakage.
llvm-svn: 111036
2010-08-13 20:13:06 +00:00
Argyrios Kyrtzidis 1063a71e43 The unused warnings extravaganza continues. Warn for:
-static variables
-variables in anonymous namespace (fixes rdar://7794535)
-static data members in anonymous namespace
-static data members specializations in anonymous namespace

llvm-svn: 111027
2010-08-13 18:42:40 +00:00
Argyrios Kyrtzidis 540bc01f50 Expand the unused warnings for functions. Warn for:
-static function declarations
-functions in anonymous namespace
-class methods in anonymous namespace
-class method specializations in anonymous namespace
-function specializations in anonymous namespace

llvm-svn: 111026
2010-08-13 18:42:29 +00:00
John McCall b3732bb3b7 Just disable the hidden-visibility optimization for now by hiding it behind
a -cc1 option.  The Darwin linker complains about mixed visibility when linking
gcc-built objects with clang-built objects, and the optimization isn't really
that valuable.  Platforms with less ornery linkers can feel free to enable this.

llvm-svn: 110979
2010-08-12 23:36:15 +00:00
John McCall 2b5c1b2516 Implement -Wcast-align. The initial design of this diagnostic diverges
from GCC's in that we warn on *any* increase in alignment requirements, not
just those that are enforced by hardware.  Please let us know if this causes
major problems for you (which it shouldn't, since it's an optional warning).

llvm-svn: 110959
2010-08-12 21:44:57 +00:00
John McCall 8246e350be Handle the obvious case for diagnosing redeclarations of extern "C" functions.
Fixes PR7859.

llvm-svn: 110906
2010-08-12 07:09:11 +00:00
John McCall 12d53da8cb Fix a crash on invalid when declaring an implicit member of a class with an
invalid destructor.

llvm-svn: 110891
2010-08-12 00:57:17 +00:00
Douglas Gregor 836a7e8468 Improve our handling of user-defined conversions when computing
implicit conversion sequences. In particular, model the "standard
conversion" from a class to its own type (or a base type) directly as
a standard conversion in the normal path *without* trying to determine
if there is a valid copy constructor. This appears to match the intent
of C++ [over.best.ics]p6 and more closely matches GCC and EDG.

As part of this, model non-lvalue reference initialization via
user-defined conversion in overloading the same way we handle it in
InitializationSequence, separating the "general user-defined
conversion" and "conversion to compatible class type" cases.

The churn in the overload-call-copycon.cpp test case is because the
test case was originally wrong; it assumed that we should do more
checking for copy constructors that we actually should, which affected
overload resolution.

Fixes PR7055. Bootstrapped okay.

llvm-svn: 110773
2010-08-11 02:15:33 +00:00
Douglas Gregor 86b8d9ff87 When attempting to recover from a failed unqualified name lookup, make
sure to clear out the LookupResult structure after looking into each class.

llvm-svn: 110615
2010-08-09 22:38:14 +00:00
Chandler Carruth 9b41823177 Fix a crash on template delete operators.
llvm-svn: 110542
2010-08-08 07:04:00 +00:00
Eli Friedman 9129b00c5f Make this test check a few more cases which didn't work correctly before
r110526.

llvm-svn: 110540
2010-08-08 05:07:06 +00:00
Eli Friedman aab1fda91f PR7800: both virtual and non-virtual bases must be marked as used for VTTs.
llvm-svn: 110526
2010-08-07 23:11:44 +00:00
Douglas Gregor a49ccfeeb2 The pre-increment/pre-decrement grammar in C++ differs from that in C,
but we were parsing the C grammar. Handle the C++ grammar
appropriately. Fixes PR7794.

llvm-svn: 110445
2010-08-06 14:50:36 +00:00
Douglas Gregor 59e8b3bd7b Introduce implicit conversions between AltiVec vectors and GCC
vectors, from Anton Yartsev!

llvm-svn: 110437
2010-08-06 10:14:59 +00:00
Eli Friedman 74ef7cf144 PR7769: Fix references to anonymous structs/unions in base classes in
offsetof expressions.

llvm-svn: 110327
2010-08-05 10:11:36 +00:00
Nick Lewycky ef7c0ffe40 Remove the warning for variables declared in the if-expression being used in
the else clause. The problem is that it's overly zealous and will respond to
uses in assignments, or after assignments. We should bring this back once we
can do it right. Fixes PR7100.

llvm-svn: 110314
2010-08-05 06:27:49 +00:00
Sebastian Redl e0351b970d Remove a redundant and broken check. Fixes PR7810.
llvm-svn: 110294
2010-08-05 00:45:34 +00:00
John McCall e16adc2b1e Emit standard-library RTTI with external linkage, not weak_odr.
Apply hidden visibility to most RTTI;  libstdc++ does not rely on exact
pointer equality for the type info (just the type info names).  Apply
the same optimization to RTTI that we do to vtables.

Fixes PR5962.

llvm-svn: 110192
2010-08-04 08:34:44 +00:00
John McCall deb646ebb5 Only look up an 'operator delete' on the definition of a destructor, not on
a declaration.

llvm-svn: 110175
2010-08-04 01:04:25 +00:00
John McCall 4a33fa95c0 Labels (and case statement) don't create independent scope parents for the
purposes of the jump checker.  Also extend Ted's iteration fix to labels.

Fixes PR7789.

llvm-svn: 110082
2010-08-02 23:33:14 +00:00