Hello Rafael.
Would you mind to double-check the following change in your commit?
On 11/29/2012 05:09 PM, Rafael Espindola wrote:
Author: rafael
Date: Thu Nov 29 10:09:03 2012
New Revision: 168895
URL: http://llvm.org/viewvc/llvm-project?rev=168895&view=rev
Log:
Merge function types in C.
[...]
* Use the type from the function type in initializations, even if an
parameter
is available.
[...]
Modified: cfe/trunk/include/clang/Sema/Initialization.h
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=168895&r1=168894&r2=168895&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Initialization.h (original)
+++ cfe/trunk/include/clang/Sema/Initialization.h Thu Nov 29 10:09:03 2012
[...]
+ /// \brief Create the initialization entity for a parameter, but use
+ /// another type.
+ static InitializedEntity InitializeParameter(ASTContext &Context,
+ ParmVarDecl *Parm,
+ QualType Type) {
bool Consumed = (Context.getLangOpts().ObjCAutoRefCount &&
Parm->hasAttr<NSConsumedAttr>());
InitializedEntity Entity;
Entity.Kind = EK_Parameter;
- Entity.Type = Context.getVariableArrayDecayedType(
- Parm->getType().getUnqualifiedType());
+ Entity.Type = Context.getVariableArrayDecayedType(Type);
It seems to me that, this way, you are no longer unqualifying the
parameter type. As a consequence, I now see the following:
$ cat bug.c
void foo1(void*);
void foo2(void* const);
void bar() {
foo1(0);
foo2(0);
}
In the call foo2(0), the null pointer implicit cast converts to a const
qualified scalar rvalue, which should be forbidden; afaict, it should
produce the very same cast as for the call foo1(0):
$ clang -cc1 -ast-dump bug.c
[...]
(CallExpr 0x6310b50 <line:6:3, col:9> 'void'
(ImplicitCastExpr 0x6310b38 <col:3> 'void (*)(void *const)'
<FunctionToPointerDecay>
(DeclRefExpr 0x6310ac8 <col:3> 'void (void *const)' Function
0x62e5440 'foo2' 'void (void *const)'))
(ImplicitCastExpr 0x6310b80 <col:8> 'void *const' <NullToPointer>
(IntegerLiteral 0x6310af0 <col:8> 'int' 0))))))
Enea.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits