summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/basic
Commit message (Collapse)AuthorAgeFilesLines
...
* Disallow constexpr main.Richard Smith2012-02-041-0/+6
| | | | llvm-svn: 149770
* constexpr: converted constant expression handling for enumerator values, caseRichard Smith2012-01-181-2/+2
| | | | | | | | | | values and non-type template arguments of integral and enumeration types. This change causes some legal C++98 code to no longer compile in C++11 mode, by enforcing the C++11 rule that narrowing integral conversions are not permitted in the final implicit conversion sequence for the above cases. llvm-svn: 148439
* Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:Richard Smith2012-01-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | - If the declarator is at the start of a line, and the previous line contained another declarator and ended with a comma, then that comma was probably a typo for a semicolon: int n = 0, m = 1, l = 2, // k = 5; myImportantFunctionCall(); // oops! - If removing the parentheses would correctly initialize the object, then produce a note suggesting that fix. - Otherwise, if there is a simple initializer we can suggest which performs value-initialization, then provide a note suggesting a correction to that initializer. Sema::Declarator now tracks the location of the comma prior to the declarator in the declaration, if there is one, to facilitate providing the note. The code to determine an appropriate initializer from the -Wuninitialized warning has been factored out to allow use in both that and -Wvexing-parse. llvm-svn: 148072
* David Blaikie and Chandler would like us to diagnoseRichard Smith2012-01-061-1/+1
| | | | | | | | int f(); in function scopes under -Wvexing-parse, so now we do. llvm-svn: 147649
* Tweak to r147599 for PR10828: Move the check from the parser into sema, and useRichard Smith2012-01-061-1/+1
| | | | | | | the Semantic Powers to only warn on class types (or dependent types), where the constructor or destructor could do something interesting. llvm-svn: 147642
* PR10828: Produce a warning when a no-arguments function is declared in blockRichard Smith2012-01-051-2/+1
| | | | | | | | | | | | | | | | | scope, when no other indication is provided that the user intended to declare a function rather than a variable. Remove some false positives from the existing 'parentheses disambiguated as a function' warning by suppressing it when the declaration is marked as 'typedef' or 'extern'. Add a new warning group -Wvexing-parse containing both of these warnings. The new warning is enabled by default; despite a number of false positives (and one bug) in clang's test-suite, I have only found genuine bugs with it when running it over a significant quantity of real C++ code. llvm-svn: 147599
* constexpr handling improvements. Produce detailed diagnostics when a 'constexpr'Richard Smith2011-12-191-5/+4
| | | | | | | | | | | | | | | | | | | | | variable is initialized by a non-constant expression, and pass in the variable being declared so that earlier-initialized fields' values can be used. Rearrange VarDecl init evaluation to make this possible, and in so doing fix a long-standing issue in our C++ constant expression handling, where we would mishandle cases like: extern const int a; const int n = a; const int a = 5; int arr[n]; Here, n is not initialized by a constant expression, so can't be used in an ICE, even though the initialization expression would be an ICE if it appeared later in the TU. This requires computing whether the initializer is an ICE eagerly, and saving that information in PCH files. llvm-svn: 146856
* Modify how the -verify flag works. Currently, the verification string andRichard Trieu2011-12-154-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | diagnostic message are compared. If either is a substring of the other, then no error is given. This gives rise to an unexpected case: // expect-error{{candidate function has different number of parameters}} will match the following error messages from Clang: candidate function has different number of parameters (expected 1 but has 2) candidate function has different number of parameters It will also match these other error messages: candidate function function has different number of parameters number of parameters This patch will change so that the verification string must be a substring of the diagnostic message before accepting. Also, all the failing tests from this change have been corrected. Some stats from this cleanup: 87 - removed extra spaces around verification strings 70 - wording updates to diagnostics 40 - extra leading or trailing characters (typos, unmatched parens or quotes) 35 - diagnostic level was included (error:, warning:, or note:) 18 - flag name put in the warning (-Wprotocol) llvm-svn: 146619
* When we notice that a member function is defined with "= delete" or "=Douglas Gregor2011-11-071-0/+1
| | | | | | | | | | | | default", make a note of which is used when creating the initial declaration. Previously, we would wait until later to handle default/delete as a definition, but this is too late: when adding the declaration, we already treated the declaration as "user-provided" when in fact it was merely "user-declared". Fixes PR10861 and PR10442, along with a bunch of FIXMEs. llvm-svn: 144011
* Update all tests other than Driver/std.cpp to use -std=c++11 rather thanRichard Smith2011-10-134-4/+4
| | | | | | -std=c++0x. Patch by Ahmed Charles! llvm-svn: 141900
* constexpr: don't consider class types with mutable members to be literal types.Richard Smith2011-10-121-0/+19
| | | | | | | 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
* constexpr: semantic checking for constexpr functions and constructors. Based inRichard Smith2011-10-011-0/+108
| | | | | | | | | | | | | 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
* De-Unicode-ify.NAKAMURA Takumi2011-08-121-1/+1
| | | | llvm-svn: 137430
* When performing the lookup in the current scope for a member access toDouglas Gregor2011-08-101-0/+18
| | | | | | | | | | | | 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
* Update this test to reflect the new (deterministic) order in r134038.Chandler Carruth2011-06-281-2/+2
| | | | | | | 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
* Modify test case to allow buildbots to make forward progress. This test shouldChad Rosier2011-06-281-2/+2
| | | | | | | now (incorrectly) pass. Once the appropriate fixes have been made this test should be reverted. llvm-svn: 134035
* Add support for C++ namespace-aware typo correction, e.g., correctingDouglas Gregor2011-06-281-3/+10
| | | | | | | | | | | | | | | 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
* Teach Sema::ActOnUninitializedDecl() not to try to interpret when oneDouglas Gregor2011-05-211-0/+3
| | | | | | | | should use a constructor to default-initialize a variable. InitializationSequence knows the rules for default initialization, better. Fixes <rdar://problem/8501008>. llvm-svn: 131796
* Support for C++11 (non-template) alias declarations.Richard Smith2011-04-151-0/+26
| | | | llvm-svn: 129567
* Add support for C++0x's range-based for loops, as specified by the C++11 ↵Richard Smith2011-04-141-0/+68
| | | | | | draft standard (N3291). llvm-svn: 129541
* When emitting a "too many arguments to function call..." error, also include ↵Ted Kremenek2011-04-041-1/+1
| | | | | | a note with a location for the function prototype. llvm-svn: 128833
* Semantic checking for exception specifications should be triggered byJohn McCall2011-03-021-1/+1
| | | | | | whether C++ exceptions are enabled, not exceptions in general. PR9358. llvm-svn: 126820
* C++ [basic.scope.hiding] allows an ordinary name to hide a non-tagDouglas Gregor2010-10-231-0/+24
| | | | | | | name *in the same scope*, but not across scopes. Implement the highlighted condition. llvm-svn: 117212
* Always treat 'main' as an extern "C" function, so that we detectDouglas Gregor2010-10-211-0/+5
| | | | | | | | | 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
* "const std::vector<int>*" not "std::vector<int> const*"Chris Lattner2010-09-051-1/+1
| | | | llvm-svn: 113094
* Rip out the C++0x-specific handling of destructor names. The specification ↵Sebastian Redl2010-07-071-0/+3
| | | | | | is still in flux and unclear, and our interim workaround was broken. Fixes PR7467. llvm-svn: 107835
* Add test case that I forgot to commit with r107354 (the implementationDouglas Gregor2010-07-011-0/+18
| | | | | | of C++ DR481). llvm-svn: 107359
* Add an extension to avoid an error when a global template has the same name asJeffrey Yasskin2010-06-051-0/+46
| | | | | | | | | | | | | | | | | | | | 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
* A more minimal fix for PR6762.John McCall2010-05-281-0/+11
| | | | llvm-svn: 104991
* Roll back r104941.John McCall2010-05-281-11/+0
| | | | llvm-svn: 104990
* Add a new attribute on records, __attribute__((adl_invisible)), and defineJohn McCall2010-05-281-0/+11
| | | | | | | | | | | | 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
* Test case for r104938.John McCall2010-05-281-0/+11
| | | | llvm-svn: 104939
* When we've parsed a nested-name-specifier in a member accessDouglas Gregor2010-05-271-1/+1
| | | | | | | expression, "forget" about the object type; only the nested-name-specifier matters for name lookup purposes. Fixes PR7239. llvm-svn: 104834
* Fix ADL for types declared in transparent decls, from Alp Toker!Douglas Gregor2010-04-301-0/+15
| | | | llvm-svn: 102695
* Recommit my change to how C++ does elaborated type lookups, now withJohn McCall2010-04-231-0/+60
| | | | | | two bugfixes which fix selfhost and (hopefully) the nightly tests. llvm-svn: 102198
* Revert "C++ doesn't really use "namespaces" for different kinds of names the ↵Daniel Dunbar2010-04-231-52/+0
| | | | | | same", which seems to break most C++ nightly test apps. llvm-svn: 102174
* C++ doesn't really use "namespaces" for different kinds of names the sameJohn McCall2010-04-231-0/+52
| | | | | | | | | | | | | 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
* Whenever we complain about a failed initialization of a function orDouglas Gregor2010-04-221-1/+1
| | | | | | | | | | | | | | | | | 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
* When a template (without arguments) is passed as a template typeJeffrey Yasskin2010-04-081-2/+2
| | | | | | | 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
* Put function templates instantiated from friend declarations in the correctJohn McCall2010-03-261-0/+12
| | | | | | lexical context. This is required for ADL to work properly; fixes PR6716. llvm-svn: 99665
* When a declaration of a function is missing an exception specificationDouglas Gregor2010-03-242-3/+19
| | | | | | | | | | | | | | | | | | | | | 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
* When pretty-printing tag types, only print the tag if we're in C (andJohn McCall2010-03-101-2/+2
| | | | | | | | | | 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
* Implement crazy destructor name lookup semantics differently inDouglas Gregor2010-02-233-0/+77
| | | | | | | | | | 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
* Check for redefinitions in MergeVarDecl. This finds redefinitions of globals ↵Sebastian Redl2010-02-021-0/+21
| | | | | | without an initializer in C++ and thus fixes PR5451. llvm-svn: 95098
* Fix two redefinitions in test cases that weren't diagnosed yet, but will be ↵Sebastian Redl2010-01-261-1/+1
| | | | | | soon. llvm-svn: 94565
* Reimplement constructor declarator parsing to cope with template-idsDouglas Gregor2010-01-131-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Tweak the text of several main() diagnostics and punch a hole specifically forJohn McCall2009-12-241-1/+1
| | | | | | | | | | 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
* Switch Sema::AddCXXDirectInitializerToDecl over to InitializationSequenceDouglas Gregor2009-12-221-1/+1
| | | | llvm-svn: 91927
* Enter the scope of an initializer for direct-initialization as well asDouglas Gregor2009-12-221-0/+2
| | | | | | for copy-initialization. llvm-svn: 91909
* Don't inject the class name until that magical lbrace.John McCall2009-12-201-0/+8
| | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud