[cfe-commits] r120904 - in /cfe/trunk: lib/Sema/SemaExpr.cpp lib/Sema/SemaExprCXX.cpp test/CodeGen/exprs.c
John McCall
rjmccall at apple.com
Sat Dec 4 04:29:12 PST 2010
Author: rjmccall
Date: Sat Dec 4 06:29:11 2010
New Revision: 120904
URL: http://llvm.org/viewvc/llvm-project?rev=120904&view=rev
Log:
First pass at implementing the intent of ANSI C DR106.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/CodeGen/exprs.c
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=120904&r1=120903&r2=120904&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Dec 4 06:29:11 2010
@@ -269,6 +269,13 @@
T->isRecordType()))
return;
+ // The C standard is actually really unclear on this point, and
+ // DR106 tells us what the result should be but not why. It's
+ // generally best to say that void just doesn't undergo
+ // lvalue-to-rvalue at all.
+ if (T->isVoidType())
+ return;
+
// C++ [conv.lval]p1:
// [...] If T is a non-class type, the type of the prvalue is the
// cv-unqualified version of T. Otherwise, the type of the
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=120904&r1=120903&r2=120904&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sat Dec 4 06:29:11 2010
@@ -3549,8 +3549,9 @@
}
DefaultFunctionArrayLvalueConversion(E);
- RequireCompleteType(E->getExprLoc(), E->getType(),
- diag::err_incomplete_type);
+ if (!E->getType()->isVoidType())
+ RequireCompleteType(E->getExprLoc(), E->getType(),
+ diag::err_incomplete_type);
}
ExprResult Sema::ActOnFinishFullExpr(Expr *FullExpr) {
Modified: cfe/trunk/test/CodeGen/exprs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exprs.c?rev=120904&r1=120903&r2=120904&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/exprs.c (original)
+++ cfe/trunk/test/CodeGen/exprs.c Sat Dec 4 06:29:11 2010
@@ -147,8 +147,22 @@
}
// Check operations on incomplete types.
-struct s14;
-void f14(struct s13 *a) {
+void f14(struct s14 *a) {
(void) &*a;
}
+// CHECK: define void @f15
+void f15(void *v, const void *cv, volatile void *vv) {
+ extern void f15_helper(void);
+ f15_helper();
+ // CHECK: call void @f15_helper()
+ // FIXME: no loads from i8* should occur here at all!
+ *v; *v, *v; v ? *v : *v;
+ *cv; *cv, *cv; v ? *cv : *cv;
+ *vv; *vv, *vv; vv ? *vv : *vv;
+ // CHECK: volatile load i8*
+ // CHECK: volatile load i8*
+ // CHECK: volatile load i8*
+ // CHECK-NOT: load i8* %
+ // CHECK: ret void
+}
More information about the cfe-commits
mailing list