]> granicus.if.org Git - clang/commit
In blocks, only pretend that enum constants have enum type if necessary.
authorJordan Rose <jordan_rose@apple.com>
Mon, 2 Jul 2012 21:19:23 +0000 (21:19 +0000)
committerJordan Rose <jordan_rose@apple.com>
Mon, 2 Jul 2012 21:19:23 +0000 (21:19 +0000)
commit7dd900ed308506f9cf1cb72c70db1652f94cab37
tree3dc75707934b1fab99a0a36e62e3d312c7ae1bfb
parentb135f0f2d893121ed2cc46d4d6c5bd5ab87d872f
In blocks, only pretend that enum constants have enum type if necessary.

In C, enum constants have the type of the enum's underlying integer type,
rather than the type of the enum. (This is not true in C++.) Thus, when a
block's return type is inferred from an enum constant, it is incompatible
with expressions that return the enum type.

In r158899, I told block returns to pretend that enum constants have enum
type, like in C++. Doug Gregor pointed out that this can break existing code.

Now, we don't check the types of return statements until the end of the block.
This lets us go back and add implicit casts in blocks with mixed enum
constants and enum-typed expressions.

<rdar://problem/11662489> (again)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159591 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Sema/ScopeInfo.h
include/clang/Sema/Sema.h
lib/Sema/SemaDecl.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaLambda.cpp
lib/Sema/SemaStmt.cpp
test/SemaObjC/blocks.m