summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/dcl.decl
Commit message (Collapse)AuthorAgeFilesLines
...
* Code cleanupNathan Sidwell2015-01-301-0/+1
| | | | | | | Parser::ParseLexedMethodDeclaration: Use local var for Param Sema::MergeCXXFunctionDecls: Use hasInheritedDefaultArg llvm-svn: 227577
* Don't crash on an invalid trailing return type on a function before a '...'Nico Weber2014-12-301-0/+4
| | | | | | | | | | | | clang tries to produce a helpful diagnostic for the traiilng '...', but the code that r216778 added for this doesn't expect an invalid trailing return type. Add code to explicitly handle this. Having explicit code for this but not for other things looks a bit strange, but trailing return types are special in that they have a separate existence bit in addition to the type (see r158348). llvm-svn: 224974
* Parse: Recover more gracefully from extra :: tokens before a {David Majnemer2014-12-291-0/+2
| | | | | | | Instead of crashing, recover by eating the extra trailing scope qualifier. This means we will treat 'struct A:: {' as 'struct A {'. llvm-svn: 224966
* Parse: Ignore '::' in 'struct :: {'David Majnemer2014-12-291-1/+0
| | | | | | | Let's pretend that we didn't see the '::' instead of go on believing that we've got some anonymous, but globally qualified, struct. llvm-svn: 224945
* Sema: Don't crash when solitary :: token appears before { in struct defDavid Majnemer2014-12-291-0/+3
| | | | | | | | hasDeclaratorForAnonDecl, getDeclaratorForAnonDecl and getTypedefNameForAnonDecl are expected to handle the case where NamedDeclOrQualifier holds the wrong type or nothing at all. llvm-svn: 224912
* First half of CWG1962: decltype(__func__) should not be a reference type,Richard Smith2014-11-111-0/+18
| | | | | | because __func__ is supposed to act like a local static variable. llvm-svn: 221698
* Change -Wbind-to-temporary-copy from an ExtWarn to an Extension.Nico Weber2014-09-181-1/+1
| | | | | | | | | | | | | | | | | The reasoning is that this construct is accepted by all compilers and valid in C++11, so it doesn't seem like a useful warning to have enabled by default. Building with -pedantic, -Wbind-to-temporary-copy, or -Wc++98-compat still shows the warning. The motivation is that I built re2, and this was the only warning that was emitted during the build. Both changing re2 to fix the warning and detecting clang and suppressing the warning in re2's build seem inferior than just giving the compiler a good default for this warning. Also move the cxx98compat version of this warning to CXX98CompatPedantic, and update tests accordingly. llvm-svn: 218008
* PR20844: If we fail to list-initialize a reference, map to the referenced typeRichard Smith2014-09-041-7/+8
| | | | | | | | | before retrying the initialization to produce diagnostics. Otherwise, we may fail to produce any diagnostics, and silently produce invalid AST in a -Asserts build. Also add a note to this codepath to make it more clear why we were trying to create a temporary. llvm-svn: 217197
* Fix for PR20660, where unexpanded parameter pack in function parameter ↵Larisse Voufo2014-08-291-0/+27
| | | | | | clause causes clang to crash. llvm-svn: 216778
* Reject varargs '...' in function prototype if there are more parameters afterRichard Smith2014-08-111-2/+1
| | | | | | | | | | | it. Diagnose with recovery if it appears after a function parameter that was obviously supposed to be a parameter pack. Otherwise, warn if it immediately follows a function parameter pack, because the user most likely didn't intend to write a parameter pack followed by a C-style varargs ellipsis. This warning can be syntactically disabled by using ", ..." instead of "...". llvm-svn: 215408
* Improve diagnostic on default-initializing const variables (PR20208).Nico Weber2014-07-232-5/+5
| | | | | | | | This tweaks the diagnostic wording slighly, and adds a fixit on a note. An alternative would be to add the fixit directly on the diagnostic, see the review thread linked to from the bug for a few notes on that approach. llvm-svn: 213725
* Tweak diagnostic wording for init list narrowingAlp Toker2014-05-175-106/+106
| | | | | | | | | The conventional form is '<action> to silence this warning'. Also call the diagnostic an 'issue' rather than a 'message' because the latter term is more widely used with reference to message expressions. llvm-svn: 209052
* PR19742: cv-qualifiers and ref-qualifiers aren't allowed on functions withinRichard Smith2014-05-142-4/+24
| | | | | | | pointer and reference types, even if those types are produced by template instantiation. llvm-svn: 208825
* Don't emit an ExtWarn on declarations of variable template specializations;Richard Smith2014-04-171-4/+4
| | | | | | | we'll already have issued the relevant diagnostic when we saw the declaration of the primary template. llvm-svn: 206441
* Don't fold together the name lookup entries for two declarations if they areRichard Smith2014-03-171-11/+12
| | | | | | declared in different namespaces in the same inline namespace set. llvm-svn: 204082
* Replace "can not" with "cannot" in diagnostics messages.Ismail Pazarbasi2014-03-071-3/+3
| | | | llvm-svn: 203302
* PR16074, implement warnings to catch pointer to boolean true and pointer toRichard Trieu2014-02-262-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | null comparison when the pointer is known to be non-null. This catches the array to pointer decay, function to pointer decay and address of variables. This does not catch address of function since this has been previously used to silence a warning. Pointer to bool conversion is under -Wbool-conversion. Pointer to null comparison is under -Wtautological-pointer-compare, a sub-group of -Wtautological-compare. void foo() { int arr[5]; int x; // warn on these conditionals if (foo); if (arr); if (&x); if (foo == null); if (arr == null); if (&x == null); if (&foo); // no warning } llvm-svn: 202216
* PR13110: Add a -Wignored-qualifiers warning when ignoring a const, volatile, orRichard Smith2014-02-191-3/+2
| | | | | | _Atomic qualifier applied to a reference type. llvm-svn: 201620
* Implement DR482: namespace members can be redeclared with a qualified nameRichard Smith2013-12-051-5/+13
| | | | | | | | | | within their namespace, and such a redeclaration isn't required to be a definition any more. Update DR status page to say Clang 3.4 instead of SVN and add new Clang 3.5 category (but keep Clang 3.4 yellow for now). llvm-svn: 196481
* Correct hyphenations in comments and assert messagesAlp Toker2013-12-051-1/+1
| | | | | | | This patch tries to avoid unrelated changes other than fixing a few hyphen-related ambiguities in nearby lines. llvm-svn: 196466
* Per [dcl.meaning]p1, a name in an inline namespace can be redeclared using aRichard Smith2013-12-051-0/+79
| | | | | | | name from the enclosing namespace set if the name is specified as a qualified-id. llvm-svn: 196464
* Teach typo correction to look inside of classes like it does namespaces.Kaelyn Uhrain2013-09-261-3/+3
| | | | | | | | | | | | | | | Unlike with namespaces, searching inside of classes requires also checking the access to correction candidates (i.e. don't suggest a correction to a private class member for a correction occurring outside that class and its methods or friends). Included is a small (one line) fix for a bug, that was uncovered while cleaning up the unit tests, where the decls from a TypoCorrection candidate were preserved in new TypoCorrection candidates that are derived (copied) from the old TypoCorrection--notably when creating a new candidate by changing the NestedNameSpecifier associated with the base idenitifer. llvm-svn: 191449
* Modify the uninitialized field visitor to detect uninitialized use across theRichard Trieu2013-09-201-1/+1
| | | | | | | | | | | | | | | | | | fields in the class. This allows a better checking of member intiailizers and in class initializers in regards to initialization ordering. For instance, this code will now produce warnings: class A { int x; int y; A() : x(y) {} // y is initialized after x, warn here A(int): y(x) {} // default initialization of leaves x uninitialized, warn here }; Several test cases were updated with -Wno-uninitialized to silence this warning. llvm-svn: 191068
* Switch the semantic DeclContext for a block-scope declaration of a function orRichard Smith2013-09-201-4/+61
| | | | | | | | | | | | | | variable from being the function to being the enclosing namespace scope (in C++) or the TU (in C). This allows us to fix a selection of related issues where we would build incorrect redeclaration chains for such declarations, and fail to notice type mismatches. Such declarations are put into a new IdentifierNamespace, IDNS_LocalExtern, which is only found when searching scopes, and not found when searching DeclContexts. Such a declaration is only made visible in its DeclContext if there are no non-LocalExtern declarations. llvm-svn: 191064
* Mark that qualifiers can prefix the auto type. This seems to just haveChandler Carruth2013-09-021-1/+1
| | | | | | | | | | | | | | | | | | been an oversight, as it definitely works. Every test which changed had the const written on the LHS of the auto already. Notably, this also makes things like cpp11-migrate's formation of 'const auto &' variables much more familiar. Yes, many people feel that 'const' and other qualifiers belong on the RHS of the type. I'm not going to argue about that because Clang already *overwhelming* places the qualifiers on the LHS when it can and on the RHS when it must. We shouldn't diverge for auto. We should add a tool to clang-tidy that fixes this in either direction, and then wire up clang-tidy to tools like cpp11-migrate to fix their placement after transforms. llvm-svn: 189769
* Fix implementation of C11 6.2.7/4 and C++11 [dcl.array]p3:Richard Smith2013-08-131-0/+152
| | | | | | | | | | | | | When a local extern declaration redeclares some other entity, the type of that entity is merged with the prior type if the prior declaration is visible (in C) or is declared in the same scope (in C++). - Make LookupRedeclarationWithLinkage actually work in C++, use it in the right set of cases, and make it track whether it found a shadowed declaration. - Track whether we found a declaration in the same scope (for C++) including across serialization and template instantiation. llvm-svn: 188307
* PR12086, PR15117Richard Smith2013-06-121-3/+7
| | | | | | | | | | | | | | | | | | | Introduce CXXStdInitializerListExpr node, representing the implicit construction of a std::initializer_list<T> object from its underlying array. The AST representation of such an expression goes from an InitListExpr with a flag set, to a CXXStdInitializerListExpr containing a MaterializeTemporaryExpr containing an InitListExpr (possibly wrapped in a CXXBindTemporaryExpr). This more detailed representation has several advantages, the most important of which is that the new MaterializeTemporaryExpr allows us to directly model lifetime extension of the underlying temporary array. Using that, this patch *drastically* simplifies the IR generation of this construct, provides IR generation support for nested global initializer_list objects, fixes several bugs where the destructors for the underlying array would accidentally not get invoked, and provides constant expression evaluation support for std::initializer_list objects. llvm-svn: 183872
* Grab-bag of bit-field fixes:John McCall2013-05-061-0/+23
| | | | | | | | | | | | | | - References to ObjC bit-field ivars are bit-field lvalues; fixes rdar://13794269, which got me started down this. - Introduce Expr::refersToBitField, switch a couple users to it where semantically important, and comment the difference between this and the existing API. - Discourage Expr::getBitField by making it a bit longer and less general-sounding. - Lock down on const_casts of bit-field gl-values until we hear back from the committee as to whether they're allowed. llvm-svn: 181252
* The 'constexpr implies const' rule for non-static member functions is gone inRichard Smith2013-04-211-2/+2
| | | | | | | | | C++1y, so stop adding the 'const' there. Provide a compatibility warning for code relying on this in C++11, with a fix-it hint. Update our lazily-written tests to add the const, except for those ones which were testing our implementation of this rule. llvm-svn: 179969
* C++1y: Allow aggregates to have default initializers.Richard Smith2013-04-202-5/+31
| | | | | | | | | | | Add a CXXDefaultInitExpr, analogous to CXXDefaultArgExpr, and use it both in CXXCtorInitializers and in InitListExprs to represent a default initializer. There's an additional complication here: because the default initializer can refer to the initialized object via its 'this' pointer, we need to make sure that 'this' points to the right thing within the evaluation. llvm-svn: 179958
* Force a load when creating a reference to a temporary copied from a bitfield.Jordan Rose2013-04-111-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For this source: const int &ref = someStruct.bitfield; We used to generate this AST: DeclStmt [...] `-VarDecl [...] ref 'const int &' `-MaterializeTemporaryExpr [...] 'const int' lvalue `-ImplicitCastExpr [...] 'const int' lvalue <NoOp> `-MemberExpr [...] 'int' lvalue bitfield .bitfield [...] `-DeclRefExpr [...] 'struct X' lvalue ParmVar [...] 'someStruct' 'struct X' Notice the lvalue inside the MaterializeTemporaryExpr, which is very confusing (and caused an assertion to fire in the analyzer - PR15694). We now generate this: DeclStmt [...] `-VarDecl [...] ref 'const int &' `-MaterializeTemporaryExpr [...] 'const int' lvalue `-ImplicitCastExpr [...] 'int' <LValueToRValue> `-MemberExpr [...] 'int' lvalue bitfield .bitfield [...] `-DeclRefExpr [...] 'struct X' lvalue ParmVar [...] 'someStruct' 'struct X' Which makes a lot more sense. This allows us to remove code in both CodeGen and AST that hacked around this special case. The commit also makes Clang accept this (legal) C++11 code: int &&ref = std::move(someStruct).bitfield PR15694 / <rdar://problem/13600396> llvm-svn: 179250
* <rdar://problem/13278115> Improve diagnostic when failing to bind an rvalue ↵Douglas Gregor2013-03-261-0/+8
| | | | | | reference to an lvalue of compatible type. llvm-svn: 178095
* <rdar://problem/13395022> Strip references when extracting an ↵Douglas Gregor2013-03-251-0/+10
| | | | | | initializer_list's element type during application of an initialization sequence. llvm-svn: 177944
* PR15390: If a function returns a pointer to a function, that function typeRichard Smith2013-03-061-1/+4
| | | | | | | can't have default arguments even though it's a parameter-declaration-clause in a function declaration. llvm-svn: 176542
* Add some missing diagnostics for C++11 narrowing conversions.Richard Smith2013-02-051-12/+11
| | | | llvm-svn: 174337
* Fixed an assertion failure triggered by invalid code.Enea Zaffanella2013-01-111-4/+2
| | | | | | | | Set invalid type of declarator after emitting error diagnostics, so that it won't be later considered when instantiating the template. Added test5_inst in test/SemaCXX/condition.cpp for non-regression. llvm-svn: 172201
* Implement AST dumper for Decls.Alexander Kornienko2012-12-201-7/+7
| | | | | | | | http://llvm-reviews.chandlerc.com/D52 Patch by Philip Craig! llvm-svn: 170634
* Properly compute triviality for explicitly-defaulted or deleted special members.Richard Smith2012-12-082-5/+4
| | | | | | | | | | | | | | Remove pre-standard restriction on explicitly-defaulted copy constructors with 'incorrect' parameter types, and instead just make those special members non-trivial as the standard requires. This required making CXXRecordDecl correctly handle classes which have both a trivial and a non-trivial special member of the same kind. This also fixes PR13217 by reimplementing DiagnoseNontrivial in terms of the new triviality computation technology. llvm-svn: 169667
* Implement C++03 [dcl.init]p5's checking for value-initialization of referencesRichard Smith2012-12-081-10/+38
| | | | | | | | properly, rather than faking it up by pretending that a reference member makes the default constructor non-trivial. That leads to rejects-valids when putting such types inside unions. llvm-svn: 169662
* Per [dcl.fct.def.default]p1, don't allow variadic special members to be ↵Richard Smith2012-12-071-0/+26
| | | | | | defaulted. llvm-svn: 169574
* Prior to adding the new "expected-no-diagnostics" directive to ↵Andy Gibbs2012-10-198-0/+8
| | | | | | VerifyDiagnosticConsumer, make the necessary adjustment to 580 test-cases which will henceforth require this new directive. llvm-svn: 166280
* Fix directive parsing in VerifyDiagnosticConsumer so that it ensures that ↵Andy Gibbs2012-10-191-3/+3
| | | | | | | | "expected" is at the start of the word and will no longer accept typos such as "junkexpected-*" as a valid "expected-*" directive. A very few test-cases had to be amended to adhere to the new rule. Patch reviewed by David Blaikie. llvm-svn: 166279
* Tests for DR1507.Richard Smith2012-10-181-0/+14
| | | | llvm-svn: 166162
* When processing an InitListExpr and skipping the initialization of an invalidRichard Smith2012-09-281-0/+6
| | | | | | | record, skip at least one element from the InitListExpr to avoid an infinite loop if we're initializing an array of unknown bound. llvm-svn: 164851
* Promote the warning about extra qualification on a declaration from aDouglas Gregor2012-09-131-7/+7
| | | | | | | | warning to an error. C++ bans it, and both GCC and EDG diagnose it as an error. Microsoft allows it, so we still warn in Microsoft mode. Fixes <rdar://problem/11135644>. llvm-svn: 163831
* Explicitly defaulted constructors cannot be used for default initialization.Aaron Ballman2012-07-311-3/+13
| | | | llvm-svn: 161088
* Final piece of core issue 1330: delay computing the exception specification ofRichard Smith2012-07-271-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a defaulted special member function until the exception specification is needed (using the same criteria used for the delayed instantiation of exception specifications for function temploids). EST_Delayed is now EST_Unevaluated (using 1330's terminology), and, like EST_Uninstantiated, carries a pointer to the FunctionDecl which will be used to resolve the exception specification. This is enabled for all C++ modes: it's a little faster in the case where the exception specification isn't used, allows our C++11-in-C++98 extensions to work, and is still correct for C++98, since in that mode the computation of the exception specification can't fail. The diagnostics here aren't great (in particular, we should include implicit evaluation of exception specifications for defaulted special members in the template instantiation backtraces), but they're not much worse than before. Our approach to the problem of cycles between in-class initializers and the exception specification for a defaulted default constructor is modified a little by this change -- we now reject any odr-use of a defaulted default constructor if that constructor uses an in-class initializer and the use is in an in-class initialzer which is declared lexically earlier. This is a closer approximation to the current draft solution in core issue 1351, but isn't an exact match (but the current draft wording isn't reasonable, so that's to be expected). llvm-svn: 160847
* PR12670: Support for initializing an array of non-aggregate class type from anRichard Smith2012-07-071-0/+113
| | | | | | | initializer list. Patch by Olivier Goffart, with extra testcases by Meador Inge and Daniel Lunow. llvm-svn: 159896
* PR12937: Explicitly deleting an explicit template specialization.David Blaikie2012-06-251-0/+8
| | | | | | | | | | | | | | | This works around a quirk in the way that explicit template specializations are handled in Clang. We generate an implicit declaration from the original template which the explicit specialization is considered to redeclare. This trips up the explicit delete logic. This change only works around that strange representation. At some point it'd be nice to remove those extra declarations to make the AST more accurately reflect the C++ semantics. Review by Doug Gregor. llvm-svn: 159167
* Fix -Wc++11-narrowing warnings for narrowing negative values to larger unsignedRichard Smith2012-06-191-7/+7
| | | | | | types to actually includes the value, rather than saying <uninitialized>. llvm-svn: 158745
OpenPOWER on IntegriCloud