[cfe-commits] r41402 - in /cfe/trunk: AST/Expr.cpp test/Parser/implicit-casts.c
Steve Naroff
snaroff at apple.com
Sat Aug 25 07:37:06 PDT 2007
Author: snaroff
Date: Sat Aug 25 09:37:06 2007
New Revision: 41402
URL: http://llvm.org/viewvc/llvm-project?rev=41402&view=rev
Log:
Change Expr::isLvalue() to properly deal with ImplicitCastExpr's.
This fixes the following bug...
t.c:1:31: error: expression is not assignable
short x; void foo(char c) { x += c; }
This case, among others are now captured in implicit-casts.c.
Added:
cfe/trunk/test/Parser/implicit-casts.c
Modified:
cfe/trunk/AST/Expr.cpp
Modified: cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Expr.cpp?rev=41402&r1=41401&r2=41402&view=diff
==============================================================================
--- cfe/trunk/AST/Expr.cpp (original)
+++ cfe/trunk/AST/Expr.cpp Sat Aug 25 09:37:06 2007
@@ -302,6 +302,8 @@
if (cast<OCUVectorElementExpr>(this)->containsDuplicateElements())
return LV_DuplicateVectorComponents;
return LV_Valid;
+ case ImplicitCastExprClass: // A side-effect of our implementation.
+ return cast<ImplicitCastExpr>(this)->getSubExpr()->isLvalue();
default:
break;
}
Added: cfe/trunk/test/Parser/implicit-casts.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/implicit-casts.c?rev=41402&view=auto
==============================================================================
--- cfe/trunk/test/Parser/implicit-casts.c (added)
+++ cfe/trunk/test/Parser/implicit-casts.c Sat Aug 25 09:37:06 2007
@@ -0,0 +1,20 @@
+// RUN: clang -parse-ast-check %s
+_Complex double X;
+void test1(int c) {
+ X = 5;
+}
+void test2() {
+ int i;
+ double d = i;
+ double _Complex a = 5;
+
+ test1(a);
+ a = 5;
+ d = i;
+}
+int test3() {
+ int a[2];
+ a[0] = test3; // expected-warning{{incompatible types assigning 'int (void)' to 'int'}}
+}
+short x; void test4(char c) { x += c; }
+int y; void test5(char c) { y += c; }
More information about the cfe-commits
mailing list