Add checks about references to non-lvalues.

Both ReturnStmt and DeclStmt now check the values being associated
with references to make sure that they are legal (e.g. it's illegal
to assign a varying lvalue, or a compile-time constant to a reference
type).  Previously we didn't catch this and would end up hitting
assertions in LLVM when code did this stuff.

Mostly fixes issue #225 (except for adding a FAQ about what this
error message means.)
This commit is contained in:
Matt Pharr
2012-04-04 05:56:22 -07:00
parent 637d076e99
commit c27418da77
9 changed files with 83 additions and 14 deletions

6
stmt.h
View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2010-2011, Intel Corporation
Copyright (c) 2010-2012, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -265,7 +265,7 @@ public:
statement in the program. */
class ReturnStmt : public Stmt {
public:
ReturnStmt(Expr *v, bool cc, SourcePos p);
ReturnStmt(Expr *e, bool cc, SourcePos p);
void EmitCode(FunctionEmitContext *ctx) const;
void Print(int indent) const;
@@ -273,7 +273,7 @@ public:
Stmt *TypeCheck();
int EstimateCost() const;
Expr *val;
Expr *expr;
/** This indicates whether the generated code will check to see if no
more program instances are currently running after the return, in
which case the code can possibly jump to the end of the current