Commit Graph

1075 Commits

Author SHA1 Message Date
Eli Friedman 7127108357 Fix crash with cast of value-dependent expr.
We don't really need to perform semantic analysis on the dependent expression
anyway, so just call the cast dependent.

<rdar://problem/15012610>

llvm-svn: 190981
2013-09-19 01:12:33 +00:00
Serge Pavlov 60ac1269c6 Added regression tests.
llvm-svn: 190531
2013-09-11 17:04:24 +00:00
Reid Kleckner f978886ea4 Ignore noreturn when checking function template specializations
As requested when applying the same logic to calling conventions.

Reviewers: rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D1634

llvm-svn: 190441
2013-09-10 22:21:37 +00:00
David Majnemer 8918920a32 Sema: Subst type default template args earlier
Summary:
We would not perform substitution at an appropriate point, allowing strange
results to appear. We would accepts things that we shouldn't or mangle things incorrectly.  Note that this hasn't fixed the other cases like
template-template parameters or non-type template parameters.

Reviewers: doug.gregor, rjmccall, rsmith

Reviewed By: rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1507

llvm-svn: 189540
2013-08-28 23:48:32 +00:00
David Majnemer 8a0caa8525 Richard makes a good point, clean up this test.
llvm-svn: 189444
2013-08-28 05:45:53 +00:00
David Majnemer 3425710cca Some of this test doesn't want -std=c++11
Sorry for the churn.

llvm-svn: 189429
2013-08-28 00:13:42 +00:00
David Majnemer af8795d46d This test now needs C++11
llvm-svn: 189425
2013-08-28 00:03:12 +00:00
David Majnemer 03f4ab7531 AST: Don't treat a TemplateExpansion as a Template
Summary:
Instead of calling getAsTemplate(), call
getAsTemplateOrTemplatePattern() because it handles the
TemplateExpansion case too.

This fixes PR16997.

Reviewers: doug.gregor, rsmith

Reviewed By: rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1512

llvm-svn: 189422
2013-08-28 00:00:27 +00:00
Eli Friedman 0eaf10bc94 Fix name lookup with dependent using decls.
We previously mishandled UnresolvedUsingValueDecls in
NamedDecl::declarationReplaces, which caused us to forget decls
when there are multiple dependent using decls for the same name.

Fixes PR16936.

llvm-svn: 188737
2013-08-20 00:39:40 +00:00
Eli Friedman 2a1d9a9290 Fix for dependent contexts in alias templates.
When we are parsing a type for an alias template, we are not entering
the context, so we can't look into dependent classes.  Make sure the
parser handles this correctly.

PR16904.

llvm-svn: 188510
2013-08-15 23:59:20 +00:00
Eli Friedman 89fe0d5842 Properly track l-paren of a CXXFucntionalCastExpr.
In addition to storing more useful information in the AST, this
fixes a semantic check in template instantiation which checks whether
the l-paren location is valid.

Fixes PR16903.

llvm-svn: 188495
2013-08-15 22:02:56 +00:00
Eli Friedman 4e28b26589 sizeof(void) etc. should be a hard error in C++.
PR16872.

llvm-svn: 188324
2013-08-13 22:26:42 +00:00
Serge Pavlov 074a518f03 Fix to PR16225 (Assert-on-invalid: isa<LabelDecl>(D) && "declaration not instantiated in this scope")
Differential Revision: http://llvm-reviews.chandlerc.com/D920

llvm-svn: 188137
2013-08-10 12:00:21 +00:00
Eli Friedman 8564139c0e Correctly profile CXXPseudoDestructorExprs.
CXXPseudoDestructorExprs may not contain a type.  PR16852.

llvm-svn: 188123
2013-08-09 23:37:05 +00:00
Larisse Voufo 39a1e507ff Started implementing variable templates. Top level declarations should be fully supported, up to some limitations documented as FIXMEs or TODO. Static data member templates work very partially. Static data member templates of class templates need particular attention...
llvm-svn: 187762
2013-08-06 01:03:05 +00:00
Reid Kleckner a09e44c75d Fix declaring class template methods with an attributed typedef
This change unifies the logic for template instantiation of methods and
functions declared with typedefs.

It ensures that SubstFunctionType() always fills the Params out param
with non-null ParmVarDecls or returns null.

Reviewers: rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D1135

llvm-svn: 187528
2013-07-31 21:00:18 +00:00
Richard Smith ccf0151b71 Add testcase for PR16134, which no longer crashes with ToT.
llvm-svn: 186849
2013-07-22 18:09:32 +00:00
Richard Smith 35828f1db6 PR16288: A template is only missing a default template argument if it provides
any default template arguments, not if it inherits some.

llvm-svn: 186804
2013-07-22 03:31:14 +00:00
Larisse Voufo 98b20f1278 FIXME fix: improving diagnostics for template arguments deduction of class templates and explicit specializations
This patch essentially removes all the FIXMEs following calls to DeduceTemplateArguments() that want to keep track of deduction failure info.

llvm-svn: 186730
2013-07-19 23:00:19 +00:00
Larisse Voufo 47c0845e0b Revert "Use function overloading instead of template specialization for diagnosis of bad template argument deductions."
This reverts commit a730f548325756d050d4caaa28fcbffdae8dfe95.

llvm-svn: 186729
2013-07-19 22:53:23 +00:00
Eli Friedman fa163749c7 Fix pack instantiation with function types.
Make sure we correctly expand packs which expand to another
pack in a function type.

llvm-svn: 186728
2013-07-19 22:50:29 +00:00
Larisse Voufo 8d33da6d58 Use function overloading instead of template specialization for diagnosis of bad template argument deductions.
llvm-svn: 186727
2013-07-19 22:34:32 +00:00
Reid Kleckner 673d81b8c7 Use an i686 triple for this test now that it uses stdcall
There seems to be a crash here if we have a calling convention attribute
that gets ignored and then we instantiate templates.

llvm-svn: 186719
2013-07-19 20:32:18 +00:00
Reid Kleckner 569b8f83a4 Create calling convention AttributedType sugar nodes
Canonical types are unchanged.  The type printer had to be changed to
avoid printing any non-default implicit calling convention as well as
the calling convention attribute.

Reviewers: rjmccall

Differential Revision: http://llvm-reviews.chandlerc.com/D1132

llvm-svn: 186714
2013-07-19 19:51:03 +00:00
Eli Friedman 8917ad5d1f Fix for template substitution with packs.
When we see a pack, and replace it with a template argument which is
also a pack, we want to use the pack pattern, not the expanded pack.
The caller should take care of expanding the pack afterwards.

Fixes PR16646.

llvm-svn: 186713
2013-07-19 19:40:38 +00:00
David Majnemer ea5092a3b0 Sema: Do not merge new decls with invalid, old decls
Sema::MergeFunctionDecl attempts merging two decls even if the old decl
is invalid.  This can lead to interesting circumstances where we
successfully merge the decls but the result makes no sense.

Take the following for example:

template <typename T>
int main(void);

int main(void);

Sema will not consider these to be overloads of the same name because
main can't be overloaded, which means that this must be a redeclaration.

In this case the templated decl is compatible with the non-templated
decl allowing the Sema::CheckFunctionDeclaration machinery to move on
and do bizarre things like setting the previous decl of a non-templated
decl to a templated decl!

The way I see it, we should just bail from MergeFunctionDecl if the old
decl is invalid.

This fixes PR16531.

llvm-svn: 185779
2013-07-07 23:49:50 +00:00
Rafael Espindola 925213b0fa Add 'not' to commands that are expected to fail.
This is at least good documentation, but also opens the possibility of
using pipefail.

llvm-svn: 185652
2013-07-04 16:16:58 +00:00
Richard Smith c87b938e17 Part of PR15673: If a function template has a default argument in which
substitution failed, report that as a substitution failure rather than
pretending that there was no default argument.

The test cases in PR15673 have exposed some pre-existing poor diagnostics here.

llvm-svn: 185604
2013-07-04 01:01:24 +00:00
Richard Smith 5001ec9190 Add regression test for PR12331.
llvm-svn: 185453
2013-07-02 18:08:50 +00:00
Argyrios Kyrtzidis ae7b38e6aa [test] Add test case for rdar://14183893.
llvm-svn: 185244
2013-06-28 23:47:22 +00:00
Eli Friedman 437313c26f Handle all TemplateArguments in trivial TypeLocs.
Armed with a much better understanding of what
TemplateSpecializationTypeLoc::initializeArgLocs actually does, I now
understand that it's fine to just use an empty TemplateArgumentLocInfo
for Integral, Declaration, and NullPtr TemplateArguments.

Fixes PR14281. (The testcases are actually derived from libcxx_test in
deduction-crash.cpp because the original testcase was impossible to reduce.)

llvm-svn: 185038
2013-06-26 23:30:50 +00:00
Matt Beaumont-Gay 76d0b46dd1 Propagate the invalid bit from bases to derived template classes.
Fixes PR16292.

llvm-svn: 184581
2013-06-21 18:58:32 +00:00
Eli Friedman 65615d4017 Add test.
llvm-svn: 184465
2013-06-20 20:56:57 +00:00
Eli Friedman f8cab73e99 One more cast test.
llvm-svn: 184393
2013-06-20 01:47:05 +00:00
Richard Smith f24e6e747b Fix some confusing diagnostic wording. s/implicit default/implicit/ if we're
not actually talking about a default constructor.

llvm-svn: 183885
2013-06-13 03:34:55 +00:00
Richard Smith 0603bbb53c Don't suggest putting 'operator new' or 'operator delete' in a namespace to fix a two-phase lookup issue. That's not permitted.
llvm-svn: 183874
2013-06-12 22:56:54 +00:00
David Majnemer 66ad574f40 Implement DR61: Address of ambiguous bound methods should be disallowed
DR61 affirms that expressions containing unresolved member access should
be disallowed when performing "address of" operations.

llvm-svn: 183723
2013-06-11 03:56:29 +00:00
David Majnemer 55890bfaa6 Implement DR85: Redeclaration of member is forbidden
Disallow the existence of a declaration of a member class that isn't a
forward declaration before it's definition.

llvm-svn: 183722
2013-06-11 03:51:23 +00:00
Faisal Vali 475671057c Fix the parser's updating of the template depth when parsing local templates and late-parsed templates.
This is a slight tweak of r180708; It avoids incrementing depth when non-template local classes nested within member templates of local classes are encountered.  
This patch was LGTM'd by Doug http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130506/079656.html and passed the regression tests that normally pass (i.e. excluding many Module and Index tests on Windows that fail regardless)

llvm-svn: 183620
2013-06-08 19:47:52 +00:00
Faisal Vali 6a79ca1c6d Revert r183618.
I ran clang-format on my patch but it seemed to have wreaked havoc with new lines  - might have to do with using it on windows :( will resubmit once i've cleaned this issue up. sorry.

llvm-svn: 183619
2013-06-08 19:39:00 +00:00
Faisal Vali 9b629831a7 Fix the parser's updating of the template depth when parsing local templates and late-parsed templates. This is a slight tweak of r180708; It avoids incrementing depth when non-template local classes nested within member templates of local classes are encountered.
This patch was LGTM'd by Doug http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130506/079656.html and passed the regression tests that normally pass (i.e. excluding many Module and Index tests on Windows that fail regardless)

llvm-svn: 183618
2013-06-08 19:33:09 +00:00
Anna Zaks 148974d678 [analyzer] Fix a crash that occurs when processing an rvalue array.
When processing ArrayToPointerDecay, we expect the array to be a location, not a LazyCompoundVal.
Special case the rvalue arrays by using a location to represent them. This case is handled similarly
elsewhere in the code.

Fixes PR16206.

llvm-svn: 183359
2013-06-06 00:19:36 +00:00
David Blaikie 6df859d859 Bound member function diagnostic - suggest no-args calls and note overload candidates
Still missing cases for templates, but this is a step in the right
direction. Also omits suggestions that would be ambiguous (eg: void
func(int = 0); + void func(float = 0); func;)

llvm-svn: 183173
2013-06-04 00:28:46 +00:00
Richard Smith eebe125f77 Fix crash-on-invalid: only use TransformAddressOfOperand when transforming the
operand of a unary address-of expression, not for *all* expressions!

llvm-svn: 182436
2013-05-21 23:29:46 +00:00
Richard Trieu b48e62fb45 Check a pointer is not null before attempting to use it. This prevents a
crash on an explicit specialization of a member function in a class scope.

llvm-svn: 181971
2013-05-16 02:14:08 +00:00
Douglas Gregor b4eadc34e1 <rdar://problem/13806270> A template argument list is a constant-evaluated context.
llvm-svn: 181076
2013-05-03 23:44:54 +00:00
Douglas Gregor d2472d4cdb Use attribute argument information to determine when to parse attribute arguments as expressions.
This change partly addresses a heinous problem we have with the
parsing of attribute arguments that are a lone identifier. Previously,
we would end up parsing the 'align' attribute of this as an expression
"(Align)":

 template<unsigned Size, unsigned Align>
 class my_aligned_storage
 {
   __attribute__((align((Align)))) char storage[Size];
 };

while this would parse as a "parameter name" 'Align':

 template<unsigned Size, unsigned Align>
 class my_aligned_storage
 {
   __attribute__((align(Align))) char storage[Size];
 };

The code that handles the alignment attribute would completely ignore
the parameter name, so the while the first of these would do what's
expected, the second would silently be equivalent to

 template<unsigned Size, unsigned Align>
 class my_aligned_storage
 {
   __attribute__((align)) char storage[Size];
 };

i.e., use the maximal alignment rather than the specified alignment.

Address this by sniffing the "Args" provided in the TableGen
description of attributes. If the first argument is "obviously"
something that should be treated as an expression (rather than an
identifier to be matched later), parse it as an expression.

Fixes <rdar://problem/13700933>.

llvm-svn: 180973
2013-05-02 23:25:32 +00:00
Douglas Gregor 33ebfe36e5 Revert r180970; it's causing breakage.
llvm-svn: 180972
2013-05-02 23:15:45 +00:00
Douglas Gregor 44dff3f2dc Use attribute argument information to determine when to parse attribute arguments as expressions.
This change partly addresses a heinous problem we have with the
parsing of attribute arguments that are a lone identifier. Previously,
we would end up parsing the 'align' attribute of this as an expression
"(Align)":

  template<unsigned Size, unsigned Align>
  class my_aligned_storage
  {
    __attribute__((align((Align)))) char storage[Size];
  };

while this would parse as a "parameter name" 'Align':

  template<unsigned Size, unsigned Align>
  class my_aligned_storage
  {
    __attribute__((align(Align))) char storage[Size];
  };

The code that handles the alignment attribute would completely ignore
the parameter name, so the while the first of these would do what's
expected, the second would silently be equivalent to

  template<unsigned Size, unsigned Align>
  class my_aligned_storage
  {
    __attribute__((align)) char storage[Size];
  };

i.e., use the maximal alignment rather than the specified alignment.

Address this by sniffing the "Args" provided in the TableGen
description of attributes. If the first argument is "obviously"
something that should be treated as an expression (rather than an
identifier to be matched later), parse it as an expression.

Fixes <rdar://problem/13700933>.

llvm-svn: 180970
2013-05-02 23:08:12 +00:00
Richard Smith 27d807cc9c Don't treat a non-deduced 'auto' type as being type-dependent. Instead, there
are now two distinct canonical 'AutoType's: one is the undeduced 'auto'
placeholder type, and the other is a deduced-but-dependent type. All
deduced-to-a-non-dependent-type cases are still non-canonical.

llvm-svn: 180789
2013-04-30 13:56:41 +00:00
Richard Smith c8378952fb Keep the parser's template depth up to date when parsing local templates and
late-parsed templates. Patch by Faisal Vali!

llvm-svn: 180708
2013-04-29 11:55:38 +00:00
Richard Smith 07cea1911a Properly reenter multiple contexts when parsing a late-parsed function template
within a dependent context. Patch by Will Wilson (+clang-format)!

llvm-svn: 180702
2013-04-29 08:53:40 +00:00
Richard Smith a3519fa347 Fix an assertion failure / accepts-invalid in -fms-extensions mode. Don't build
a dependent-scope id expression when a templated member function of a
non-templated class references an unknown identifier, since instantiation won't
rebuild it (and we can tell at parse time that it'll never work). Based on a
patch by Faisal Vali!

llvm-svn: 180701
2013-04-29 08:45:27 +00:00
Jyotsna Verma ef35f3a682 Removing example-dynarray.cpp test since it's of no value.
llvm-svn: 180208
2013-04-24 18:44:44 +00:00
Richard Trieu e373235c7c Fix PR15634, better error message for template deduction failure.
When two template decls with the same name are used in this diagnostic,
force them to print their qualified names.  This changes the bad message of:

candidate template ignored: could not match 'array' against 'array'

to the better message of:

candidate template ignored: could not match 'NS2::array' against 'NS1::array'

llvm-svn: 179056
2013-04-08 21:11:40 +00:00
Jyotsna Verma abb1ed6952 XFAIL example-dynarray.cpp test for Hexagon as some of the header files
are unavailable on Hexagon.

llvm-svn: 178791
2013-04-04 20:56:42 +00:00
Richard Smith 89b466c603 Fold together the two implementations of 6.7.3p2 in SemaType. Fix two bugs, each of which was only present in one version:
* Give the right diagnostic for 'restrict' applied to a non-pointer, non-reference type.
 * Don't reject 'restrict' applied indirectly to an Objective-C object pointer type (eg, through template instantiation).

llvm-svn: 178200
2013-03-28 00:03:10 +00:00
Richard Smith deec07403c Don't reject __restrict applied to a dependent type; it might instantiate to a pointer or reference type.
llvm-svn: 178198
2013-03-27 23:36:39 +00:00
Douglas Gregor 45bb4834e9 <rdar://problem/13267210> Ensure that Sema::CompareReferenceRelationship returns consistent results with invalid types.
When Sema::RequireCompleteType() is given a class template
specialization type that then fails to instantiate, it returns
'true'. On subsequent invocations, it can return false. Make sure that
this difference doesn't change the result of
Sema::CompareReferenceRelationship, which is expected to remain stable
while we're checking an initialization sequence.

llvm-svn: 178088
2013-03-26 23:36:30 +00:00
John McCall e68672fed2 Flag that friend function definitions are "late parsed" so that
template instantiation will still consider them to be definitions
if we instantiate the containing class before we get around
to parsing the friend.

This seems like a legitimate use of "late template parsed" to me,
but I'd appreciate it if someone responsible for the MS feature
would look over this.

This file already appears to access AST nodes directly, which
is arguably not kosher in the parser, but the performance of this
path matters enough that perpetuating the sin is justifiable.
Probably we ought to reconsider this policy for very simple
manipulations like this.

The reason this entire thing is necessary is that
function template instantiation plays some very gross games
in order to not associate an instantiated function template
with the class it came from unless it's a definition, and
the reason *that's* necessary is that the AST currently
cannot represent the instantiation history of individual
function template declarations, but instead tracks it in
common for the entire function template.  That probably
prevents us from correctly reporting ill-formed calls to
ambiguously instantiated friend function templates.

rdar://12350696

llvm-svn: 177003
2013-03-14 05:13:41 +00:00
Douglas Gregor d831d955f6 <rdar://problem/13094134> Don't try to wire up typedef names for invalid anonymous tag declarations encountered during template instantiation.
llvm-svn: 176727
2013-03-08 22:15:15 +00:00
Douglas Gregor a88c55b571 <rdar://problem/13140795> Transform the scope type of a pseudo-destructor expression within the object scope.
We were transforming the scope type of a pseudo-destructor expression
(e.g., the first T in x->T::~T()) as a freestanding type, which meant
that dependent template specialization types here would stay dependent
even when no template parameters were named. This would eventually
mean that a dependent expression would end up in what should be
fully-instantiated ASTs, causing IRgen to assert.

llvm-svn: 176723
2013-03-08 21:25:01 +00:00
David Blaikie e750491ff3 Add quotation marks to template names in diagnostics.
llvm-svn: 176474
2013-03-05 06:21:38 +00:00
David Blaikie dc601e3a09 PR15360: nullptr as a non-type template argument to a function type non-type template parameter
llvm-svn: 176216
2013-02-27 22:10:40 +00:00
David Blaikie a985542ae0 Add test coverage for array to pointer decay in non-type template parameters.
Functionality committed in r172585 but tested the function case without the
array case.

llvm-svn: 176215
2013-02-27 22:10:37 +00:00
Richard Smith 44c247f0f0 Handle alignas(foo...) pack expansions.
llvm-svn: 175875
2013-02-22 08:32:16 +00:00
Richard Smith c084bd2888 PR15132: Replace "address expression must be an lvalue or a function
designator" diagnostic with more correct and more human-friendly "cannot take
address of rvalue of type 'T'".

For the case of & &T::f, provide a custom diagnostic, rather than unhelpfully
saying "cannot take address of rvalue of type '<overloaded function type>'".

For the case of &array_temporary, treat it just like a class temporary
(including allowing it as an extension); the existing diagnostic wording
for the class temporary case works fine.

llvm-svn: 174262
2013-02-02 02:14:45 +00:00
Richard Smith 44ecdbdc61 Improve 'failed template argument deduction' diagnostic for the case where we
have a direct mismatch between some component of the template and some
component of the argument. The diagnostic now says what the mismatch was, but
doesn't yet say which part of the template doesn't match.

llvm-svn: 174039
2013-01-31 05:19:49 +00:00
Douglas Gregor effe2a1e75 Apply adjustment to function- and array-typed non-type template
parameters (per C++ [temp.param]p8) when computing the type of a
reference to a non-type template parameter. Fixes <rdar://problem/13000548>.

llvm-svn: 172585
2013-01-16 00:52:15 +00:00
Richard Smith 21bae43fab PR14695: Fix assert from bad cast<>. Not every namespace is a NamespaceDecl; it might instead be a TranslationUnitDecl.
llvm-svn: 170976
2012-12-22 02:46:14 +00:00
Richard Smith 38a549bc42 Fix regression in r170489: when instantiating a direct initializer which is a
CXXScalarValueInitExpr (or an ImplicitValueInitExpr), strip it back down to an
empty pair of parentheses so that the initialization code can tell that we're
performing value-initialization.

llvm-svn: 170867
2012-12-21 08:13:35 +00:00
Alexander Kornienko 90ff607894 Implement AST dumper for Decls.
http://llvm-reviews.chandlerc.com/D52

Patch by Philip Craig!

llvm-svn: 170634
2012-12-20 02:09:13 +00:00
Richard Smith 4efa77fde4 Attempt to clarify a vexing-parse diagnostic.
llvm-svn: 170492
2012-12-19 03:15:32 +00:00
Richard Smith 503053a737 Fix assertion failure in self-host (and probably bogus template instantiation
too). When instantiating a direct-initializer, if we find it has zero
arguments, produce an empty ParenListExpr rather than returning a null
expression.

llvm-svn: 170490
2012-12-19 02:27:38 +00:00
Eli Friedman 07bab73c7f Using CanQualType::getAs<ArrayType> is unsafe; fix the code currently using it,
and make sure additional uses don't get introduced.  <rdar://problem/12858424>.

llvm-svn: 170081
2012-12-13 01:43:21 +00:00
Richard Smith 58db83d11d PR13098: If we're instantiating an overloaded binary operator and we could
determine which member function would be the callee from within the template
definition, don't pass that function as a "non-member function" to
CreateOverloadedBinOp. Instead, just rely on it to select the member function
for itself.

llvm-svn: 168818
2012-11-28 21:47:39 +00:00
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
Richard Smith 4f6a2c4acb When we have a MemberExpr referring to an overloaded static member function,
and we resolve it to a specific function based on the type which it's used as,
don't forget to mark it as referenced.

Fixes a regression introduced in r167514.

llvm-svn: 167918
2012-11-14 07:06:31 +00:00
Nick Lewycky a21719d688 When filtering the list of associated namespaces so that we don't suggest people
add functions to namespace 'std', also filter out namespaces with '__' anywhere
in the name.

llvm-svn: 167786
2012-11-13 00:08:34 +00:00
Douglas Gregor dc97457178 Rework my implementation of circular-reference finding to not use
CXXRecordDecl::forallBases, which does *not* do what I need. Fixes the
failure introduced in r167651.

llvm-svn: 167668
2012-11-10 07:24:09 +00:00
Douglas Gregor 6200470112 Diagnostic circular inheritance involving dependent base classes. We
would have diagnosed this at instantiation time anyway, if only we
didn't hang on all of these test cases. Fixes <rdar://problem/12629723>

llvm-svn: 167651
2012-11-10 01:18:17 +00:00
Richard Smith de63d36fb2 PR13788: Don't perform checks on the initializer of a dependently-typed
variable. Previously we didn't notice the type was dependent if the only
dependence came from an array bound.

Patch by Brian Brooks!

llvm-svn: 167642
2012-11-09 23:03:14 +00:00
Richard Trieu 23bafad985 When template deduction fails on a derived class, try a template deduction on
the base class.  If the base class deduction succeeds, use those results.  If
it fails, keep using the results from the derived class template deduction.

This prevents an assertion later where the type of deduction failure doesn't
match up with the template deduction info.

llvm-svn: 167550
2012-11-07 21:17:13 +00:00
Richard Smith e10d304d20 PR11851 (and duplicates): Whenever a constexpr function is referenced,
instantiate it if it can be instantiated and implicitly define it if it can be
implicitly defined. This matches g++'s approach. Remove some cases from
SemaOverload which were marking functions as referenced when just planning how
overload resolution would proceed; such cases are not actually references.

llvm-svn: 167514
2012-11-07 01:14:25 +00:00
Eli Friedman c087c3f6c5 Add missing check to warning for packed attribute. PR14259.
llvm-svn: 167510
2012-11-07 00:35:20 +00:00
Richard Smith 40c180db13 When rebuilding a DependentScopeDeclRefExpr, perform a lookup into the scope
even if it's dependent, in case it now names a member of the current instantiation.

llvm-svn: 166496
2012-10-23 19:56:01 +00:00
Richard Smith db2630fb04 Unrevert r166268, reverted in r166272, with a fix for the issue which Nick
found: if an overloaded operator& is present before a template definition,
the expression &T::foo is represented as a CXXOperatorCallExpr, not as a
UnaryOperator, so we didn't notice that it's permitted to reference a non-static
data member of an unrelated class.

While investigating this, I discovered another problem in this area: we are
treating template default arguments as unevaluated contexts during substitution,
resulting in performing incorrect checks for uses of non-static data members in
C++11. That is not fixed by this patch (I'll look into this soon; it's related
to the failure to correctly instantiate constexpr function templates), but was
resulting in this bug not firing in C++11 mode (except with -Wc++98-compat).

Original message:

PR14124: When performing template instantiation of a qualified-id outside of a
class, diagnose if the qualified-id instantiates to a non-static class member.

llvm-svn: 166385
2012-10-21 03:28:35 +00:00
Andy Gibbs c6e68daac0 Prior to adding the new "expected-no-diagnostics" directive to VerifyDiagnosticConsumer, make the necessary adjustment to 580 test-cases which will henceforth require this new directive.
llvm-svn: 166280
2012-10-19 12:44:48 +00:00
Nick Lewycky 2e3b716959 Revert r166268, this fix for a crash-on-invalid introduced a rejects-valid.
Richard has an unreduced testcase to work with.

llvm-svn: 166272
2012-10-19 08:08:02 +00:00
Richard Smith b2d6df5c95 PR14124: When performing template instantiation of a qualified-id outside of a
class, diagnose if the qualified-id instantiates to a non-static class member.

llvm-svn: 166268
2012-10-19 06:32:17 +00:00
Eli Friedman c681e5f608 Fix a regression from r164656.
llvm-svn: 164804
2012-09-27 22:13:33 +00:00
Richard Smith 60f2e1efb8 Don't produce diagnostics for missing ctor-initializers during template
instantiations if we encountered errors parsing some of the initializers.

llvm-svn: 164578
2012-09-25 00:23:05 +00:00
Richard Smith 6d12af7410 Fix bug which sometimes resulted in further diagnostics being produced after a
fatal error. Previously, if a fatal error was followed by a diagnostic which
was suppressed due to a SFINAETrap, we'd forget that we'd seen a fatal error.

llvm-svn: 164437
2012-09-22 00:53:56 +00:00
Douglas Gregor c5c01a60c2 Don't perform template argument deduction against invalid templates;
it's likely to lead to a crash later on. Fixes PR12933 /
<rdar://problem/11525335>.

llvm-svn: 163838
2012-09-13 21:01:57 +00:00
Richard Smith 09b031fbc0 Don't try to check override control for invalid member functions. Fixes a crash in a corner case. Patch by Olivier Goffart!
llvm-svn: 163337
2012-09-06 18:32:18 +00:00
Nico Weber 723b4f02a7 Reland r160052: Default to -std=c++11 on Windows.
Also update the tests that rely on c++98 to explicitly mention that.

llvm-svn: 162890
2012-08-30 02:08:31 +00:00
Richard Smith 4f605aff7f PR41111, PR5925, PR13210: Teach tentative parsing to annotate identifiers and
nested names as id-expressions, using the annot_primary_expr annotation, where
possible. This removes some redundant lookups, and also allows us to
typo-correct within tentative parsing, and to carry on disambiguating past an
identifier which we can determine will fail lookup as both a type and as a
non-type, allowing us to disambiguate more declarations (and thus offer
improved error recovery for such cases).

This also introduces to the parser the notion of a tentatively-declared name,
which is an identifier which we *might* have seen a declaration for in a
tentative parse (but only if we end up disambiguating the tokens as a
declaration). This is necessary to correctly disambiguate cases where a
variable is used within its own initializer.

llvm-svn: 162159
2012-08-18 00:55:03 +00:00
David Blaikie 1c7c8f7637 Implement warning for integral null pointer constants other than the literal 0.
This is effectively a warning for code that violates core issue 903 & thus will
become standard error in the future, hopefully. It catches strange null
pointers such as: '\0', 1 - 1, const int null = 0; etc...

There's currently a flaw in this warning (& the warning for 'false' as a null
pointer literal as well) where it doesn't trigger on comparisons (ptr == '\0'
for example). Fix to come in a future patch.

Also, due to this only being a warning, not an error, it triggers quite
frequently on gtest code which tests expressions for null-pointer-ness in a
SFINAE context (so it wouldn't be a problem if this was an error as in an
actual implementation of core issue 903). To workaround this for now, the
diagnostic does not fire in unevaluated contexts.

Review by Sean Silva and Richard Smith.

llvm-svn: 161501
2012-08-08 17:33:31 +00:00
Richard Smith 943c440455 Improvements to vexing-parse warnings. Make the no-parameters case more
accurate by asking the parser whether there was an ambiguity rather than trying
to reverse-engineer it from the DeclSpec. Make the with-parameters case have
better diagnostics by using semantic information to drive the warning,
improving the diagnostics and adding a fixit.

Patch by Nikola Smiljanic. Some minor changes by me to suppress diagnostics for
declarations of the form 'T (*x)(...)', which seem to have a very high false
positive rate, and to reduce indentation in 'warnAboutAmbiguousFunction'.

llvm-svn: 160998
2012-07-30 21:30:52 +00:00