]> granicus.if.org Git - clang/commitdiff
explicitly document that return statement argument does not necessarily follow the...
authorChris Lattner <sabre@nondot.org>
Wed, 6 Feb 2008 21:20:34 +0000 (21:20 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 6 Feb 2008 21:20:34 +0000 (21:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46823 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Stmt.h
test/CodeGen/statements.c

index dae7fbf49b64cd58735f55f857028804caf2a0b3..e92c4faea7ee8da77c472b427722786fd3aa48f6 100644 (file)
@@ -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;
index 46d19dbc5294c51543cda07e4c2a49b08af4e1f4..4092121393508c922e5289964c09dcef257fa4e7 100644 (file)
@@ -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; }
+