[cfe-commits] r46823 - in /cfe/trunk: include/clang/AST/Stmt.h test/CodeGen/statements.c
Chris Lattner
sabre at nondot.org
Wed Feb 6 13:20:35 PST 2008
Author: lattner
Date: Wed Feb 6 15:20:34 2008
New Revision: 46823
URL: http://llvm.org/viewvc/llvm-project?rev=46823&view=rev
Log:
explicitly document that return statement argument does not necessarily follow the result type of the function. Add testcase.
Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/test/CodeGen/statements.c
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=46823&r1=46822&r2=46823&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Wed Feb 6 15:20:34 2008
@@ -722,7 +722,14 @@
};
-/// ReturnStmt - This represents a return, optionally of an expression.
+/// ReturnStmt - This represents a return, optionally of an expression:
+/// return;
+/// return 4;
+///
+/// Note that GCC allows return with no argument in a function declared to
+/// return a value, and it allows returning a value in functions declared to
+/// return void. We explicitly model this in the AST, which means you can't
+/// depend on the return type of the function and the presence of an argument.
///
class ReturnStmt : public Stmt {
Expr *RetExpr;
Modified: cfe/trunk/test/CodeGen/statements.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/statements.c?rev=46823&r1=46822&r2=46823&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/statements.c (original)
+++ cfe/trunk/test/CodeGen/statements.c Wed Feb 6 15:20:34 2008
@@ -1,9 +1,13 @@
-// RUN: clang %s -emit-llvm
+// RUN: clang < %s -emit-llvm
-void foo(int x) {
+void test1(int x) {
switch (x) {
case 111111111111111111111111111111111111111:
bar();
}
}
+// Mismatched type between return and function result.
+int test2() { return; }
+void test3() { return 4; }
+
More information about the cfe-commits
mailing list