Commit Graph

34 Commits

Author SHA1 Message Date
Richard Smith dd2ca571ae PR14428: When instantiating a 'new' expression, if we had a non-dependent
initialization, don't rebuild it. Remove a couple of hacks which were trying to
work around this. Fix the special case for one-argument CXXConstructExprs to
not apply if the one argument is a default argument.

llvm-svn: 168582
2012-11-26 08:32:48 +00:00
Benjamin Kramer 90633e39fc Sema: Provide a valid source location when instantiating templates based on a CXXDefaultArgExpr.
Fixes PR13758.

llvm-svn: 168521
2012-11-23 17:04:52 +00:00
Eli Friedman c25372bb76 Add a missing ExpressionEvaluationContext for template default arguments. Fixes PR12581.
llvm-svn: 155670
2012-04-26 22:43:24 +00:00
Chandler Carruth a92409c3ec Enhance the diagnostic for negative array sizes to include the
declaration name of the array when present. This ensures that
a poor-man's C++03 static_assert will include the user error message
often embedded in the name.

Update all the tests to reflect the new wording, and add a test for the
name behavior.

llvm-svn: 122802
2011-01-04 04:44:35 +00:00
Douglas Gregor f0873f4c85 When marking declarations referenced within an expression (e.g.,
within a default argument), recurse into default arguments. Fixes
PR8401, a regression I introduced in r113700 while refactoring our
handling of "used" declarations in default arguments.

llvm-svn: 116817
2010-10-19 17:17:35 +00:00
Douglas Gregor 6ed2feebfc When marking the declarations in a default argument expression as
"used", at the time that the default argument itself is used, also
mark destructors that will be called by this expression. This fixes a
regression that I introduced in r113700, which broke WebKit, and fixes
<rdar://problem/8427926>.

llvm-svn: 113883
2010-09-14 22:55:20 +00:00
Douglas Gregor 32b3de519d Teach the EvaluatedExprVisitor and its client, which marks
declarations in potentially-evaluated subexpressions, about
recursion. Fixes the release-mode self-host failure I introduced in
r113700.

llvm-svn: 113708
2010-09-11 23:32:50 +00:00
Douglas Gregor 8a01b2a392 When parsing default function arguments, do not mark any declarations
used in the default function argument as "used". Instead, when we
actually use the default argument, make another pass over the
expression to mark any used declarations as "used" at that point. This
addresses two kinds of related problems:

  1) We were marking some declarations "used" that shouldn't be,
  because we were marking them too eagerly.
  2) We were failing to mark some declarations as "used" when we
  should, if the first time it was instantiated happened to be an
  unevaluated context, we wouldn't mark them again at a later point.

I've also added a potentially-handy visitor class template
EvaluatedExprVisitor, which only visits the potentially-evaluated
subexpressions of an expression. I bet this would have been useful for
noexcept...

Fixes PR5810 and PR8127.

llvm-svn: 113700
2010-09-11 20:24:53 +00:00
Douglas Gregor d984815ed9 Ensure that we have completed a type before attempting initialization
on that type. Fixes several problems in Boost.Interprocess.

llvm-svn: 102339
2010-04-26 14:36:57 +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 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
Douglas Gregor 8c702534cb Default function arguments for function template specializations
always come from the primary template, so gather the instantiation
template arguments from the primary template.

llvm-svn: 95380
2010-02-05 07:33:43 +00:00
John McCall e1ac8d1742 Improve the reporting of non-viable overload candidates by noting the reason
why the candidate is non-viable.  There's a lot we can do to improve this, but
it's a good start.  Further improvements should probably be integrated with the
bad-initialization reporting routines.

llvm-svn: 93277
2010-01-13 00:25:19 +00:00
John McCall fd0b2f8fe4 Improve the diagnostics used to report implicitly-generated class members
as parts of overload sets.  Also, refer to constructors as 'constructors'
rather than functions.

Adjust a lot of tests.

llvm-svn: 92832
2010-01-06 09:43:14 +00:00
Douglas Gregor 033f675f61 When we see a CXXDefaultArgExpr during template instantiation, rebuild
the default argument so that we're sure to mark any referenced
declarations. This gets us another little step closer to fixing
PR5810.

llvm-svn: 92078
2009-12-23 23:03:06 +00:00
Douglas Gregor 25ab25f39d When using a default function argument for a function template (or
member function thereof), perform the template instantiation each time
the default argument is needed. This ensures that
  (1) We get different CXXTemporary objects for each instantiation, and
  (2) Any other instantiations or definitions triggered by the
  instantiation of the default argument expression are guaranteed to
  happen; previously, they might have been suppressed, e.g., because
  they happened in an unevaluated context.

This fixes the majority of PR5810. However, it does not address the
problem where we may have multiple uses of the same CXXTemporary
within an expression when the temporary came from a non-instantiated
default argument expression.

llvm-svn: 92015
2009-12-23 18:19:08 +00:00
Eli Friedman 5f101b95c6 Switch default arguments over to InitializationSequence.
llvm-svn: 91883
2009-12-22 02:46:13 +00:00
Douglas Gregor a4b592a7d5 Switch more of Sema::CheckInitializerTypes over to
InitializationSequence. Specially, switch initialization of a C++
class type (either copy- or direct-initialization). 

Also, make sure that we create an elidable copy-construction when
performing copy initialization of a C++ class variable. Fixes PR5826.

llvm-svn: 91750
2009-12-19 03:01:41 +00:00
Daniel Dunbar 8fbe78f6fc Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
- This is designed to make it obvious that %clang_cc1 is a "test variable"
   which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it
   can be useful to redefine what gets run as 'clang -cc1' (for example, to set
   a default target).

llvm-svn: 91446
2009-12-15 20:14:24 +00:00
Douglas Gregor 1bc688dc60 Make sure that we instantiate default function arguments for an
overloaded operator(). 

llvm-svn: 86581
2009-11-09 19:27:57 +00:00
Sebastian Redl 14236c8e82 Special-case default argument expression in instantiation. This should fix PR4301. Doug, please double-check my assumptions. Read the PR for more details.
llvm-svn: 86465
2009-11-08 13:56:19 +00:00
Anders Carlsson 561f793890 Make sure to call CompleteConstructorCall for bases and members that are initialized implicitly in constructors so that default arguments etc are set correctly. Fixes PR5283.
llvm-svn: 85510
2009-10-29 15:46:07 +00:00
Douglas Gregor 4f15f4dec1 Merge uninstantiated default arguments more carefully, and try not to
complain about specializations of member functions that are not
definitions. Fixes PR4995.

llvm-svn: 82159
2009-09-17 19:51:30 +00:00
Douglas Gregor 64621e6eb3 Teach Sema::FindInstantiatedDecl to find instantiated RecordDecls even
when we are not instantiating the corresponding "current
instantiation." This happens, e.g., when we are instantiating a
declaration reference that refers into the "current instantiation" but
occurs in a default function argument. The libstdc++ vector default
constructor now instantiates properly.

llvm-svn: 82069
2009-09-16 18:34:49 +00:00
Douglas Gregor c732aba9a9 Cleanup and test C++ default arguments. Improvements include:
- Diagnose attempts to add default arguments to templates (or member
    functions of templates) after the initial declaration (DR217).
  - Improve diagnostics when a default argument is redefined. Now, the
    note will always point at the place where the default argument was
    previously defined, rather than pointing to the most recent
    declaration of the function.

llvm-svn: 81548
2009-09-11 18:44:32 +00:00
Anders Carlsson faf1ced5ee Reapply 81096, now with a fix. Spot the bug:
for (unsigned i = numargs; i < NumArgs; ++i)
        Args[0] = 0;

;)

llvm-svn: 81123
2009-09-06 16:54:02 +00:00
Daniel Dunbar 94bcae46d5 Revert "Initialize default CXXConstructExpr arguments to 0. Fixes a crash when
destroying the CXXConstructExpr.", this is causing test failures across the
board.

llvm-svn: 81100
2009-09-06 01:31:23 +00:00
Anders Carlsson 8284d7caa3 Initialize default CXXConstructExpr arguments to 0. Fixes a crash when destroying the CXXConstructExpr.
llvm-svn: 81096
2009-09-05 22:51:06 +00:00
Anders Carlsson dc6d2c3cda Report errors for member functions correctly.
llvm-svn: 81063
2009-09-05 05:38:54 +00:00
Anders Carlsson 657bad441e Use a separate diagnostic for default function argument expressions.
llvm-svn: 81062
2009-09-05 05:14:19 +00:00
Douglas Gregor 7315672a60 Add a little more testing for default arguments of constructors in a class template
llvm-svn: 79989
2009-08-25 15:24:38 +00:00
Anders Carlsson 114056f22c If a parameter has a default argument expression, make sure to instantiate the parameter type before checking that the expression is a valid initializer.
llvm-svn: 79986
2009-08-25 13:46:13 +00:00
Anders Carlsson 10ebe78730 Improved support for default arguments in constructors for class templates.
llvm-svn: 79984
2009-08-25 13:07:08 +00:00
Anders Carlsson 4562f1f066 Basic support for default argument expressions for function templates.
llvm-svn: 79972
2009-08-25 03:18:48 +00:00