[cfe-commits] r147730 - in /cfe/trunk: include/clang/Sema/Sema.h lib/CodeGen/CodeGenFunction.cpp lib/Parse/ParseDecl.cpp lib/Sema/SemaDecl.cpp test/CodeGen/vla.c

Abramo Bagnara abramo.bagnara at gmail.com
Sun Jan 8 00:12:37 PST 2012


Il 08/01/2012 01:30, Eli Friedman ha scritto:
> On Sat, Jan 7, 2012 at 3:17 PM, Abramo Bagnara <abramo.bagnara at gmail.com> wrote:
>> Il 07/01/2012 21:33, Douglas Gregor ha scritto:
>>>
>>> On Jan 7, 2012, at 2:52 AM, Abramo Bagnara wrote:
>>>> +    default:
>>>> +      // Only sugared types (different from typeof_expr) can reach this point.
>>>> +      assert(!type.isCanonical() && "unhandled canonical type!");
>>>> +      type = type.getSingleStepDesugaredType(getContext());
>>>> +      break;
>>>> +
>>>> +    case Type::TypeOfExpr: {
>>>> +      // This is the only sugared type requiring special treatment.
>>>> +      // Emit typeof expression and we are done.
>>>> +      Expr *E = cast<TypeOfExprType>(ty)->getUnderlyingExpr();
>>>> +      EmitIgnoredExpr(E);
>>>> +      return;
>>>> +    }
>>>
>>> Do you also need to handle decltype?
>>
>> In C++11 7.1.6.2p4 it is written "The operand of the decltype specifier
>> is an unevaluated operand".
>>
>> But it is also true that C++11 does not have VLA (and therefore does not
>> take in account them).
>>
>> gcc 4.6.1 obey C++11 7.1.6.2p4 also for VM types.
> 
> How can you tell?

It appeared me in a dream ;-)

$ cat p.c
long f();
long g();

void m() {
  typeof((int (*)[f()])g()) x;
}

$ gcc -O2 -S p.c -o -
	.file	"p.c"
	.text
	.p2align 4,,15
	.globl	m
	.type	m, @function
m:
.LFB0:
	.cfi_startproc
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	call	f
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	jmp	g
	.cfi_endproc
.LFE0:
	.size	m, .-m
	.ident	"GCC: (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1"
	.section	.note.GNU-stack,"", at progbits
$ cat p.cc
long f();
long g();

void m() {
  __decltype((int (*)[f()])g()) x;
}

$ g++ -O2 -S p.cc -o -
	.file	"p.cc"
	.text
	.p2align 4,,15
	.globl	_Z1mv
	.type	_Z1mv, @function
_Z1mv:
.LFB0:
	.cfi_startproc
	rep
	ret
	.cfi_endproc
.LFE0:
	.size	_Z1mv, .-_Z1mv
	.ident	"GCC: (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1"
	.section	.note.GNU-stack,"", at progbits




More information about the cfe-commits mailing list