summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/enum.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [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 llvm-svn: 313386
* 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. llvm-svn: 254992
* 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. llvm-svn: 148209
* 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. llvm-svn: 113711
* 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? llvm-svn: 111512
* Complain when an unnamed enumeration has no enumerations (inDouglas Gregor2010-07-131-0/+4
| | | | | | C++). Fixes PR7466. llvm-svn: 108231
* In C++, allow a declaration of an enum to follow a definition of thatDouglas Gregor2010-06-221-1/+3
| | | | | | enum as a GNU extension. llvm-svn: 106540
* In C++, one cannot assign from an arithmetic type to an enumerationDouglas Gregor2010-05-231-1/+9
| | | | | | type. Fixes PR7051. llvm-svn: 104475
* 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. llvm-svn: 95167
* 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. llvm-svn: 93862
* Fix test.Eli Friedman2009-12-161-10/+1
| | | | llvm-svn: 91566
* Make sure C-specific enum warning doesn't trigger in C++.Eli Friedman2009-12-161-11/+11
| | | | llvm-svn: 91563
* 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
* 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 llvm-svn: 90965
* 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. llvm-svn: 90500
* 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; ^ llvm-svn: 83692
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-6/+5
| | | | llvm-svn: 81346
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Check that the return/argument types of calls are complete.Eli Friedman2009-03-221-2/+2
| | | | llvm-svn: 67485
* Print the context of tag types as part of pretty-printing, e.g.,Douglas Gregor2009-03-191-3/+1
| | | | | | struct N::M::foo llvm-svn: 67284
* Implement the GNU semantics for forward declarations of enum types inDouglas Gregor2009-03-061-0/+15
| | | | | | C and C++. Fixes PR3688. llvm-svn: 66282
* 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). llvm-svn: 62345
* Add test of enumerator typesDouglas Gregor2008-12-121-0/+14
llvm-svn: 60940
OpenPOWER on IntegriCloud