summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/block-return.c
Commit message (Collapse)AuthorAgeFilesLines
* Consolidate header inclusion diagnosticsAlp Toker2014-07-111-1/+1
| | | | | | | Make argument orders match, unify diagnostic IDs and reword the message to be a little less saccharine. llvm-svn: 212845
* Further weaken block conversion rules to permit blocks withJohn McCall2013-03-211-0/+11
| | | | | | | | | enum return type to be converted to blocks with any integer type of the same size. rdar://13463504 llvm-svn: 177613
* Implement GCC's -Wint-to-pointer-cast.David Blaikie2012-10-161-1/+1
| | | | | | | | | | | | This implementation doesn't warn on anything that GCC doesn't warn on with the exception of templates specializations (GCC doesn't warn, Clang does). The specific skipped cases (boolean, constant expressions, enums) are open for debate/adjustment if anyone wants to demonstrate that GCC is being overly conservative here. The only really obvious false positive I found was in the Clang regression suite's MPI test - apparently MPI uses specific flag values in pointer constants. (eg: #define FOO (void*)~0) llvm-svn: 166039
* fixes the diagnostic issued in // rdar://11069896Fariborz Jahanian2012-03-211-1/+1
| | | | llvm-svn: 153217
* Allow void blocks to return witn a void expression in Fariborz Jahanian2012-03-211-2/+5
| | | | | | | c-mode to match behavior with void functions in c. Issue warning with -pedantic. // rdar://11069896 llvm-svn: 153200
* Remove the "C" in "implicitly declaring C library function" diagnosticJean-Daniel Dupas2012-01-271-1/+1
| | | | | | because all functions are not C functions (i.e. NSLog). llvm-svn: 149150
* Move block return type inference diagnostic to a common place whereFariborz Jahanian2011-12-031-2/+2
| | | | | | Function or array lvalue conversions happens. llvm-svn: 145782
* If block literal return type is not specified, return type of the block is Fariborz Jahanian2011-12-031-3/+3
| | | | | | | inferred from return types. All the return statements have to agree about the type. // rdar://10466373 llvm-svn: 145774
* Fix a block sema bug where result type of initializerFariborz Jahanian2011-02-111-1/+1
| | | | | | | | | is unqualified but its initialized is qualified. This is for c only and fixes the imm. problem. c++ is more involved and is wip. // rdar://8979379 llvm-svn: 125386
* Correct r124242 making sure function chunk that gets diagnosed is really ↵Argyrios Kyrtzidis2011-01-261-0/+1
| | | | | | | | about the block. Clairvoyance by John! llvm-svn: 124264
* Change error "function cannot return array type" -> "blocks cannot return ↵Argyrios Kyrtzidis2011-01-251-1/+1
| | | | | | | | array type" when blocks are involved. Addresses rdar://8876238. llvm-svn: 124242
* Refactor the application of type attributes so that attributes fromJohn McCall2011-01-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | the declaration-specifiers and on the declarator itself are moved to the appropriate declarator chunk. This permits a greatly simplified model for how to apply these attributes, as well as allowing a much more efficient query for the GC attribute. Now all qualifier queries follow the same basic strategy of "local qualifiers, local qualifiers on the canonical type, then look through arrays". This can be easily optimized by changing the canonical qualified-array-type representation. Do not process type attributes as decl attributes on declarations with declarators. When computing the type of a block, synthesize a prototype function declarator chunk if the decl-spec type was not a function. This simplifies the logic for building block signatures. Change the logic which inserts an objc_read_weak on a block literal to only fire if the block has a __weak __block variable, rather than if the return type of the block is __weak qualified, which is not actually a sensible thing to ask. llvm-svn: 122871
* make clang print types as "const int *" instead of "int const*",Chris Lattner2010-09-051-4/+4
| | | | | | | 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
* Get rid of the "functions declared 'noreturn' should have a 'void' result ↵Anders Carlsson2010-09-031-2/+2
| | | | | | | | | type" warning. The rationale behind this is that it is normal for callback functions to have a non-void return type and it should still be possible to mark them noreturn. (JavaScriptCore is a good example of this). llvm-svn: 112918
* Add warning for functions/blocks that have attribute 'noreturn' but return a ↵Ted Kremenek2010-08-191-2/+2
| | | | | | non-void result. (<rdar://problem/7562925>) llvm-svn: 111492
* Wire up '-Wignored-qualifiers' to the warning on 'const' in 'const int f()'.Chandler Carruth2010-07-141-3/+2
| | | | | | | | | This flag and warning match GCC semantics. Also, move it to -Wextra as this is a largely cosmetic issue and doesn't seem to mask problems. Subsequent fixes to the tests which no longer by default emit the warning. Added explicit test cases for both C and C++ behavior with the warning turned on. llvm-svn: 108325
* When forming a function call or message send expression, be sure toDouglas Gregor2010-07-131-2/+5
| | | | | | | | | | | | | | | | | strip cv-qualifiers from the expression's type when the language calls for it: in C, that's all the time, while C++ only does it for non-class types. Centralized the computation of the call expression type in QualType::getCallResultType() and some helper functions in other nodes (FunctionDecl, ObjCMethodDecl, FunctionType), and updated all relevant callers of getResultType() to getCallResultType(). Fixes PR7598 and PR7463, along with a bunch of getResultType() call sites that weren't stripping references off the result type (nothing stripped cv-qualifiers properly before this change). llvm-svn: 108234
* Improve diagnostics like "initializing <type> from an expression ofDouglas Gregor2010-04-091-5/+5
| | | | | | | type..." with "initializing <type> with an expression of type...", which reads better. Thanks to John for the improved wording. llvm-svn: 100873
* Improve diagnostics when we fail to convert from a source type to aDouglas Gregor2010-04-091-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | destination type for initialization, assignment, parameter-passing, etc. The main issue fixed here is that we used rather confusing wording for diagnostics such as t.c:2:9: warning: initializing 'char const [2]' discards qualifiers, expected 'char *' [-pedantic] char *name = __func__; ^ ~~~~~~~~ We're not initializing a 'char const [2]', we're initializing a 'char *' with an expression of type 'char const [2]'. Similar problems existed for other diagnostics in this area, so I've normalized them all with more precise descriptive text to say what we're initializing/converting/assigning/etc. from and to. The warning for the code above is now: t.c:2:9: warning: initializing 'char *' from an expression of type 'char const [2]' discards qualifiers [-pedantic] char *name = __func__; ^ ~~~~~~~~ Fixes <rdar://problem/7447179>. llvm-svn: 100832
* Implement the lvalue-to-rvalue conversion where needed. TheDouglas Gregor2010-02-031-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* add a bunch of missing prototypes to testsChris Lattner2010-01-091-0/+1
| | | | llvm-svn: 93072
* 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
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-2/+2
| | | | llvm-svn: 81346
* reject returning a block expr even when it has parens and casts in the way.Chris Lattner2009-09-081-0/+2
| | | | llvm-svn: 81176
* Use QualType to represent block's implicit return type asFariborz Jahanian2009-06-191-0/+24
| | | | | | to not lose its 'const/volatile' qualifier. llvm-svn: 73795
* Fixup Sema and CodeGen for block literal attributes when the returnMike Stump2009-04-291-1/+2
| | | | | | | | type and argument types are missing, and let return type deduction happen before we give errors for returning from a noreturn block. Radar 6441502 llvm-svn: 70413
* Sema and CodeGen support for attributes on blocks. Radar 6441502Mike Stump2009-04-291-0/+6
| | | | llvm-svn: 70403
* Don't allow blocks to be declared as returning an array. Radar 6441502Mike Stump2009-04-281-0/+3
| | | | llvm-svn: 70277
* Tighten up blocks type checking. This was discussed back in theMike Stump2009-04-211-4/+4
| | | | | | r56595 timeframe, but left undone. Radar 6812711 llvm-svn: 69745
* Fixup semantic analysis for nested blocks, and allow block literalMike Stump2009-04-171-2/+11
| | | | | | | expressions that can be of static duration to be returned. Radar 6786551 llvm-svn: 69331
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Extend builtin "attribute" syntax to include a notation forDouglas Gregor2009-02-141-1/+2
| | | | | | | | | | | | | | | | | | | | | printf-like functions, both builtin functions and those in the C library. The function-call checker now queries this attribute do determine if we have a printf-like function, rather than scanning through the list of "known functions IDs". However, there are 5 functions they are not yet "builtins", so the function-call checker handles them specifically still: - fprintf and vfprintf: the builtins mechanism cannot (yet) express FILE* arguments, so these can't be encoded. - NSLog: the builtins mechanism cannot (yet) express NSString* arguments, so this (and NSLogv) can't be encoded. - asprintf and vasprintf: these aren't part of the C99 standard library, so we really shouldn't be defining them as builtins in the general case (and we don't seem to have the machinery to make them builtins only on certain targets and depending on whether extensions are enabled). llvm-svn: 64512
* Add support for blocks with explicit return types.Mike Stump2009-02-041-15/+14
| | | | llvm-svn: 63784
* instead of forcing blocks on by default, make them default to off, but letChris Lattner2008-12-041-1/+1
| | | | | | | | specific targets default them to on. Default blocks to on on 10.6 and later. Add a -fblocks option that allows the user to override the target's default. Use -fblocks in the various testcases that use blocks. llvm-svn: 60563
* Fix <rdar://problem/6252216> compare block to NULL.Steve Naroff2008-09-281-1/+4
| | | | llvm-svn: 56764
* Fix <rdar://problem/6252226> parser thinks block argument is undefined ↵Steve Naroff2008-09-281-0/+2
| | | | | | identifier in NSServices.m llvm-svn: 56761
* Downgrade incompatible block pointer error to a warning (to be consistent ↵Steve Naroff2008-09-241-3/+11
| | | | | | with incompatible pointer warnings in general). llvm-svn: 56595
* Fix <rdar://problem/6243788> clang: Incorrect return statement for Blocks?Steve Naroff2008-09-241-0/+20
| | | | llvm-svn: 56590
* Sema::ActOnBlockReturnStmt(): Need to perform the UsualUnaryConversions on ↵Steve Naroff2008-09-161-0/+52
the return type. Sema::CheckReturnStackAddr(): Make sure we skip over implicit casts. Added some more test cases... llvm-svn: 56254
OpenPOWER on IntegriCloud