Commit Graph

72 Commits

Author SHA1 Message Date
Richard Smith 9ca5c42582 Update all tests other than Driver/std.cpp to use -std=c++11 rather than
-std=c++0x. Patch by Ahmed Charles!

llvm-svn: 141900
2011-10-13 22:29:44 +00:00
Richard Smith fd53aaf7e7 constexpr: don't consider class types with mutable members to be literal types.
The standard doesn't allow this, but mutable constexpr variables break the
semantics so badly that we can't reasonably accept them.

llvm-svn: 141768
2011-10-12 05:08:15 +00:00
Richard Smith eb3c10c248 constexpr: semantic checking for constexpr functions and constructors. Based in
part on patches by Peter Collingbourne.

We diverge from the C++11 standard in a few areas, mostly related to checking
constexpr function declarations, and not just definitions. See WG21 paper
N3308=11-0078 for details.

Function invocation substitution is not available in this patch; constexpr
functions cannot yet be used from within constant expressions.

llvm-svn: 140926
2011-10-01 02:31:28 +00:00
NAKAMURA Takumi 9f8a02d34e De-Unicode-ify.
llvm-svn: 137430
2011-08-12 05:49:51 +00:00
Douglas Gregor de0a43f772 When performing the lookup in the current scope for a member access to
a member template, e.g.,

  x.f<int>

if we have found a template in the type of x, but the lookup in the
current scope is ambiguous, just ignore the lookup in the current
scope.  Fixes <rdar://problem/9915664>.

llvm-svn: 137255
2011-08-10 21:59:45 +00:00
Chandler Carruth 8ea21dc2af Update this test to reflect the new (deterministic) order in r134038.
This was part of Kaelyn's original patch that got dropped while I was
working on it, but after I ran my tests. =/ Sorry.

llvm-svn: 134039
2011-06-28 22:58:10 +00:00
Chad Rosier c8a215f251 Modify test case to allow buildbots to make forward progress. This test should
now (incorrectly) pass.  Once the appropriate fixes have been made this test
should be reverted.

llvm-svn: 134035
2011-06-28 22:29:53 +00:00
Douglas Gregor c2fa169d6c Add support for C++ namespace-aware typo correction, e.g., correcting
vector<int>

to

  std::vector<int>

Patch by Kaelyn Uhrain, with minor tweaks + PCH support from me. Fixes
PR5776/<rdar://problem/8652971>.

Thanks Kaelyn!

llvm-svn: 134007
2011-06-28 16:20:02 +00:00
Douglas Gregor 9574af6ea2 Teach Sema::ActOnUninitializedDecl() not to try to interpret when one
should use a constructor to default-initialize a
variable. InitializationSequence knows the rules for default
initialization, better. Fixes <rdar://problem/8501008>.

llvm-svn: 131796
2011-05-21 17:52:48 +00:00
Richard Smith dda56e4b4a Support for C++11 (non-template) alias declarations.
llvm-svn: 129567
2011-04-15 14:24:37 +00:00
Richard Smith 02e85f3bc5 Add support for C++0x's range-based for loops, as specified by the C++11 draft standard (N3291).
llvm-svn: 129541
2011-04-14 22:09:26 +00:00
Ted Kremenek 99a337eed0 When emitting a "too many arguments to function call..." error, also include a note with a location for the function prototype.
llvm-svn: 128833
2011-04-04 17:22:27 +00:00
John McCall 8feeb49662 Semantic checking for exception specifications should be triggered by
whether C++ exceptions are enabled, not exceptions in general.  PR9358.

llvm-svn: 126820
2011-03-02 02:04:40 +00:00
Douglas Gregor e63d087bcb C++ [basic.scope.hiding] allows an ordinary name to hide a non-tag
name *in the same scope*, but not across scopes. Implement the
highlighted condition.

llvm-svn: 117212
2010-10-23 16:06:17 +00:00
Douglas Gregor bff6203152 Always treat 'main' as an extern "C" function, so that we detect
redeclarations of main appropriately rather than allowing it to be
overloaded. Also, disallowing declaring main as a template.

Fixes GCC DejaGNU g++.old-deja/g++.other/main1.C.

llvm-svn: 117029
2010-10-21 16:57:46 +00:00
Chris Lattner 7f2c7f4ef3 "const std::vector<int>*" not "std::vector<int> const*"
llvm-svn: 113094
2010-09-05 00:27:00 +00:00
Sebastian Redl a771d2239d Rip out the C++0x-specific handling of destructor names. The specification is still in flux and unclear, and our interim workaround was broken. Fixes PR7467.
llvm-svn: 107835
2010-07-07 23:17:38 +00:00
Douglas Gregor a343430e00 Add test case that I forgot to commit with r107354 (the implementation
of C++ DR481). 

llvm-svn: 107359
2010-07-01 00:21:50 +00:00
Jeffrey Yasskin 2f96e9f5c9 Add an extension to avoid an error when a global template has the same name as
a member template, and you try to call the member template with an explicit
template argument.  See PR7247 

For example, this downgrades the error to a warning in:

template<typename T> struct set{};
struct Value {
    template<typename T>
    void set(T value) {
    }
};
void foo() {
    Value v;
    v.set<double>(3.2);  // Warning here.
}

llvm-svn: 105518
2010-06-05 01:39:57 +00:00
John McCall f24d7bbbcd A more minimal fix for PR6762.
llvm-svn: 104991
2010-05-28 18:45:08 +00:00
John McCall 61d8258fa3 Roll back r104941.
llvm-svn: 104990
2010-05-28 18:25:28 +00:00
John McCall 2177a9b65a Add a new attribute on records, __attribute__((adl_invisible)), and define
the x86-64 __va_list_tag with this attribute.  The attribute causes the
affected type to behave like a fundamental type when considered by ADL.

(x86-64 is the only target we currently provide with a struct-based
__builtin_va_list)

Fixes PR6762.

llvm-svn: 104941
2010-05-28 08:20:36 +00:00
John McCall cd4b3ba316 Test case for r104938.
llvm-svn: 104939
2010-05-28 06:14:52 +00:00
Douglas Gregor 205a361413 When we've parsed a nested-name-specifier in a member access
expression, "forget" about the object type; only the
nested-name-specifier matters for name lookup purposes. Fixes PR7239.

llvm-svn: 104834
2010-05-27 15:25:59 +00:00
Douglas Gregor 8b895228d9 Fix ADL for types declared in transparent decls, from Alp Toker!
llvm-svn: 102695
2010-04-30 07:08:38 +00:00
John McCall e87beb2591 Recommit my change to how C++ does elaborated type lookups, now with
two bugfixes which fix selfhost and (hopefully) the nightly tests.

llvm-svn: 102198
2010-04-23 18:46:30 +00:00
Daniel Dunbar 45b2d8ab42 Revert "C++ doesn't really use "namespaces" for different kinds of names the same", which seems to break most C++ nightly test apps.
llvm-svn: 102174
2010-04-23 13:07:39 +00:00
John McCall a245671ae0 C++ doesn't really use "namespaces" for different kinds of names the same
way that C does.  Among other differences, elaborated type specifiers
are defined to skip "non-types", which, as you might imagine, does not
include typedefs.  Rework our use of IDNS masks to capture the semantics
of different kinds of declarations better, and remove most current lookup
filters.  Removing the last remaining filter is more complicated and will
happen in a separate patch.

Fixes PR 6885 as well some spectrum of unfiled bugs.

llvm-svn: 102164
2010-04-23 02:41:41 +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
Jeffrey Yasskin 823015d627 When a template (without arguments) is passed as a template type
parameter, explicitly ask the user to give it arguments.  We used to
complain that it wasn't a type and expect the user to figure it out.

llvm-svn: 100729
2010-04-08 00:03:06 +00:00
John McCall 30837102a2 Put function templates instantiated from friend declarations in the correct
lexical context.  This is required for ADL to work properly;  fixes PR6716.

llvm-svn: 99665
2010-03-26 23:10:15 +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
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 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
Sebastian Redl f184291fec Check for redefinitions in MergeVarDecl. This finds redefinitions of globals without an initializer in C++ and thus fixes PR5451.
llvm-svn: 95098
2010-02-02 18:35:11 +00:00
Sebastian Redl 497c0a418d Fix two redefinitions in test cases that weren't diagnosed yet, but will be soon.
llvm-svn: 94565
2010-01-26 18:52:33 +00:00
Douglas Gregor 9de54ea41b Reimplement constructor declarator parsing to cope with template-ids
that name constructors, the endless joys of out-of-line constructor
definitions, and various other corner cases that the previous hack
never imagined. Fixes PR5688 and tightens up semantic analysis for
constructor names.

Additionally, fixed a problem where we wouldn't properly enter the
declarator scope of a parenthesized declarator. We were entering the
scope, then leaving it when we saw the ")"; now, we re-enter the
declarator scope before parsing the parameter list.

Note that we are forced to perform some tentative parsing within a
class (call it C) to tell the difference between

  C(int); // constructor

and

  C (f)(int); // member function

which is rather unfortunate. And, although it isn't necessary for
correctness, we use the same tentative-parsing mechanism for
out-of-line constructors to improve diagnostics in icky cases like:

  C::C C::f(int); // error: C::C refers to the constructor name, but
                  // we complain nicely and recover by treating it as
                  // a type.

llvm-svn: 93322
2010-01-13 17:31:36 +00:00
John McCall 0e21fccfae Tweak the text of several main() diagnostics and punch a hole specifically for
Darwin's sekrit fourth argument.  This should probably be factored to
let targets make target-specific decisions about what main() should look like.

Fixes rdar://problem/7414990
or if different platforms have radically different ideas of what they want in

llvm-svn: 92128
2009-12-24 09:58:38 +00:00
Douglas Gregor b6ea60872d Switch Sema::AddCXXDirectInitializerToDecl over to InitializationSequence
llvm-svn: 91927
2009-12-22 22:17:25 +00:00
Douglas Gregor 613bf10470 Enter the scope of an initializer for direct-initialization as well as
for copy-initialization.

llvm-svn: 91909
2009-12-22 17:47:17 +00:00
John McCall 1c7e6ec27b Don't inject the class name until that magical lbrace.
Because of the rules of base-class lookup* and the restrictions on typedefs, it
was actually impossible for this to cause any problems more serious than the
spurious acceptance of
  template <class T> class A : B<A> { ... };
instead of
  template <class T> class A : B<A<T> > { ... };
but I'm sure we can all agree that that is a very important restriction which
is well worth making another Parser->Sema call for.

(*) n.b. clang++ does not implement these rules correctly;  we are not ignoring
    non-type names

llvm-svn: 91792
2009-12-20 07:58:13 +00:00
John McCall bffb990c23 Test the lookup I wasn't sure would be done properly after the last patch.
Clang reasonably adds all the base specifiers in one pass;  this is now required
for correctness to prevent lookup from going mad.  But this has the advantage of
establishing the correct context when looking up base specifiers, which will be
important for access control.

llvm-svn: 91791
2009-12-20 05:57:29 +00:00
John McCall 2d814c305e Parse base specifiers within the scope of the class. This is possibly not
quite right;  I'll come back to it later.  It does fix PR 5741.

llvm-svn: 91789
2009-12-19 21:48:58 +00:00
John McCall 1f4ee7bd2f Just push a new scope when parsing an out-of-line variable definition.
Magically fixes all the terrible lookup problems associated with not pushing
a new scope.  Resolves an ancient xfail and an LLVM misparse.

llvm-svn: 91769
2009-12-19 09:28:58 +00:00
John McCall d681c3959f Introduce a centralized routine in Sema for diagnosing failed lookups (when
used as expressions).  In dependent contexts, try to recover by doing a lookup
in previously-dependent base classes.  We get better diagnostics out, but    
unfortunately the recovery fails:  we need to turn it into a method call  
expression, not a bare call expression.  Thus this is still a WIP.

llvm-svn: 91525
2009-12-16 08:11:27 +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
Anders Carlsson f5056f8545 Fix test.
llvm-svn: 91245
2009-12-13 18:30:34 +00:00
Anders Carlsson 7e0b207e54 More improvements to checking allocation and deallocation functions.
llvm-svn: 91244
2009-12-13 17:53:43 +00:00
Anders Carlsson e363c8e1df Correctly diagnose [basic.stc.dynamic.allocation]p1
llvm-svn: 91190
2009-12-12 00:32:00 +00:00
Anders Carlsson 12308f41e7 Improve diagnostics for malformed delete operator function declarations.
llvm-svn: 91180
2009-12-11 23:23:22 +00:00