summaryrefslogtreecommitdiff
path: root/test/SemaCXX/enum.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Test] Fix test file for C++98 modeDavid Bolvansky2018-10-181-1/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@344762 91177308-0d34-0410-b5e6-96231b3b80d8
* [Diagnostics] Add missing expected warning to test fileDavid Bolvansky2018-10-181-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@344761 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sema] Error out early for tags defined inside an enumeration.Volodymyr Sapsai2017-09-151-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes PR28903 by avoiding access check for inner enum constant. We are performing access check because one enum constant references another and because enum is defined in CXXRecordDecl. But access check doesn't work because FindDeclaringClass doesn't expect more than one EnumDecl and because inner enum has access AS_none due to not being an immediate child of a record. The change detects an enum is defined in wrong place and allows to skip parsing its body. Access check is skipped together with body parsing. There was no crash in C, added test case to cover the new error. rdar://problem/28530809 Reviewers: rnk, doug.gregor, rsmith Reviewed By: doug.gregor Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D37089 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@313386 91177308-0d34-0410-b5e6-96231b3b80d8
* Explicitly permit undefined behavior in constant initializers for globalRichard Smith2015-12-081-1/+16
| | | | | | | | | variables in C, in the cases where we can constant-fold it to a value regardless (such as floating-point division by zero and signed integer overflow). Strictly enforcing this rule breaks too much code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254992 91177308-0d34-0410-b5e6-96231b3b80d8
* Pedantic diagnostic correction: in C++, we have integral constant expressions,Richard Smith2012-01-151-1/+1
| | | | | | | | | not integer constant expressions. In passing, fix the 'folding is an extension' diagnostic to not claim we're accepting the code, since that's not true in -pedantic-errors mode, and add this diagnostic to -Wgnu. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148209 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't perform integral promotions from an incompletion enumerationDouglas Gregor2010-09-121-0/+5
| | | | | | | type. Fixes PR8089 in a slightly different way than had been suggested. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113711 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix for PR7911 and PR7921: make isIntegralOrEnumerationType return falseEli Friedman2010-08-191-0/+5
| | | | | | | | | | | | | for incomplete enum types. An incomplete enum can't really be treated as an "integral or enumeration" type, and the incorrect treatment leads to bad behavior for many callers. This makes isIntegralOrEnumerationType equivalent to isIntegerType; I think we should globally replace the latter with the former; thoughts? git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111512 91177308-0d34-0410-b5e6-96231b3b80d8
* Complain when an unnamed enumeration has no enumerations (inDouglas Gregor2010-07-131-0/+4
| | | | | | | C++). Fixes PR7466. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108231 91177308-0d34-0410-b5e6-96231b3b80d8
* In C++, allow a declaration of an enum to follow a definition of thatDouglas Gregor2010-06-221-1/+3
| | | | | | | | enum as a GNU extension. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106540 91177308-0d34-0410-b5e6-96231b3b80d8
* In C++, one cannot assign from an arithmetic type to an enumerationDouglas Gregor2010-05-231-1/+9
| | | | | | | type. Fixes PR7051. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104475 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement the lvalue-to-rvalue conversion where needed. TheDouglas Gregor2010-02-031-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lvalue-to-rvalue conversion adjusts lvalues of qualified, non-class type to rvalue expressions of the unqualified variant of that type. For example, given: const int i; (void)(i + 17); the lvalue-to-rvalue conversion for the subexpression "i" will turn it from an lvalue expression (a DeclRefExpr) with type 'const int' into an rvalue expression with type 'int'. Both C and C++ mandate this conversion, and somehow we've slid through without implementing it. We now have both DefaultFunctionArrayConversion and DefaultFunctionArrayLvalueConversion, and which gets used depends on whether we do the lvalue-to-rvalue conversion or not. Generally, we do the lvalue-to-rvalue conversion, but there are a few notable exceptions: - the left-hand side of a '.' operator - the left-hand side of an assignment - a C++ throw expression - a subscript expression that's subscripting a vector Making this change exposed two issues with blocks: - we were deducing const-qualified return types of non-class type from a block return, which doesn't fit well - we weren't always setting the known return type of a block when it was provided with the ^return-type syntax Fixes the current Clang-on-Clang compile failure and PR6076. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95167 91177308-0d34-0410-b5e6-96231b3b80d8
* When looking up enumerator names for redeclaration, use theDouglas Gregor2010-01-191-0/+11
| | | | | | | | ForRedeclaration flag so that we don't look into base classes. Fixes PR6061. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93862 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix test.Eli Friedman2009-12-161-10/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91566 91177308-0d34-0410-b5e6-96231b3b80d8
* Make sure C-specific enum warning doesn't trigger in C++.Eli Friedman2009-12-161-11/+11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91563 91177308-0d34-0410-b5e6-96231b3b80d8
* 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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91446 91177308-0d34-0410-b5e6-96231b3b80d8
* First pass at implementing C++ enum semantics: calculate (and store) anJohn McCall2009-12-091-0/+30
| | | | | | | | | | | | | | | "integer promotion" type associated with an enum decl, and use this type to determine which type to promote to. This type obeys C++ [conv.prom]p2 and is therefore generally signed unless the range of the enumerators forces it to be unsigned. Kills off a lot of false positives from -Wsign-compare in C++, addressing rdar://7455616 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90965 91177308-0d34-0410-b5e6-96231b3b80d8
* When recovering from an invalid forward reference to an enum type in C++,John McCall2009-12-041-2/+2
| | | | | | | | create the enum type in the same scope as you would a record type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90500 91177308-0d34-0410-b5e6-96231b3b80d8
* Add CheckCallReturnType and start using it for regular call expressions. ↵Anders Carlsson2009-10-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This will improve error messages. For struct B; B f(); void g() { f(); } We now get t.cpp:6:3: error: calling 'f' with incomplete return type 'struct B' f(); ^~~ t.cpp:3:3: note: 'f' declared here B f(); ^ t.cpp:1:8: note: forward declaration of 'struct B' struct B; ^ git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83692 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-6/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81346 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | | Tests and drivers updated, still need to shuffle dirs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67602 91177308-0d34-0410-b5e6-96231b3b80d8
* Check that the return/argument types of calls are complete.Eli Friedman2009-03-221-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67485 91177308-0d34-0410-b5e6-96231b3b80d8
* Print the context of tag types as part of pretty-printing, e.g.,Douglas Gregor2009-03-191-3/+1
| | | | | | | | struct N::M::foo git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67284 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement the GNU semantics for forward declarations of enum types inDouglas Gregor2009-03-061-0/+15
| | | | | | | C and C++. Fixes PR3688. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66282 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix <rdar://problem/6502934>. We were creating an ImplicitCastExprDouglas Gregor2009-01-161-1/+12
| | | | | | | with reference type (it should be an lvalue with non-reference type). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62345 91177308-0d34-0410-b5e6-96231b3b80d8
* Add test of enumerator typesDouglas Gregor2008-12-121-0/+14
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60940 91177308-0d34-0410-b5e6-96231b3b80d8