aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/AST/Stmt.h9
-rw-r--r--test/CodeGen/statements.c8
2 files changed, 14 insertions, 3 deletions
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index dae7fbf49b..e92c4faea7 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -722,7 +722,14 @@ public:
};
-/// 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;
diff --git a/test/CodeGen/statements.c b/test/CodeGen/statements.c
index 46d19dbc52..4092121393 100644
--- a/test/CodeGen/statements.c
+++ b/test/CodeGen/statements.c
@@ -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; }
+