John McCall [Sat, 27 Mar 2010 00:47:27 +0000 (00:47 +0000)]
When mapping restrict to noalias, look for 'restrict' on the parameter variable
instead of the canonical parameter type (which has correctly dropped all such
direct qualifiers). Fixes PR6695.
Douglas Gregor [Fri, 26 Mar 2010 22:43:07 +0000 (22:43 +0000)]
When adding initializers to a constructor, be sure that we are looking
through the bases and fields of the definition of the class in which
the constructor is declared, rather than some other declaration of
that class.
Daniel Dunbar [Fri, 26 Mar 2010 22:41:03 +0000 (22:41 +0000)]
Driver/Darwin: Support CCC_ENABLE_NEW_DARWIN_TOOLCHAIN as an environment
override to enable use of the DarwinClang tool chain on all platforms (not just
ARM).
John McCall [Fri, 26 Mar 2010 21:56:38 +0000 (21:56 +0000)]
Properly account for redeclarations when explicitly instantiating class templates.
What happens here is that we actually turn the first declaration into a
definition, regardless of whether it was actually originally a definition,
and furthermore we do this all after we've instantiated all the declarations.
This exposes a bug in my DefinitionData patch where it was only setting the
DefinitionData for previous declarations, not future declarations.
Fortunately, there's an iterator for that.
Douglas Gregor [Fri, 26 Mar 2010 20:59:55 +0000 (20:59 +0000)]
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.
Douglas Gregor [Fri, 26 Mar 2010 20:35:59 +0000 (20:35 +0000)]
Eliminate the non-InitializedEntity PerformCopyInitialization() and
re-route its only caller to the newer
PerformCopyInitialization(). We're down to one remaining caller of
Sema::CheckReferenceInit.
Douglas Gregor [Fri, 26 Mar 2010 05:50:28 +0000 (05:50 +0000)]
When deducing an integral template argument for a non-type template
parameter, keep the integral value exactly as it was in the source
code rather than trying to convert it to the type of the non-type
template parameter (which may still be dependent!). The value will
then be converted to the appropriate type once we check the resulting
template arguments. Fixes PR6707.
Douglas Gregor [Fri, 26 Mar 2010 02:38:37 +0000 (02:38 +0000)]
Reinstate change to non-type template arguments of integral type, so
that we extend/truncate then correct the sign to convert the non-type
template argument to the template parameter's type. Previously, we
reported an error when the non-type template argument was out of
range; now we just warn.
Douglas Gregor [Thu, 25 Mar 2010 22:21:04 +0000 (22:21 +0000)]
Warn when the conversion of an integral non-type template argument to
the type of its corresponding non-type template parameter changes the
value. Previously, we were diagnosing this as an error, which was
wrong. We give reasonably nice warnings like:
test/SemaTemplate/temp_arg_nontype.cpp:100:10: warning: non-type template
argument value '256' truncated to '0' for template parameter of type
'unsigned char'
Overflow<256> *overflow3; // expected-warning{{non-type template ...
^~~
test/SemaTemplate/temp_arg_nontype.cpp:96:24: note: template parameter is
declared here
template<unsigned char C> struct Overflow;
^
Douglas Gregor [Thu, 25 Mar 2010 22:17:48 +0000 (22:17 +0000)]
Teach the diagnostic engine to provide more detailed information about
how to handle a diagnostic during template argument deduction, which
may be "substitution failure", "suppress", or "report". This keeps us
from, e.g., emitting warnings while performing template argument
deduction.
John McCall [Thu, 25 Mar 2010 22:08:03 +0000 (22:08 +0000)]
When finishing a function definition, leave the function definition *after*
doing all the cleanup tasks and checks. This gives us the proper context for
checking access to base and member destructors.
John McCall [Thu, 25 Mar 2010 21:39:55 +0000 (21:39 +0000)]
Fix a very minor oversight in privileges-elevation: we were only considering
friendship for a derived class if the base class specifier was non-public,
and thus not considering friendship for non-public members of public bases.
John McCall [Thu, 25 Mar 2010 21:28:06 +0000 (21:28 +0000)]
Handle simple friend-class decls in class templates better by ensuring that
we look for shadow friend decls in the appropriate scope before injecting
a new declaration.
Daniel Dunbar [Thu, 25 Mar 2010 17:13:09 +0000 (17:13 +0000)]
Remove support for nand atomic builtins. They are inconsistently implemented in
gcc, and the common expectation seems to be that they are unused. If and when
someone cares we can add them back with well documented demantics.
Douglas Gregor [Thu, 25 Mar 2010 15:38:42 +0000 (15:38 +0000)]
Improve our handling of local instantiation scopes in two related ways:
- When substituting template arguments as part of template argument
deduction, introduce a new local instantiation scope.
- When substituting into a function prototype type, introduce a new
"temporary" local instantiation scope that merges with its outer
scope but also keeps track of any additions it makes, removing
them when we exit that scope.
Fixes PR6700, where we were getting too much mixing of local
instantiation scopes due to template argument deduction that
substituted results into function types.
Anders Carlsson [Thu, 25 Mar 2010 15:26:28 +0000 (15:26 +0000)]
When -fdump-vtable-layouts is specified, construction vtable initializers will be generated using the new vtable layout code. (The code is still not completely in place but this is a huge step forward).
John McCall [Thu, 25 Mar 2010 06:39:04 +0000 (06:39 +0000)]
Properly instantiate friend class template declarations and link them into
the redeclaration chain. Recommitted from r99477 with a fix: we need to
merge in default template arguments from previous declarations.
Bob Wilson [Thu, 25 Mar 2010 04:40:43 +0000 (04:40 +0000)]
Revert 99477 since it appears to be breaking the clang-x86_64-darwin10-fnt
buildbot. The tramp3d test fails.
--- Reverse-merging r99477 into '.':
U test/SemaTemplate/friend-template.cpp
U test/CXX/temp/temp.decls/temp.friend/p1.cpp
U lib/Sema/SemaTemplateInstantiateDecl.cpp
U lib/Sema/SemaAccess.cpp
Ted Kremenek [Thu, 25 Mar 2010 03:59:12 +0000 (03:59 +0000)]
Fix two bugs in format-string checking:
(1) Do not assume the data arguments start after the format string
(2) Do not use the fact that a function is variadic to treat it like a va_list printf function
Douglas Gregor [Thu, 25 Mar 2010 00:20:38 +0000 (00:20 +0000)]
Kill off two more uses of Sema::CheckReferenceInit in favor of the new
initialization code. Exposed a bug where we were not marking an
implicit conversion as an lvalue when we were forming a call to a
conversion function whose return type is a reference.
Douglas Gregor [Wed, 24 Mar 2010 23:38:29 +0000 (23:38 +0000)]
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.
Douglas Gregor [Wed, 24 Mar 2010 23:14:04 +0000 (23:14 +0000)]
When returning from a function that has a reference return type, use
EmitReferenceBindingToExpr() rather than assuming we have an
lvalue. This is just the lowest hanging fruit for PR6024, which still
requires a bit of work.
Rafael Espindola [Wed, 24 Mar 2010 22:43:31 +0000 (22:43 +0000)]
Discussing with dgregor we decided that we should not force the emission of
implicit methods on explicit template instantiation definitions. As a
consequence, we should emit them at every use, even if we see a explicit
template instantiation declaration.
This is already the current behaviour, but it is good to test for that :-)
Douglas Gregor [Wed, 24 Mar 2010 21:22:47 +0000 (21:22 +0000)]
When pulling apart an initializer that involves a CXXConstructExpr, do
not pick apart a CXXTemporaryObjectExpr because such an object
construction was explicitly written in the source code. Fixes PR6657.
Douglas Gregor [Wed, 24 Mar 2010 17:31:23 +0000 (17:31 +0000)]
Silently drop dependent friend function template specializations,
since we have absolutely no way to match them when they are declared
nor do we have a way to represent these parsed-but-not-checked friend
declarations.
John McCall [Wed, 24 Mar 2010 08:27:58 +0000 (08:27 +0000)]
Correct that last fixit: if the user wrote
template <> friend void foo(int);
we need to change it to
friend void foo<>(int);
or else the user won't get the template specialization they obviously want.