Richard Smith
f3e9e43da4
Constant expression evaluation: support for arrays.
...
llvm-svn: 143922
2011-11-07 09:22:26 +00:00
Richard Smith
8081560048
Constant expression evaluation: preserve subobject designator when flattening a
...
core constant value down to an APValue.
llvm-svn: 143909
2011-11-07 05:07:52 +00:00
Richard Smith
a08acd8588
Allow constexpr variables' initializers to be folded in C++11 mode. This
...
partially undoes the revert in r143491, but does not introduce any new instances
of the underlying issue (which is not yet fixed) in code which does not use
the 'constexpr' keyword.
llvm-svn: 143905
2011-11-07 03:22:51 +00:00
Richard Smith
fe5354b945
Clean up C++11 constant expression testing.
...
llvm-svn: 143720
2011-11-04 18:32:57 +00:00
Richard Smith
96e0c101fe
Constant expression evaluation: track the manner in which an lvalue was written,
...
to allow us to implement the C++11 rule that a non-active union member can't be
read, and use it to implement subobject access for string literals.
llvm-svn: 143677
2011-11-04 02:25:55 +00:00
Douglas Gregor
dd847baadd
When we're checking a friend function template in an out-of-line class
...
definition, we may not have a scope corresponding to the namespace
where that friend function template actually lives. Work around this
issue by faking up a scope with the appropriate DeclContext.
This is a bit of a hack, but it fixes <rdar://problem/10204947>.
llvm-svn: 143614
2011-11-03 16:37:14 +00:00
Douglas Gregor
10f939c3db
Don't build member initializers for zero-length or incomplete arrays,
...
and don't try to destroy them, either. Fixes
<rdar://problem/10228639>.
llvm-svn: 143584
2011-11-02 23:04:16 +00:00
Douglas Gregor
c3ae7c363e
When we run into a constructor or destructor that is defined in the
...
wrong class, make sure to drop it immediately; we don't want that
constructor to be available within the DeclContext. Fixes
<rdar://problem/9677163>.
llvm-svn: 143506
2011-11-01 22:13:30 +00:00
Richard Smith
1a77e8d10d
Fix r143463 to test what it was intended to test.
...
llvm-svn: 143505
2011-11-01 21:48:46 +00:00
Richard Smith
1f1f2d8ca3
Temporarily disable lvalue-to-rvalue conversions on const pointers while an
...
apparent miscompile triggered by this is investigated. This is essentially a
revert of r143298.
llvm-svn: 143491
2011-11-01 20:38:59 +00:00
Richard Smith
fec0992aca
Implement C++11 'constexpr calls must return constant expressions' rule, and
...
perform the code simplifications this rule allows.
llvm-svn: 143463
2011-11-01 16:57:24 +00:00
Sebastian Redl
72ef7bc2b5
Enable function call and some overload resolution with parameters of aggregate class type and initializer list arguments.
...
llvm-svn: 143462
2011-11-01 15:53:09 +00:00
Eli Friedman
c6be94b3de
Don't try to fold comparisons between the address of an object and an arbitrary integer constant. Fixes regression from r143334.
...
llvm-svn: 143374
2011-10-31 22:28:05 +00:00
Eli Friedman
90a2cdf1fb
Add missing lvalue-to-rvalue conversion.
...
llvm-svn: 143364
2011-10-31 20:59:03 +00:00
Richard Smith
4e4c78ffff
C++11 generalized constant expression handling: evaluation support for
...
materialized temporaries.
llvm-svn: 143335
2011-10-31 05:52:43 +00:00
Richard Smith
83c682115b
C++11 generalized constant expressions: evaluate equality comparisons between
...
arbitrary pointers, if those pointers don't point to weak objects or literals.
llvm-svn: 143334
2011-10-31 05:11:32 +00:00
Richard Smith
8b3497ee54
C++11 generalized constant expressions: support pointer comparisons where the
...
result is not unspecified.
llvm-svn: 143329
2011-10-31 01:37:14 +00:00
Richard Smith
35a1f85466
constexpr evaluation: allow lvalue-to-rvalue conversion on any literal type, not
...
just integers and floating point types. Since we don't support evaluating class
types or performing lvalue-to-rvalue conversions on array elements yet, this
just means pointer types right now.
llvm-svn: 143298
2011-10-29 21:53:17 +00:00
Richard Smith
0b0a0b6174
constexpr function substitution:
...
Track the function invocation where an lvalue referring to a constexpr function
parameter originated from, and use it to substitute the correct argument and to
determine whether such an argument's lifetime has ended.
llvm-svn: 143296
2011-10-29 20:57:55 +00:00
Richard Smith
254a73d636
Initial support for C++11 constexpr function invocation substitution. Using
...
constexpr function arguments outside of their function (passing or returning
them by reference) does not work correctly yet.
Calling constexpr function templates does not work yet, since the bodies are not
instantiated until the end of the translation unit.
llvm-svn: 143234
2011-10-28 22:34:42 +00:00
Richard Smith
11562c5e10
Reinstate r142844 (reverted in r142872) now that lvalue-to-rvalue conversions
...
are present in all the necessary places:
In constant expression evaluation, evaluate lvalues as lvalues and rvalues as
rvalues. Remove special case for caching reference initialization and fix a
cyclic initialization crash in the process.
llvm-svn: 143204
2011-10-28 17:51:58 +00:00
Richard Smith
508ebf35ee
Add (hopefully) the last missing lvalue-to-rvalue conversion. Add an assertion
...
to catch some future implicit lvalue-to-rvalue casts of inappropriate kinds.
llvm-svn: 143182
2011-10-28 03:31:48 +00:00
Richard Smith
01ebacd80d
Add missing lvalue-to-rvalue conversion to vector splat casts.
...
llvm-svn: 143166
2011-10-27 23:31:58 +00:00
Richard Smith
08b12f1f5e
Fix some cases where a CK_IntegralCast was being used to convert an lvalue to an
...
rvalue. An assertion to catch this is in ImpCastExprToType will follow, but
vector operations currently trip over this (due to omitting the usual arithmetic
conversions). Also add an assert to catch missing lvalue-to-rvalue conversions
on the LHS of ->.
llvm-svn: 143155
2011-10-27 22:11:44 +00:00
Richard Smith
3d5c1fa93f
UnresolvedMemberExprs need lvalue-to-rvalue conversions during template
...
instantiations too.
llvm-svn: 143016
2011-10-26 06:15:36 +00:00
Richard Smith
d4268d91e7
Don't forget the lvalue-to-rvalue conversion on the LHS when instantiating a
...
dependent ->, where the member being referred to is an anonymous struct or
union. This path was missed by the fix in r142890.
llvm-svn: 142910
2011-10-25 06:33:21 +00:00
Douglas Gregor
ab6bc1d13e
Make the -Wc++11-compat warnings ignored by default, so we don't break
...
valid C++98/03 code. However, add these warnings to -Wall, for those
who obviously already like clean code.
llvm-svn: 142903
2011-10-25 03:07:45 +00:00
Richard Smith
e042bbfdf8
Tidy up testcase from r142890, spotted by Chandler.
...
llvm-svn: 142895
2011-10-25 01:05:41 +00:00
Richard Smith
841222ea75
Don't forget the lvalue-to-rvalue conversion on the LHS of an -> when rebuilding
...
it during template instantiation, for a known RHS decl.
llvm-svn: 142890
2011-10-25 00:41:24 +00:00
Richard Smith
733237db23
Revert r142844, it broke selfhost. The problem appears to be a missing
...
lvalue-to-rvalue conversion on the LHS operand of '->'.
llvm-svn: 142872
2011-10-24 23:14:33 +00:00
Richard Smith
cbb407268e
Constant expression evaluation: evaluate lvalues as lvalues, and rvalues as
...
rvalues, as C++11 constant evaluation semantics require. DeclRefs referring to
references can now use the normal initialization-caching codepath, which
incidentally fixes a crash in cyclic initialization of references.
llvm-svn: 142844
2011-10-24 21:07:08 +00:00
Richard Smith
c3e31e7bb2
In accordance with the C89, C99 and C++98 standards, ICEs can only contain
...
floating-point literals if they are the immediate operands of casts.
ImplicitCastExpr is not a cast in the language-standards sense.
llvm-svn: 142832
2011-10-24 18:26:35 +00:00
Ted Kremenek
81ce1c8a99
Rename AnalysisContext to AnalysisDeclContext. Not only is this name more accurate, but it frees up the name AnalysisContext for other uses.
...
llvm-svn: 142782
2011-10-24 01:32:45 +00:00
Peter Collingbourne
7d33cd3a2f
Fix grammar for C++11 alignment specifiers, and add a few FIXMEs.
...
llvm-svn: 142760
2011-10-23 20:07:52 +00:00
Peter Collingbourne
e109a2ca59
Attach class template attributes to the templated CXXRecordDecl,
...
instead of silently discarding them.
As a side effect, this improves diagnostics for constexpr class
templates slightly.
llvm-svn: 142755
2011-10-23 17:07:16 +00:00
DeLesley Hutchins
f893e8ab87
Added support for thread safety attributes on destructors.
...
llvm-svn: 142685
2011-10-21 20:51:27 +00:00
DeLesley Hutchins
c20905110a
Thread safety analysis refactoring: invalid lock expressions.
...
llvm-svn: 142666
2011-10-21 18:10:14 +00:00
DeLesley Hutchins
db917bdea2
Thread safety analysis: add support for attributes on constructors.
...
llvm-svn: 142665
2011-10-21 18:06:53 +00:00
Douglas Gregor
60060d6f8f
Treat the Microsoft/Borland keyword "__except" as a context-sensitive
...
keyword, because both libstdc++ and libc++ use "__except" as an
identifier. Fixes <rdar://problem/10322555>.
llvm-svn: 142636
2011-10-21 03:57:52 +00:00
Richard Smith
fe2750db42
Add -Wc++98-compat diagnostics for jumps which bypass initialization of non-POD
...
but trivially constructible and destructible variables in C++11 mode. Also
incidentally improve the precision of the wording for jump diagnostics in C++98
mode.
llvm-svn: 142619
2011-10-20 21:42:12 +00:00
Richard Smith
f411196d15
'extern template' is a C++11 feature. Add an Extension for C++98 (this matches
...
gcc's behaviour), and a -Wc++98-compat-pedantic warning for C++11.
llvm-svn: 142597
2011-10-20 18:35:58 +00:00
Richard Smith
91c7bbde4b
Add -Wc++98-compat warning for enumerations in nested name specifiers.
...
llvm-svn: 142568
2011-10-20 03:28:47 +00:00
David Blaikie
0a8e8999d6
Don't provide errors for anonymous unions when they're actually anonymous classes.
...
llvm-svn: 142551
2011-10-19 22:43:29 +00:00
Richard Smith
f720df0ed6
-Wc++98-compat: warn on nontrivial types used in unions and anonymous structs.
...
llvm-svn: 142541
2011-10-19 20:41:51 +00:00
Richard Smith
c620f554b9
-Wc++98-compat: diagnose if a reference is bound to a prvalue which does not
...
have an unambiguous accessible copying constructor; this is ill-formed in C++98.
llvm-svn: 142533
2011-10-19 16:55:56 +00:00
Richard Smith
a066ccfcf1
Add a -Wc++98-compat warning for friend functions of class templates which would
...
be implicitly instantiated (resulting in a redefinition) in C++98.
llvm-svn: 142468
2011-10-19 00:54:10 +00:00
Richard Smith
38c0e0417c
-Wc++98-compat: warn if a SFINAE substitution in C++11 suppresses an access
...
control diagnostic.
llvm-svn: 142463
2011-10-19 00:07:01 +00:00
Richard Smith
c82397332d
-Wc++98-compat and -Wc++98-compat-pedantic warnings for Sema, part 2.
...
llvm-svn: 142426
2011-10-18 21:39:00 +00:00
Richard Smith
0bf8a492fd
-Wc++98-compat and -Wc++98-compat-pedantic warnings for Sema, part 1.
...
llvm-svn: 142419
2011-10-18 20:49:44 +00:00
David Blaikie
cc5f8f0d9e
Switch to the C++11 warning flags in tests.
...
Patch by Ahmed Charles!
llvm-svn: 142340
2011-10-18 05:54:07 +00:00