Commit Graph

926 Commits

Author SHA1 Message Date
Anders Carlsson 58e24a8fd8 Change the 'declared at' diagnostic to say 'declared here'.
llvm-svn: 102163
2010-04-23 02:20:12 +00:00
Anders Carlsson 3c1db570b2 Factor code to initialize an implicit member out into a separate function.
llvm-svn: 102162
2010-04-23 02:15:47 +00:00
Douglas Gregor 2c4a7501ee When parsing a cast-expression that starts with a scope annotation,
try to annotate as a type first to determine whether we have a
functional-style cast. Patch by Eli Friedman, fixes PR6830.

llvm-svn: 102161
2010-04-23 02:08:13 +00:00
John McCall 8c12dc4351 Use the naming class from the overloaded lookup when access-checking an
address of overloaded function, instead of assuming that a nested name
specifier was used.  A nested name specifier is not required for static
functions.

Fixes PR6886.

llvm-svn: 102107
2010-04-22 18:44:12 +00:00
Douglas Gregor fceea36501 When checking whether to diagnose an initialized "extern" variable,
look for the const on the base type rather than on the top-level
type. Fixes PR6495 properly.

llvm-svn: 102066
2010-04-22 14:36:26 +00:00
Douglas Gregor 4f4946aaaa Whenever we complain about a failed initialization of a function or
method parameter, provide a note pointing at the parameter itself so
the user does not have to manually look for the function/method being
called and match up parameters to arguments. For example, we now get:

t.c:4:5: warning: incompatible pointer types passing 'long *' to
parameter of
      type 'int *' [-pedantic]
  f(long_ptr);
    ^~~~~~~~
t.c:1:13: note: passing argument to parameter 'x' here
void f(int *x);
            ^

llvm-svn: 102038
2010-04-22 00:20:18 +00:00
John McCall 0f55a035cf Restore r101841 without modification. Also mark 'operator delete' as used for
actual delete expressions, not just new expressions.

llvm-svn: 101861
2010-04-20 02:18:25 +00:00
John McCall 44adf26dd0 Revert r101841 and follow-up.
llvm-svn: 101859
2010-04-20 01:42:53 +00:00
John McCall 21f8d1d643 Use __SIZE_TYPE__ as suggested by dgregor.
llvm-svn: 101857
2010-04-20 01:26:56 +00:00
John McCall 75b4746e7d Don't bother looking for (or diagnosing problems with) the 'operator delete'
associated with a new expression if -fno-exceptions is set.

llvm-svn: 101841
2010-04-20 00:22:43 +00:00
Douglas Gregor dc35ef9279 Do not diagnose unused-parameter errors in template instantiations. We
will already have done so when the template is declared.

llvm-svn: 101838
2010-04-19 23:56:20 +00:00
Douglas Gregor f4cd8f4ece Only suppress the "extern variable has an initializer" warning when the extern entity being initialized is const.
llvm-svn: 101821
2010-04-19 22:34:40 +00:00
Douglas Gregor c81ca09830 Disable the "'extern' variable has an initializer" warning in C++,
since it makes sense there to have const extern variables. Fixes
PR6495.

llvm-svn: 101818
2010-04-19 21:31:25 +00:00
Douglas Gregor 870f3743e4 When performing reference initialization for the purposes of overload
resolution ([over.ics.ref]), we take some shortcuts required by the
standard that effectively permit binding of a const volatile reference
to an rvalue. We have to treat lightly here to avoid infinite
recursion.

Fixes PR6177.

llvm-svn: 101712
2010-04-18 09:22:00 +00:00
Douglas Gregor 7566e4ad2c Do not consider explicit constructors when performing a copy to a
temporary object. This is blindingly obvious from reading C++
[over.match.ctor]p1, but somehow I'd missed it and it took DR152 to
educate me. Adjust one test that was relying on this non-standard
behavior.

llvm-svn: 101688
2010-04-18 02:16:12 +00:00
Douglas Gregor 5ab1165531 Improve our handling of user-defined conversions as part of overload
resolution. There are two sources of problems involving user-defined
conversions that this change eliminates, along with providing simpler
interfaces for checking implicit conversions:

  - It eliminates a case of infinite recursion found in Boost.

  - It eliminates the search for the constructor needed to copy a temporary
    generated by an implicit conversion from overload
    resolution. Overload resolution assumes that, if it gets a value
    of the parameter's class type (or a derived class thereof), there
    is a way to copy if... even if there isn't. We now model this
    properly.

llvm-svn: 101680
2010-04-17 22:01:05 +00:00
Douglas Gregor 24f27696db If a non-noreturn virtual member function is guaranteed not to return,
do *not* suggest that the function could be attribute 'noreturn';
overridden functions may end up returning.

llvm-svn: 101572
2010-04-16 23:28:44 +00:00
Anders Carlsson 5723516ce9 More work on wide bit-fields, WIP.
llvm-svn: 101467
2010-04-16 15:57:11 +00:00
Anders Carlsson d5635feb1a Start working on handling wide bitfields in C++
llvm-svn: 101464
2010-04-16 15:16:32 +00:00
Douglas Gregor b8eaf2944b Audit uses of Sema::LookupSingleName for those lookups that are
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
2010-04-15 23:40:53 +00:00
Douglas Gregor e8154339f4 Diagnose attempts to throw an abstract class type.
llvm-svn: 101381
2010-04-15 18:05:39 +00:00
Douglas Gregor c1cf814c8b Fix a few cases where enum constant handling was using
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
2010-04-15 15:53:31 +00:00
Douglas Gregor 454a5b65d4 Warn about non-aggregate classes with no user-declared constructors
that have reference or const scalar members, since those members can
never be initializer or modified. Fixes <rdar://problem/7804350>.

llvm-svn: 101316
2010-04-15 00:00:53 +00:00
Douglas Gregor 064fdb2fe8 Always diagnose and complain about problems in
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
2010-04-14 23:11:21 +00:00
Douglas Gregor 2d2d90750c Once we've emitted a fatal diagnostic, keep counting errors but with a
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
2010-04-14 22:19:45 +00:00
Douglas Gregor 2bf2d3d016 When diagnosing suspicious precedence or assignments, move the fix-it
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
2010-04-14 16:09:52 +00:00
Douglas Gregor e5e775bc8e When returning the result of a call to an object of class type, do not
return a NULL expression; return either an error or a proper
expression. Fixes PR6078.

llvm-svn: 101133
2010-04-13 15:50:39 +00:00
John McCall 43314ab3ae Allow classes to befriend implicitly-declared members. Fixes PR6207 for
members of non-templated classes.

llvm-svn: 101122
2010-04-13 07:45:41 +00:00
John McCall 212fa2efb7 Diagnose declarations of conversion functions with declarators other than '()'.
llvm-svn: 101098
2010-04-13 00:04:31 +00:00
Douglas Gregor 5c0066f1cf Improve source-location information for C++ conversion functions, by
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
2010-04-12 23:19:01 +00:00
Douglas Gregor b93b606759 When creating the implicitly-declared special member functions, be
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
2010-04-12 17:09:20 +00:00
Sebastian Redl c72350ea9f When a member pointer is dereferenced, the class it points into must be complete. Enforce this.
llvm-svn: 100925
2010-04-10 10:14:54 +00:00
John McCall 23eebd9c1e Diagnose more cases of initializing distinct members of an anonymous union
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
2010-04-10 09:28:51 +00:00
John McCall bb7b658ab5 Diagnose misordered initializers in constructor templates immediately instead of
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
2010-04-10 07:37:23 +00:00
John McCall 3155f573f5 Turn access control on by default in -cc1.
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
2010-04-09 19:03:51 +00:00
Douglas Gregor fb8b27d530 Remove all "used" static functions *after* we have performed all of
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
2010-04-09 17:41:13 +00:00
Douglas Gregor c68e140657 Improve diagnostics when we fail to convert from a source type to a
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
2010-04-09 00:35:39 +00:00
Douglas Gregor f19ac0ede9 Downgrade the "declaration does not declare anything" error to a
warning. It's not harmful to have such pointless declarations, and GCC
does not diagnose this issue consistently.

llvm-svn: 100814
2010-04-08 21:33:23 +00:00
Douglas Gregor 01e09d9d91 Introduce an egregious hack to work around a bug in libstdc++ 4.2.x's
<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
2010-04-08 18:16:15 +00:00
Jeffrey Yasskin c76498d409 Make CXXScopeSpec invalid when incomplete, and propagate that into any
Declarator that depends on it.  This fixes several redundant errors and bad
recoveries.

llvm-svn: 100779
2010-04-08 16:38:48 +00:00
Jeffrey Yasskin 4e150f8d35 Fix some redundant errors by changing CXXScopeSpec::isSet calls into
isNotEmpty calls.

llvm-svn: 100722
2010-04-07 23:29:58 +00:00
Chris Lattner 4b73cfabac rename llvm::llvm_report_error -> llvm::report_fatal_error
llvm-svn: 100708
2010-04-07 22:58:06 +00:00
Douglas Gregor 45cf7e3d2a Rework our handling of copy construction of temporaries, which was a
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
2010-04-02 18:24:57 +00:00
Anders Carlsson 7b3f2788a1 Diagnose multiple base and member initializers in class templates.
llvm-svn: 100179
2010-04-02 05:42:15 +00:00
Douglas Gregor f5af3584ca Improve diagnostics when an elaborated-type-specifer containing a
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
2010-03-31 23:17:41 +00:00
John McCall eae5acbbd0 Fix PR6327: restore invariants when there's a parse error in an initializer.
llvm-svn: 99980
2010-03-31 02:13:20 +00:00
Anders Carlsson 83ac312965 Fix a bug where we would incorrectly report an error about initializing two fields in an anonymous struct.
llvm-svn: 99891
2010-03-30 16:19:37 +00:00
Douglas Gregor c48a10d652 Support __attribute__((packed)) (along with other attributes) at the
end of a struct/class/union in C++, from Justin Bogner!

llvm-svn: 99811
2010-03-29 14:42:08 +00:00
Anders Carlsson abb20e6249 Fix a nasty bug in the virtual base computation which would lead to us initializing virtual bases in the wrong order.
llvm-svn: 99806
2010-03-29 05:13:12 +00:00
Douglas Gregor 4667effa8b Compare namespaces properly when looking for redeclarations of
namespace aliases. Fixes PR6341.

llvm-svn: 99664
2010-03-26 22:59:39 +00:00
Douglas Gregor f9edf80c39 When trying to determine whether one operand of a conditional
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
2010-03-26 20:59:55 +00:00
Douglas Gregor 838fcc318a Switch semantic analysis of the conditional operator from using
CheckReferenceInit to using the new initialization sequence code.

llvm-svn: 99647
2010-03-26 20:14:36 +00:00
Douglas Gregor f956b35f98 Do not mark the destructor of a function parameter's type. Fixes PR6709.
llvm-svn: 99615
2010-03-26 06:57:13 +00:00
Douglas Gregor deb714ceeb Switch static_cast from the old reference-initialization code (via
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
2010-03-24 23:38:29 +00:00
Douglas Gregor d6bc5e6bbc When a declaration of a function is missing an exception specification
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
2010-03-24 07:14:45 +00:00
Douglas Gregor bcf0a47e7a When performing name lookup for the allocation or deallocation
operators, make sure that the implicitly-declared global new and
delete operators are always available. Fixes PR5904.

llvm-svn: 99382
2010-03-24 05:07:21 +00:00
Douglas Gregor f9f54eab43 Make sure to properly track the anonymous namespace that lives inside
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
2010-03-24 00:46:35 +00:00
Douglas Gregor b525ef87fc When recovering from a qualified typedef name, don't clear out the
DeclContext because we don't want a NULL DeclContext. Instead, use the
current context.

llvm-svn: 99281
2010-03-23 15:26:55 +00:00
Rafael Espindola 568586ff22 Fix PR6618.
If a struct has an invalid field, mark it as invalid. Also avoid producing
errors about incomplete types that are invalid.

llvm-svn: 99150
2010-03-21 22:56:43 +00:00
John McCall 2d8c760df7 Implement -Wshadow for parameter declarations as well.
llvm-svn: 99037
2010-03-20 04:12:52 +00:00
John McCall ce5cbdc4ff Promote enum types during -Wsign-compare. Fixes some spurious warnings,
mostly during conditional expressions.

llvm-svn: 98975
2010-03-19 18:53:26 +00:00
John McCall ef01f71a5a Pretty-print anonymous types using their kind and presumed location.
Fixes PR6643.  Patch by Mike M!

llvm-svn: 98946
2010-03-19 07:56:44 +00:00
John McCall a332b953e8 When elevating access along an inheritance path, initialize the computed
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
2010-03-18 23:49:19 +00:00
John McCall 9a3da8e6cf Provide a test case for PR6629.
llvm-svn: 98702
2010-03-17 01:31:25 +00:00
John McCall 9a9ae00442 Forgot the testcases.
llvm-svn: 98685
2010-03-16 21:50:59 +00:00
Rafael Espindola 13327bbe55 Fix PR6562. If a type is dependent, we don't know if it will have implicit
destructors.

llvm-svn: 98440
2010-03-13 18:12:56 +00:00
John McCall c493a73240 Improve the unused-value check to look into comma expressions and filter out
voids in sub-expressions.  Patch by Mike M!

Fixes PR4806.

llvm-svn: 98335
2010-03-12 07:11:26 +00:00
Rafael Espindola e81620fb88 Move test and also test codegen.
llvm-svn: 98154
2010-03-10 14:01:14 +00:00
John McCall 85f9055955 When pretty-printing tag types, only print the tag if we're in C (and
therefore not creating ElaboratedTypes, which are still pretty-printed
with the written tag).

Most of these testcase changes were done by script, so don't feel too
sorry for my fingers.

llvm-svn: 98149
2010-03-10 11:27:22 +00:00
Rafael Espindola 69902a0a0d add missing test
llvm-svn: 98129
2010-03-10 02:43:01 +00:00
Douglas Gregor 589973b097 In C++98/03, an uninitialized variable that has POD class type will be
uninitialized. This seems not to be the case in C++0x, where we still
call the (trivial) default constructor for a POD class
(!). Previously, we had implemented only the C++0x rules; now we
implement both. Fixes PR6536.

llvm-svn: 97928
2010-03-08 02:45:10 +00:00
Douglas Gregor 104ee00181 Downgrade errors when trying to catch a pointer or reference to
incomplete type to warnings; GCC (and EDG in GCC compatibility mode)
permit such handles. Fixes PR6527.

(For real this time)

llvm-svn: 97927
2010-03-08 01:47:36 +00:00
Chandler Carruth 3681e58d8b Revert r97925, it only contained the test updates not the actual fix.
llvm-svn: 97926
2010-03-08 00:41:19 +00:00
Douglas Gregor 254bba4095 Downgrade errors when trying to catch a pointer or reference to
incomplete type to warnings; GCC (and EDG in GCC compatibility mode)
permit such handles. Fixes PR6527.

llvm-svn: 97925
2010-03-07 23:28:27 +00:00
Douglas Gregor c934bc840c Perform overload resolution when static_cast'ing from a
pointer-to-member-to-derived to a pointer-to-member-to-base. Fixes
PR6072.

llvm-svn: 97923
2010-03-07 23:24:59 +00:00
Douglas Gregor 1ce52caf0d Reference binding via user-defined conversion can compute a binding
that is not reference-related (because it requires another implicit
conversion to which we can find). Fixes PR6483.

llvm-svn: 97922
2010-03-07 23:17:44 +00:00
Douglas Gregor 3e637467d7 Implement name hiding for names found through virtual base subobjects
that are hidden by other derived base subobjects reached along a
lookup path that does *not* pass through the hiding subobject (C++
[class.member.lookup]p6). Fixes PR6462.

llvm-svn: 97640
2010-03-03 04:38:46 +00:00
Rafael Espindola 70e040d552 During codegen assert that any copy assignment, destructor or constructor that
we need to synthesize has been marked as used by Sema.

Change Sema to avoid these asserts.

llvm-svn: 97589
2010-03-02 21:28:26 +00:00
Douglas Gregor 63d08ddda6 Add test case from PR6064, which now works
llvm-svn: 97575
2010-03-02 18:48:07 +00:00
Douglas Gregor 1d85d2903b Fix an amusing typo that completely the re-introduction of parameters
for the purposes of parsing default arguments. In effect, we would
re-introduce the parameter with a default argument N times (where N is
the number of parameters preceding the parameter with a default
argument). This showed up when a defaulted parameter of a member
function of a local class shadowed a parameter of the enclosing
function. Fixes PR6383.

llvm-svn: 97534
2010-03-02 01:29:43 +00:00
Douglas Gregor 9a28e84b32 Keep an explicit stack of function and block scopes, each element of
which has the label map, switch statement stack, etc. Previously, we
had a single set of maps in Sema (for the function) along with a stack
of block scopes. However, this lead to funky behavior with nested
functions, e.g., in the member functions of local classes.

The explicit-stack approach is far cleaner, and we retain a 1-element
cache so that we're not malloc/free'ing every time we enter a
function. Fixes PR6382.

Also, tweaked the unused-variable warning suppression logic to look at
errors within a given Scope rather than within a given function. The
prior code wasn't looking at the right number-of-errors count when
dealing with blocks, since the block's count would be deallocated
before we got to ActOnPopScope. This approach works with nested
blocks/functions, and gives tighter error recovery.

llvm-svn: 97518
2010-03-01 23:15:13 +00:00
Chris Lattner 30d0cfda35 Implement jump checking for initialized c++ variables, implementing
a fixme and PR6451.

Only perform jump checking if the containing function has no errors,
and add the infrastructure needed to do this.

On the testcase in the PR, we produce:

t.cc:6:3: error: illegal goto into protected scope
  goto later;
  ^
t.cc:7:5: note: jump bypasses variable initialization
  X x;
    ^

llvm-svn: 97497
2010-03-01 20:59:53 +00:00
Douglas Gregor e489a7d3d3 Warn about the deprecated string literal -> char* conversion. Fixes PR6428.
llvm-svn: 97404
2010-02-28 18:30:25 +00:00
John McCall 1f476a1783 Fix an assertion-on-error during tentative constructor parsing by
propagating error conditions out of the various annotate-me-a-snowflake
routines.  Generally (but not universally) removes redundant diagnostics
as well as, you know, not crashing on bad code.  On the other hand,
I have just signed myself up to fix fiddly parser errors for the next
week.  Again.

llvm-svn: 97221
2010-02-26 08:45:28 +00:00
Douglas Gregor 6f5f642ca2 When computing the composite pointer type for relational comparisons,
equality comparisons, and conditional operators, produce a composite
pointer type with the appropriate additional "const" qualifiers if the
pointer types would otherwise be incompatible. This is a small
extension (also present in GCC and EDG in a slightly different form)
that permits code like:

  void** i; void const** j; 
  i == j; 

with the following extwarn:

t.cpp:5:5: warning: comparison of distinct pointer types ('void **' and
      'void const **') uses non-standard composite pointer type
      'void const *const *' [-pedantic]
  i == j; 
  ~ ^  ~

Fixes PR6346, and I'll be filing a core issue about this with the C++
committee.

llvm-svn: 97177
2010-02-25 22:29:57 +00:00
Douglas Gregor 83af86a6bc Allow us to compare derived-to-base conversions between a reference
binding and a copy-construction. Fixes an overloading problem in the
Clang-on-Clang build.

llvm-svn: 97161
2010-02-25 19:01:05 +00:00
Douglas Gregor 422f155ca3 Don't try to finalize an ill-formed variable or one whose class type is ill-formed. Fixes PR6421
llvm-svn: 97152
2010-02-25 18:11:54 +00:00
John McCall 21b57fa4e5 When comparing two method overload candidates during overload diagnostics,
skip the object argument conversion if either of the candidates didn't
initialize it.

Fixes PR6421, which is such a very straightforward extension of PR6398 that I
should have worked it into the last test case (and therefore caught it then).
Ah well.

llvm-svn: 97135
2010-02-25 10:46:05 +00:00
Chandler Carruth 8fa1e7eec4 Add a new conversion rank to classify conversions between complex and scalar
types. Rank these conversions below other conversions. This allows overload
resolution when the only distinction is between a complex and scalar type. It
also brings the complex overload resolutin in line with GCC's.

llvm-svn: 97128
2010-02-25 07:20:54 +00:00
John McCall 65eb879d22 Catch more uses of uninitialized implicit conversion sequences.
When diagnosing bad conversions, skip the conversion for ignored object
arguments.  Fixes PR 6398.

llvm-svn: 97090
2010-02-25 01:37:24 +00:00
Douglas Gregor 0d5b0a1e5e ActOnPseudoDestructorExpr now performs all semantic analysis for
pseudo-destructor expressions, and builds the CXXPseudoDestructorExpr
node directly. Currently, this only affects pseudo-destructor
expressions when they are parsed, but not after template
instantiation. That's coming next...

Improve parsing of pseudo-destructor-names. When parsing the
nested-name-specifier and we hit the sequence of tokens X :: ~, query
the actual module to determine whether X is a type-name (in which case
the X :: is part of the pseudo-destructor-name but not the
nested-name-specifier) or not (in which case the X :: is part of the
nested-name-specifier). 

llvm-svn: 97058
2010-02-24 21:29:12 +00:00
John McCall 6dee473780 References to const int parameters with ICE default arguments are not ICEs.
Fixes PR6373.

llvm-svn: 97037
2010-02-24 09:03:18 +00:00
Zhongxing Xu a396e617b5 Always add CallExpr as block-level expression. Inline-based interprocedural
analysis needs this.

llvm-svn: 97014
2010-02-24 02:19:28 +00:00
Rafael Espindola c18086ae17 Add support for the weakref attribute. We still produce "alias weak" as llvm-gcc does, but are more strict on what uses of weakref we accept.
llvm-svn: 96992
2010-02-23 22:00:30 +00:00
Douglas Gregor 46841e1bd9 Implement crazy destructor name lookup semantics differently in
C++98/03 and C++0x, since the '0x semantics break valid C++98/03
code. This new mess is tracked by core issue 399, which is still
unresolved.

Fixes PR6358 and PR6359.

llvm-svn: 96836
2010-02-23 00:15:22 +00:00
Chris Lattner dd1cb5b2ec Add 'previous declaration is here' note for param redefinition
errors, e.g.:

t.c:1:21: error: redefinition of parameter 'x'
int test(int x, int x);
                    ^
t.c:1:14: note: previous declaration is here
int test(int x, int x);
             ^

llvm-svn: 96769
2010-02-22 00:40:25 +00:00
Douglas Gregor 90d554ecb3 Implement support for parsing pseudo-destructor expression with a nested-name-specifier, e.g.,
typedef int Int;
  int *p;
  p->Int::~Int();

This weakens the invariant that the only types in nested-name-specifiers are tag types (restricted to class types in C++98/03). However, we weaken this invariant as little as possible, accepting arbitrary types in nested-name-specifiers only when we're in a member access expression that looks like a pseudo-destructor expression.

llvm-svn: 96743
2010-02-21 18:36:56 +00:00
Chandler Carruth 8f2548112e Commiting a revert from dgregor of a bit of destructor logic until we can
figure out how not to break lots of code using this. See PR6358 and PR6359 for
motivating examples. FIXME's left in the code and the test.

llvm-svn: 96733
2010-02-21 10:19:54 +00:00
Fariborz Jahanian ffcfecdc1f Fixed a crash specific to blocks in c++ uncovered by an internal
test suite.

llvm-svn: 96608
2010-02-18 20:31:02 +00:00
Douglas Gregor 12ea0f4ef9 For -Wswitch-enum warnings, be sure to look through typedefs of enum
types. Fixes <rdar://problem/7643909>.

llvm-svn: 96531
2010-02-17 23:29:11 +00:00