summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/class.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [CXX] Exercise all paths through these tests.Paul Robinson2019-07-091-0/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D63894 llvm-svn: 365555
* [c++20] Implement P0846R0: allow (ADL-only) calls to template-ids whoseRichard Smith2019-05-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | template name is not visible to unqualified lookup. In order to support this without a severe degradation in our ability to diagnose typos in template names, this change significantly restructures the way we handle template-id-shaped syntax for which lookup of the template name finds nothing. Instead of eagerly diagnosing an undeclared template name, we now form a placeholder template-name representing a name that is known to not find any templates. When the parser sees such a name, it attempts to disambiguate whether we have a less-than comparison or a template-id. Any diagnostics or typo-correction for the name are delayed until its point of use. The upshot should be a small improvement of our diagostic quality overall: we now take more syntactic context into account when trying to resolve an undeclared identifier on the left hand side of a '<'. In fact, this works well enough that the backwards-compatible portion (for an undeclared identifier rather than a lookup that finds functions but no function templates) is enabled in all language modes. llvm-svn: 360308
* Lit C++11 Compatibility Patch #8Charles Li2016-04-141-2/+21
| | | | | | 24 tests have been updated for C++11 compatibility. llvm-svn: 266387
* If a function decl cannot be merged, mark it as invalid.Nico Weber2015-01-171-3/+3
| | | | | | | | | | | | | | | | | | | Clang currently crashes on class C { C() = default; C() = delete; }; My cunning plan for fixing this was to change the `if (!FnD)` in Parser::ParseCXXInlineMethodDef() to `if (!FnD || FnD->isInvalidDecl)` – but alas, the second constructor decl wasn't marked as invalid. This lets Sema::MergeFunctionDecl() return true on function redeclarations, which leads to them being marked invalid. This also improves error messages when functions are redeclared. llvm-svn: 226365
* Avoid spurious error messages if parent template class cannot be instantiatedSerge Pavlov2013-08-101-5/+1
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D924 llvm-svn: 188133
* Promote the warning about extra qualification on a declaration from aDouglas Gregor2012-09-131-1/+1
| | | | | | | | 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
* Part of PR10101: after a parse error in a declaration, try harder to find theRichard Smith2012-04-111-2/+2
| | | | | | | right place to pick up parsing. In C++, this had a tendency to skip everything declared within headers if the TU starts with garbage. llvm-svn: 154530
* Improve diagnostics for invalid use of non-static members / this:Richard Smith2012-04-051-4/+6
| | | | | | | | | | | | * s/nonstatic/non-static/ in the diagnostics, since the latter form outvoted the former by 28-2 in our diagnostics. * Fix the "use of member in static member function" diagnostic to correctly detect this situation inside a block or lambda. * Produce a more specific "invalid use of non-static member" diagnostic for the case where a nested class member refers to a member of a lexically-surrounding class. llvm-svn: 154073
* Change the diagnostics which said 'accepted as an extension' to instead sayRichard Smith2011-12-291-3/+3
| | | | | | | 'is an extension'. The former is inappropriate and confusing when building with -Werror/-pedantic-errors. llvm-svn: 147357
* Modify how the -verify flag works. Currently, the verification string andRichard Trieu2011-12-151-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Make the -Wc++11-compat warnings ignored by default, so we don't breakDouglas Gregor2011-10-251-1/+1
| | | | | | | valid C++98/03 code. However, add these warnings to -Wall, for those who obviously already like clean code. llvm-svn: 142903
* Switch diagnostic text from "C++0x" over to "C++11".Douglas Gregor2011-10-121-2/+2
| | | | | | | | We'd also like for "C++11" or "c++11" to be used for the warning groups, but without removing the old warning flags. Patches welcome; I've run out of time to work on this today. llvm-svn: 141801
* Parse the initializer for a class member after handling itsDouglas Gregor2011-10-101-0/+4
| | | | | | | declarator, so that the declarator is in scope for the initializer. Fixes PR9989. llvm-svn: 141539
* Mark the ExtWarn for in-class initialization of static const float members ↵Richard Smith2011-09-291-2/+2
| | | | | | as a GNU extension. Don't extend the scope of this extension to all literal types in C++0x mode. llvm-svn: 140820
* In C++0x, static const volatile data members cannot be initialized in-class.Richard Smith2011-09-291-0/+1
| | | | llvm-svn: 140809
* constexpr: semantic checking for constexpr variables.Richard Smith2011-09-291-2/+2
| | | | | | We had an extension which allowed const static class members of floating-point type to have in-class initializers, 'as a C++0x extension'. However, C++0x does not allow this. The extension has been kept, and extended to all literal types in C++0x mode (with a fixit to add the 'constexpr' specifier). llvm-svn: 140801
* PR10458: Finesse behaviour of C++0x features when in pre-0x mode. Accept ↵Richard Smith2011-09-041-1/+1
| | | | | | for-range and auto with an ExtWarn, and produce a -Wc++0x-compat warning in C++98 mode when auto is used as a storage class. llvm-svn: 139102
* Implement support for C++11 in-class initialization of non-static data members.Richard Smith2011-06-111-1/+1
| | | | llvm-svn: 132878
* Error for use of field from anonymous struct or union should say "invalid ↵Argyrios Kyrtzidis2011-01-311-0/+12
| | | | | | | | use of nonstatic data member" not "call to non-static member function without an object argument". llvm-svn: 124576
* Better diagnostic for superfluous scope specifier inside a class definition ↵Francois Pichet2010-10-011-1/+1
| | | | | | | | | | | for member functions. + Fixit. Example: class A { void A::foo(); //warning: extra qualification on member 'foo' }; llvm-svn: 115347
* Support in-class initialization of static const floating-point data members.John McCall2010-09-101-6/+17
| | | | llvm-svn: 113663
* make clang print types as "const int *" instead of "int const*",Chris Lattner2010-09-051-1/+1
| | | | | | | which is should have done from the beginning. As usual, the most fun with this sort of change is updating all the testcases. llvm-svn: 113090
* When parsing cached C++ method declarations/definitions, save theDouglas Gregor2010-06-161-0/+6
| | | | | | | | "previous token" location at the end of the class definition. This eliminates a badly-placed error + Fix-It when the ';' following a class definition is missing. Fixes <rdar://problem/8066414>. llvm-svn: 106175
* When determining whether we can use "this", make sure to look throughDouglas Gregor2010-05-221-0/+12
| | | | | | | enum contexts (along with block contexts, which we already did). Fixes PR7196. llvm-svn: 104444
* Test that mutability of class members that involve class definitions ↵Douglas Gregor2010-05-171-0/+5
| | | | | | actually works llvm-svn: 103959
* mutable is a storage class that can follow a class/struct/union definition. ↵Douglas Gregor2010-05-171-0/+6
| | | | | | Fixes PR7153 llvm-svn: 103954
* Downgrade the "declaration does not declare anything" error to aDouglas Gregor2010-04-081-1/+1
| | | | | | | warning. It's not harmful to have such pointless declarations, and GCC does not diagnose this issue consistently. llvm-svn: 100814
* Provide a test case for PR6629.John McCall2010-03-171-0/+18
| | | | llvm-svn: 98702
* Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar2009-12-151-1/+1
| | | | | | | | | - 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
* Have the parser tell sema whether a member declaration is a function ↵Sebastian Redl2009-11-241-3/+2
| | | | | | definition. This allows sema to not emit spurious diagnostics in some invalid code. llvm-svn: 89816
* Make sure redeclaration chains are properly linked, even through invalid ↵Sebastian Redl2009-11-241-0/+9
| | | | | | decls. This fixes PR5415. llvm-svn: 89777
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Move most of the checking from ActOnCXXMemberDeclarator to other, more ↵Douglas Gregor2009-03-111-2/+2
| | | | | | general routines. This is a step toward separating the checking logic from Declarators, which in turn is required for template instantiation. llvm-svn: 66734
* Implement basic template instantiation for fields. Reshuffle checkingDouglas Gregor2009-03-111-2/+2
| | | | | | | for FieldDecls so that the parser and the template instantiation make use of the same semantic checking module. llvm-svn: 66685
* refactor C++ bitfield checking a bit (haha)Chris Lattner2009-03-051-1/+1
| | | | llvm-svn: 66213
* fix PR3607 and a fixme, by checking bitfield constraintsChris Lattner2009-03-051-2/+2
| | | | | | more consistently. llvm-svn: 66210
* Complete semantic checking for typedef redeclarations in C++. TheDouglas Gregor2009-01-281-1/+1
| | | | | | | rules are slightly different than in C, and now we handle both dialects properly. llvm-svn: 63211
* Unify the code for defining tags in C and C++, so that we alwaysDouglas Gregor2009-01-081-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | introduce a Scope for the body of a tag. This reduces the number of semantic differences between C and C++ structs and unions, and will help with other features (e.g., anonymous unions) in C. Some important points: - Fields are now in the "member" namespace (IDNS_Member), to keep them separate from tags and ordinary names in C. See the new test in Sema/member-reference.c for an example of why this matters. In C++, ordinary and member name lookup will find members in both the ordinary and member namespace, so the difference between IDNS_Member and IDNS_Ordinary is erased by Sema::LookupDecl (but only in C++!). - We always introduce a Scope and push a DeclContext when we're defining a tag, in both C and C++. Previously, we had different actions and different Scope/CurContext behavior for enums, C structs/unions, and C++ structs/unions/classes. Now, it's one pair of actions. (Yay!) There's still some fuzziness in the handling of struct/union/enum definitions within other struct/union/enum definitions in C. We'll need to do some more cleanup to eliminate some reliance on CurContext before we can solve this issue for real. What we want is for something like this: struct X { struct T { int x; } t; }; to introduce T into translation unit scope (placing it at the appropriate point in the IdentifierResolver chain, too), but it should still have struct X as its lexical declaration context. PushOnScopeChains isn't smart enough to do that yet, though, so there's a FIXME test in nested-redef.c llvm-svn: 61940
* Diagnose declarations that don't declare anything, and fix PR3020.Sebastian Redl2008-12-281-0/+4
| | | | | | | | Examples: int; typedef int; llvm-svn: 61454
* Implement effects of 'mutable', and a few comments from Chris on its parsing.Sebastian Redl2008-11-171-0/+12
| | | | llvm-svn: 59470
* Implement parsing and semantic checking of the 'mutable' keyword.Sebastian Redl2008-11-141-0/+13
| | | | | | Thanks to Doug for the review. Actual effects of mutable to follow. llvm-svn: 59331
* Sema-check virtual declarations. Complete dynamic_cast checking.Sebastian Redl2008-11-061-2/+6
| | | | llvm-svn: 58804
* Fix this bug:Argyrios Kyrtzidis2008-10-151-0/+1
| | | | | | | | | typedef int f(); struct S { f *x; // incorrectly assuming this is function decl, leading to failed assertions. }; llvm-svn: 57598
* Fix a bug that crashed clang when parsing this:Argyrios Kyrtzidis2008-10-081-0/+3
| | | | | | | | | | | | | | | | class C { static const int number = 50; static int arr[number]; }; Here's how it worked: -GetTypeForDeclarator was called from both Sema::ActOnCXXMemberDeclarator and Sema::ActOnDeclarator. -VariableArrayTypes are not uniqued so two VariableArrayTypes were created with the same DeclRefExpr. -On exit they both tried to destroy that one DeclRefExpr. The fix is not to use GetTypeForDeclarator from the Sema::ActOnCXXMemberDeclarator. llvm-svn: 57313
* Move the C++ Sema tests into a separate SemaCXX directory.Argyrios Kyrtzidis2008-08-161-0/+70
llvm-svn: 54853
OpenPOWER on IntegriCloud