summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX
Commit message (Collapse)AuthorAgeFilesLines
...
* [Concepts] Implement subsection [dcl.spec.concept]p7 of the Concepts TSNathan Wilson2016-04-091-0/+18
| | | | | | | | | | | | Summary: A program shall not declare an explicit instantiation (14.8.2), an explicit specialization (14.8.3), or a partial specialization of a concept definition. Reviewers: rsmith, hubert.reinterpretcast, faisalv, aaron.ballman Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18221 llvm-svn: 265868
* Diagnose template alias declarations in local classes.Richard Smith2016-04-061-1/+3
| | | | | | Patch by Erik Pilkington! llvm-svn: 265571
* Paper over the Windows-only enum initialization test failure until the bug ↵Reid Kleckner2016-03-281-1/+2
| | | | | | is fixed llvm-svn: 264642
* P0138R2: Allow direct-list-initialization of an enumeration from an integralRichard Smith2016-03-281-0/+127
| | | | | | value that can convert to the enum's underlying type. llvm-svn: 264564
* Make SemaAccess smarter about determining when a dependent class mightRichard Smith2016-03-231-3/+16
| | | | | | | instantiate to match a friend class declaration. It's still pretty dumb, though. llvm-svn: 264189
* [Cxx1z] Implement Lambda Capture of *this by Value as [=,*this] (P0018R3)Faisal Vali2016-03-211-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement lambda capture of *this by copy. For e.g.: struct A { int d = 10; auto foo() { return [*this] (auto a) mutable { d+=a; return d; }; } }; auto L = A{}.foo(); // A{}'s lifetime is gone. // Below is still ok, because *this was captured by value. assert(L(10) == 20); assert(L(100) == 120); If the capture was implicit, or [this] (i.e. *this was captured by reference), this code would be otherwise undefined. Implementation Strategy: - amend the parser to accept *this in the lambda introducer - add a new king of capture LCK_StarThis - teach Sema::CheckCXXThisCapture to handle by copy captures of the enclosing object (i.e. *this) - when CheckCXXThisCapture does capture by copy, the corresponding initializer expression for the closure's data member direct-initializes it thus making a copy of '*this'. - in codegen, when assigning to CXXThisValue, if *this was captured by copy, make sure it points to the corresponding field member, and not, unlike when captured by reference, what the field member points to. - mark feature as implemented in svn Much gratitude to Richard Smith for his carefully illuminating reviews! llvm-svn: 263921
* P0184R0: Allow types of 'begin' and 'end' expressions in range-based for ↵Richard Smith2016-03-201-4/+11
| | | | | | loops to differ. llvm-svn: 263895
* Implement support for [[maybe_unused]] in C++1z that is based off existing ↵Aaron Ballman2016-03-094-0/+56
| | | | | | support for unused, and treat it as an extension pre-C++1z. This also means extending the existing unused attribute so that it can be placed on an enum and enumerator, in addition to the other subjects. llvm-svn: 263025
* Readd testcase accidentally removed in r262888.Richard Smith2016-03-091-0/+2
| | | | llvm-svn: 262971
* P0017R1: In C++1z, an aggregate class can have (public non-virtual) base ↵Richard Smith2016-03-082-81/+124
| | | | | | classes; these are initialized as if they were data members. llvm-svn: 262963
* Silence duplicate diagnostics because parsing of a standards-based attribute ↵Aaron Ballman2016-03-081-0/+8
| | | | | | triggers parsing diagnostics that may also be picked up during semantic analysis. llvm-svn: 262960
* Move [[nodiscard]] tests into test/CXX tree.Richard Smith2016-03-082-0/+46
| | | | llvm-svn: 262888
* Add accidentally forgotten testcase from r262881.Richard Smith2016-03-081-0/+70
| | | | llvm-svn: 262882
* [modules] Prefer more complete array types.Vassil Vassilev2016-02-281-0/+4
| | | | | | | | | | | | | | If we import a module that has a complete array type and one that has an incomplete array type, the declaration found by name lookup might be the one with the incomplete type, possibly resulting in rejects-valid. Now, the name lookup prefers decls with a complete array types. Also, diagnose cases when the redecl chain has array bound, different from the merge candidate. Reviewed by Richard Smith. llvm-svn: 262189
* Implement the likely resolution of core issue 253.Nico Weber2016-02-193-5/+6
| | | | | | | | | | | | | | | | | | C++11 requires const objects to have a user-provided constructor, even for classes without any fields. DR 253 relaxes this to say "If the implicit default constructor initializes all subobjects, no initializer should be required." clang is currently the only compiler that implements this C++11 rule, and e.g. libstdc++ relies on something like DR 253 to compile in newer versions. This change makes it possible to build code that says `const vector<int> v;' again when using libstdc++5.2 and _GLIBCXX_DEBUG (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60284). Fixes PR23381. http://reviews.llvm.org/D16552 llvm-svn: 261297
* Improve diagnostics for ill-formed literal operator declarations.Richard Smith2016-02-172-7/+7
| | | | | | Patch by Erik Pilkington! llvm-svn: 261034
* [Concepts] Implement a portion of Concepts TS[dcl.spec.concept]p1 byNathan Wilson2016-02-081-0/+17
| | | | | | | | | | | | | | diagnosing when 'concept' is specified on a function or template specialization. Since a concept can only be applied to a function or variable template, the concept bit is stored in TemplateDecl as a PointerIntPair. Reviewers: rsmith, faisalv, aaron.ballman, hubert.reinterpretcast Differential Revision: http://reviews.llvm.org/D13357 llvm-svn: 260074
* Ensure that we substitute into the declaration of a template parameter packRichard Smith2016-02-031-0/+22
| | | | | | | (that is not a pack expansion) during template argument deduction, even if we deduced that the pack would be empty. llvm-svn: 259688
* PR23057: Fix assertion `Val && "isa<> used on a null pointer"' on invalid ↵Denis Zobnin2016-02-021-0/+3
| | | | | | | | | | | for-range expression. Fix the issue discovered by fuzzing (PR23057, comment 18) by handling nullptr in Sema::ActOnCXXForRangeDecl and correct delayed typos in for-range expression before calling Sema::ActOnCXXForRangeStmt. Also fixes PR26288. Differential Revision: http://reviews.llvm.org/D16630 llvm-svn: 259532
* Mark DR1250 as implementedDavid Majnemer2016-02-011-0/+18
| | | | | | | We implemented this DR back in r258768 but forgot to mark it as implemented. llvm-svn: 259335
* Improve -Wconstant-conversionRichard Trieu2016-01-291-2/+2
| | | | | | | | | | | | | | Switch the evaluation from isIntegerConstantExpr to EvaluateAsInt. EvaluateAsInt will evaluate more types of expressions than isIntegerConstantExpr. Move one case from -Wsign-conversion to -Wconstant-conversion. The case is: 1) Source and target types are signed 2) Source type is wider than the target type 3) The source constant value is positive 4) The conversion will store the value as negative in the target. llvm-svn: 259271
* [Concepts] Implement a portion of Concepts TS[dcl.spec.concept]p5 and p6:Nathan Wilson2016-01-292-0/+37
| | | | | | | | | | | Diagnose if the return type of a function concept or declaration type of a variable concept is not bool. Reviewers: hubert.reinterpretcast Differential Revision: http://reviews.llvm.org/D16163 llvm-svn: 259159
* PR26048, PR26050: put non-type template parameters and indirect field declsRichard Smith2016-01-062-5/+68
| | | | | | | | into IDNS_Tag in C++, because they conflict with redeclarations of tags. (This doesn't affect elaborated-type-specifier lookup, which looks for IDNS_Type in C++). llvm-svn: 256985
* Fix half of PR26048. We don't yet diagnose the case where the anonymous ↵Richard Smith2016-01-063-2/+28
| | | | | | union member is declared first and the tag name is declared second. llvm-svn: 256979
* Convert test/CXX/lex/lex.literal/lex.string/p4.cpp back to DOS lineDimitry Andric2016-01-041-17/+17
| | | | | | | endings, since the file is supposed to have them, according to its comments. Also set its svn:eol-style property. Noticed by Nico Weber. llvm-svn: 256742
* Fix several accidental DOS line endings in source filesDimitry Andric2016-01-031-17/+17
| | | | | | | | | | | | | | | Summary: There are a number of files in the tree which have been accidentally checked in with DOS line endings. Convert these to native line endings. There are also a few files which have DOS line endings on purpose, and I have set the svn:eol-style property to 'CRLF' on those. Reviewers: joerg, aaron.ballman Subscribers: aaron.ballman, cfe-commits Differential Revision: http://reviews.llvm.org/D15849 llvm-svn: 256704
* Improve diagnostic for the case where a function template candidate is rejectedRichard Smith2015-12-313-4/+3
| | | | | | | | by overload resolution because deduction succeeds, but the substituted parameter type for some parameter (with deduced type) doesn't exactly match the corresponding adjusted argument type. llvm-svn: 256657
* [Cygwin] Enable TLS as emutls.NAKAMURA Takumi2015-12-211-1/+0
| | | | | | | | It resolves clang selfhosting with std::once() for Cygwin. FIXME: It may be EmulatedTLS-generic also for X86-Android. FIXME: Pass EmulatedTLS to LLVM CodeGen from Clang with -femulated-tls. llvm-svn: 256134
* Allow non-defining declarations of class template partial specializations toRichard Smith2015-12-111-0/+26
| | | | | | | | | have a nested name specifier. Strictly speaking, forward declarations of class template partial specializations are not permitted at all, but that seems like an obvious wording defect, and if we allow them without a nested name specifier we should also allow them with a nested name specifier. llvm-svn: 255383
* Add some more tests for initializer lists related to CWG1591Faisal Vali2015-12-111-0/+20
| | | | llvm-svn: 255323
* Fix PR24694 (CWG1591): Deducing array bound and element type from ↵Faisal Vali2015-12-101-0/+51
| | | | | | | | | | | | | | | initializer list https://llvm.org/bugs/show_bug.cgi?id=24694 http://wg21.link/cwg1591 Teach DeduceFromInitializerList in SemaTemplateDeduction.cpp to deduce against array (constant and dependent sized) parameters (really, reference to arrays since they don't decay to pointers), by checking if the template parameter is either one of those kinds of arrays, and if so, deducing each initializer list element against the element type, and then deducing the array bound if needed. In brief, this patch enables the following code: template<class T, int N> int *f(T (&&)[N]); int *ip = f({1, 2, 3}); llvm-svn: 255221
* [Lit Test] Updated 20 Lit tests to be C++11 compatible.Charles Li2015-12-101-1/+6
| | | | | | | | This is the 5th Lit test patch. Expanded expected diagnostics to vary by C++ dialect. Expanded RUN line to: default, C++98/03 and C++11. llvm-svn: 255196
* PR25731: namespace alias declarations can appear at block scope; ensure that weRichard Smith2015-12-031-1/+6
| | | | | | | | | do scope-based lookup when looking for redeclarations of them. Add some related missing checks for the scope-based redeclaration lookup: properly filter the list of found declarations to match the scope, and diagnose shadowing of a template parameter name. llvm-svn: 254663
* PR17381: Treat undefined behavior during expression evaluation as an unmodeledRichard Smith2015-12-031-2/+2
| | | | | | | | | | | | | | | | | | | | | side-effect, so that we don't allow speculative evaluation of such expressions during code generation. This caused a diagnostic quality regression, so fix constant expression diagnostics to prefer either the first "can't be constant folded" diagnostic or the first "not a constant expression" diagnostic depending on the kind of evaluation we're doing. This was always the intent, but didn't quite work correctly before. This results in certain initializers that used to be constant initializers to no longer be; in particular, things like: float f = 1e100; are no longer accepted in C. This seems appropriate, as such constructs would lead to code being executed if sanitizers are enabled. llvm-svn: 254574
* [PR25661] Revert part of r217213 according to r254323.NAKAMURA Takumi2015-11-301-13/+2
| | | | llvm-svn: 254346
* P0002R1: increment on expressions of type bool is no longer allowed in C++1z.Richard Smith2015-11-261-0/+5
| | | | llvm-svn: 254122
* [NFC] Change the evaluation context of a non-type default template argument ↵Faisal Vali2015-11-181-0/+14
| | | | | | | | | | | | | | | | from Unevaluated to ConstantEvaluated. This patch emits a more appropriate (but still noisy) diagnostic stream when a lambda-expression is encountered within a non-type default argument. For e.g. template<int N = ([] { return 5; }())> int f(); As opposed to complaining that a lambda expression is not allowed in an unevaluated operand, the patch complains about the lambda being forbidden in a constant expression context (which will be allowed in C++17 now that they have been accepted by EWG, unless of course CWG or national bodies (that have so far shown no signs of concern) rise in protest) As I start submitting patches for constexpr lambdas (http://wg21.link/P0170R0) under C++1z (OK'd by Richard Smith at Kona), this will be one less change to make. Thanks! llvm-svn: 253431
* [Lit Test] Updated 34 Lit tests to be C++11 compatible.Charles Li2015-11-1710-6/+92
| | | | | | | Added expected diagnostics new to C++11. Expanded RUN line to: default, C++98/03 and C++11. llvm-svn: 253371
* Avoid duplicated diagnostic when lookup for a nested-name-specifier fails ↵Richard Smith2015-11-121-2/+1
| | | | | | due to ambiguity. llvm-svn: 252967
* DR407: Rationalize how we handle tags being hidden by typedefs. Even withRichard Smith2015-11-121-9/+9
| | | | | | | | | | | | | | | | | | DR407, the C++ standard doesn't really say how this should work. Here's what we do (which is consistent with DR407 as far as I can tell): * When performing name lookup for an elaborated-type-specifier, a tag declaration hides a typedef declaration that names the same type. * When performing any other kind of lookup, a typedef declaration hides a tag declaration that names the same type. In any other case where lookup finds both a typedef and a tag (that is, when they name different types), the lookup will be ambiguous. If lookup finds a tag and a typedef that name the same type, and finds anything else, the lookup will always be ambiguous (even if the other entity would hide the tag, it does not also hide the typedef). llvm-svn: 252959
* Add diagnostics which fall under [dcl.spec.concept]p5Nathan Wilson2015-11-111-0/+13
| | | | | | | | | | | | Summary: Diagnose when a function concept declaration has parameter(s) Reviewers: rsmith, faisalv, aaron.ballman, hubert.reinterpretcast Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D14352 llvm-svn: 252827
* [Lit Test] Updated 26 Lit tests to be C++11 compatible.Charles Li2015-11-114-8/+41
| | | | | | | Expected diagnostics have been expanded to vary by C++ dialect. RUN line has also been expanded to: default, C++98/03 and C++11. llvm-svn: 252785
* Add support for GCC's '__auto_type' extension, per the GCC manual:Richard Smith2015-11-112-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | https://gcc.gnu.org/onlinedocs/gcc/Typeof.html Differences from the GCC extension: * __auto_type is also permitted in C++ (but only in places where it could appear in C), allowing its use in headers that might be shared across C and C++, or used from C++98 * __auto_type can be combined with a declarator, as with C++ auto (for instance, "__auto_type *p") * multiple variables can be declared in a single __auto_type declaration, with the C++ semantics (the deduced type must be the same in each case) This patch also adds a missing restriction on applying typeof to a bit-field, which GCC has historically rejected in C (due to lack of clarity as to whether the operand should be promoted). The same restriction also applies to __auto_type in C (in both GCC and Clang). This also fixes PR25449. Patch by Nicholas Allegra! llvm-svn: 252690
* N3922: direct-list-initialization of an auto-typed variable no longer deduces aRichard Smith2015-11-112-8/+9
| | | | | | | | | | | | | | | | | | | std::initializer_list<T> type. Instead, the list must contain a single element and the type is deduced from that. In Clang 3.7, we warned by default on all the cases that would change meaning due to this change. In Clang 3.8, we will support only the new rules -- per the request in N3922, this change is applied as a Defect Report against earlier versions of the C++ standard. This change is not entirely trivial, because for lambda init-captures we previously did not track the difference between direct-list-initialization and copy-list-initialization. The difference was not previously observable, because the two forms of initialization always did the same thing (the elements of the initializer list were always copy-initialized regardless of the initialization style used for the init-capture). llvm-svn: 252688
* [Concepts] Add diagnostics which fall under [dcl.spec.concept]p1Nathan Wilson2015-11-041-0/+2
| | | | | | | | | | | | Summary: Diagnose when the 'concept' specifier is used on a typedef or function parameter. Reviewers: rsmith, hubert.reinterpretcast, aaron.ballman, faisalv Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D14316 llvm-svn: 252061
* [Concepts] Fixing Concepts TS directory structure; NFCNathan Wilson2015-10-102-0/+0
| | | | llvm-svn: 249934
* Update tests touched by r249656David Majnemer2015-10-084-9/+9
| | | | | | | | | These test updates almost exclusively around the change in behavior around enum: enums without a definition are considered incomplete except when targeting MSVC ABIs. Since these tests are interested in the 'incomplete-enum' behavior, restrict them to %itanium_abi_triple. llvm-svn: 249660
* When pretty-printing a C++11 literal operator, don't insert whitespace betweenRichard Smith2015-10-085-19/+19
| | | | | | | the "" and the suffix; that breaks names such as 'operator""if'. For symmetry, also remove the space between the 'operator' and the '""'. llvm-svn: 249641
* [Sema] Don't crash when friending an unqualified templated constructorDavid Majnemer2015-09-301-0/+6
| | | | | | | | | | Unqualified templated constructors cannot be friended and our lack of a diagnostic led to violated invariants. Instead, raise a diagnostic when processing the friend declaration. This fixes PR20251. llvm-svn: 248953
* Promote a warning on ill-formed code (redeclaration missing an exceptionRichard Smith2015-09-305-6/+6
| | | | | | | | | | | | | | | | | specification) to an error. No compiler other than Clang seems to allow this, and it doesn't seem like a useful thing to accept as an extension in general. The current behavior was added for PR5957, where the problem was specifically related to mismatches of the exception specification on the implicitly-declared global operator new and delete. To retain that workaround, we downgrade the error to an ExtWarn when the declaration is of a replaceable global allocation function. Now that this is an error, stop trying (and failing) to recover from a missing computed noexcept specification. That recovery didn't work, and led to crashes in code like the added testcase. llvm-svn: 248867
OpenPOWER on IntegriCloud