| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Submitted by:
Reviewed by:
Two vector fixes:
- Sema::CheckAssignmentConstraints() needs to compare the canonical type.
- Expr::isLvalue() needs to disallow subscripting into a vector returned by a function. This
follows the rules for struct returns (in C, at least...C++ is another story:-)
Here is an example...
float4 float4_return()
{
float4 xx;
return xx;
}
void add_float4_void_return(float4 *a, float4 *b, float4 *result)
{
float f;
float4_return()[1] = f; // now illegal
}
llvm-svn: 39728
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Submitted by:
Reviewed by:
Typechecking support for vectors...
- Added CheckVectorOperands(). Called from CheckAdditionOperands,
CheckMultiplyDivideOperands, CheckSubstractionOperands, and CheckBitwiseOperands.
- Added diagnostic for converting vector values of different size.
- Modified Type::isArithmeticType to include vectors.
Sould be ready for Chris to add code generation. I will continue testing/refining.
llvm-svn: 39717
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Submitted by:
Reviewed by:
- Finished semantic analysis for vectors, added some diagnostics.
- Added AST for vectors (instantiation, installation into the decl).
- Fixed bug in ParseArraySubscriptExpr()...this crasher was introduced by me
when we added the range support.
- Turned pedantic off by default. Since vectors are gcc extensions, having
pedantic on by default was annoying. Turning it off by default is also
consistent with gcc (but this wasn't my primary motivation).
- Tweaked some comments and diagnostics.
Note: The type checking code is still under construction (for vectors). This
will be my next check-in.
llvm-svn: 39715
|
|
|
|
|
|
| |
some ivars to more obvious names, eliminating some comments.
llvm-svn: 39685
|
|
|
|
| |
llvm-svn: 39684
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
this produces:
warn.c:4:3: warning: expression result unused
X == Y;
^~~~~~
warn.c:5:3: warning: expression result unused
(void)X;
^~~~~~~
warn.c:11:3: warning: expression result unused
A == foo(1, 2);
^~~~~~~~~~~~~~
warn.c:13:3: warning: expression result unused
foo(1,2)+foo(4,3);
^~~~~~~~~~~~~~~~~
llvm-svn: 39682
|
|
|
|
|
|
| |
types.
llvm-svn: 39672
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
out of the llvm namespace. This makes the clang namespace be a sibling of
llvm instead of being a child.
The good thing about this is that it makes many things unambiguous. The
bad things is that many things in the llvm namespace (notably data structures
like smallvector) now require an llvm:: qualifier. IMO, libsystem and libsupport
should be split out of llvm into their own namespace in the future, which will fix
this issue.
llvm-svn: 39659
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
int test(int X, short Y, float Z) {
return (int)(X*Y+Z);
}
to:
define i32 @test(i32 %X, i16 %Y, float %Z) {
entry:
%promote = sext i16 %Y to i32 ; <i32> [#uses=1]
%mul = mul i32 %promote, %X ; <i32> [#uses=1]
%promote3 = sitofp i32 %mul to float ; <float> [#uses=1]
%add = add float %promote3, %Z ; <float> [#uses=1]
%conv = fptosi float %add to i32 ; <i32> [#uses=1]
ret i32 %conv
}
with:
$ clang -emit-llvm t.c | llvm-as | opt -std-compile-opts | llvm-dis
llvm-svn: 39652
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
void printutf8(unsigned int X) {
if (X <= 127)
printf("%c", (char)X);
else if (X <= 2047)
printf("%d %d ", 128 + 64 + (X >> 6), 128 + (X & ((1 << 6) - 1)));
else if (X <= 65535)
printf("%c%c%c", 128 + 64 + 32 + (X >> 12), 128 + ((X >> 6) & 63), 128 + (X & 63));
else
printf("UNKNOWN %d\n", X);
instead of:
if (X <= 127)
printf("%c", (char)X);
else
if (X <= 2047)
printf("%d %d ", 128 + 64 + (X >> 6), 128 + (X & ((1 << 6) - 1)));
else
if (X <= 65535)
printf("%c%c%c", 128 + 64 + 32 + (X >> 12), 128 + ((X >> 6) & 63), 128 + (X & 63));
else
printf("UNKNOWN %d\n", X);
llvm-svn: 39648
|
|
|
|
| |
llvm-svn: 39645
|
|
|
|
| |
llvm-svn: 39644
|
|
|
|
|
|
|
|
|
|
| |
Submitted by:
Reviewed by:
Lot's of attribute scaffolding.
Modernized ParseArraySubscriptExpr...call DefaultFunctionArrayConversion (which
simplified the logic considerably) and upgrade Diags to use the range support.
llvm-svn: 39628
|
|
|
|
|
|
|
|
|
|
|
| |
declspecs,
like: int X, Y, Z;
This is required for the code gen to get to all of the declarations in a
DeclStmt, and should simplify some other code.
llvm-svn: 39623
|
|
|
|
| |
llvm-svn: 39618
|
|
|
|
| |
llvm-svn: 39617
|
|
|
|
| |
llvm-svn: 39610
|
|
|
|
|
|
| |
stmts prettier etc
llvm-svn: 39592
|
|
|
|
| |
llvm-svn: 39588
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
check canonical types in a few places. Tighten up VerifyConstantArrayType
to diagnose more errors, now that we can evaluate i-c-e's. Add some fixmes
about poor diagnostics.
We now correctly typecheck this example:
void s(void) {
typedef int a[(int) +1.0];
static a b; // invalid, static VLA
static int c[(int) +1.0]; // invalid, static VLA
}
void t(void) {
typedef int a[(int)1.0];
static a b; // valid, constant size
}
void u() {
static int X[-1];
static int Y[0];
}
producing:
static-vla.c:3:12: error: variable length array declared outside of any function
static a b; // invalid, static VLA
^
static-vla.c:5:14: error: variable length array declared outside of any function
static int c[(int) +1.0]; // invalid, static VLA
^ ~~~~~~~~~~
static-vla.c:15:14: error: array size is negative
static int X[-1];
^ ~~
static-vla.c:16:14: warning: zero size arrays are an extension
static int Y[0];
^ ~
llvm-svn: 39587
|
|
|
|
|
|
| |
on complete types.
llvm-svn: 39586
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
1. Compute and return the value of the i-c-e if the expression is one.
2. Use this computation to correctly track whether subexprs are being
evaluated, and use this to guide diagnostics appropriately.
This allows us to correctly handle all the cases in:
void bar() {
int foo();
switch (1) {
case 1 ? 0 : foo(): // bad
case 0 ? 0 : foo(): // bad
case 0 ? 1/0 : 14 : // ok
case 1 ? 1/0 : 14 : // bad
;
}
switch (1) {
case 1 ? 2: (2, 3): // ok
case 0 ? 2: (2, 3): // invalid comma.
;
}
}
This code has numerous todo items. Specifically, we need to:
1. Pass in target info, so we know the size of the integers we are producing.
2. Model type sizes and alignments correctly, so we can eval sizeof/alignof
3. Handle promotions (need to talk to steve about this).
4. Return an enum that can be used to better diagnose problems with i-c-e's.
instead of just saying "this isn't valid" we should be able to say why.
5. Various other miscellanea, like handling enums and character literals
properly.
llvm-svn: 39585
|
|
|
|
|
|
|
| |
isConstantExpr into just isIntegerConstantExpr in preparation for other
changes.
llvm-svn: 39584
|
|
|
|
| |
llvm-svn: 39583
|
|
|
|
| |
llvm-svn: 39578
|
|
|
|
|
|
|
|
|
|
| |
'char', which varies based on the target.
Instead of spreading target knowledge throughout the compiler, bifurcate char
into Char_S and Char_U, and have ASTContext create the right one based on the
target, when it starts up.
llvm-svn: 39577
|
|
|
|
|
|
|
|
|
| |
Reviewed by: Chris Lattner
- Added a method to determine if two types, where at least one is a
reference, are compatible. That is you can assign the RHS to the LHS.
llvm-svn: 39566
|
|
|
|
| |
llvm-svn: 39563
|
|
|
|
| |
llvm-svn: 39556
|
|
|
|
|
|
| |
of one by reference, making it optional.
llvm-svn: 39552
|
|
|
|
|
|
|
|
|
|
|
| |
We now print:
extern void blah();
as:
void (blah)();
Strange, but ok :)
llvm-svn: 39549
|
|
|
|
|
|
|
|
| |
Submitted by:
Reviewed by:
Add implemention file for GCC attributes
llvm-svn: 39542
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Submitted by:
Reviewed by:
Implement support for GCC __attribute__.
- Implement "TODO" in Parser::ParseAttributes. Changed the return type from
void to Parser::DeclTy. Changed all call sites to accept the return value.
- Added Action::ParseAttribute and Sema::ParseAttribute to return an
appropriate AST node. Added new node AttributeDecl to Decl.h.
Still to do...hook up to the Decl...
llvm-svn: 39539
|
|
|
|
| |
llvm-svn: 39538
|
|
|
|
| |
llvm-svn: 39537
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
a = b;
{
int c;
c = a + b;
int d;
d++;
}
int e;
instead of:
a = b;
{
int c;
c = a + b;
int d;
d++;
} int e;
llvm-svn: 39535
|
|
|
|
| |
llvm-svn: 39531
|
|
|
|
|
|
|
|
|
|
|
|
| |
Submitted by:
Reviewed by:
- ParseForStatement(): Put back a test/assignment. My removal of
ParseExprStmt() was a bit over zealous:-(thanks to Chris for pointing it out)
- Add assert to VisitDeclStmt().
- Removed an out-of-date FIXME
- Added some curlies for a couple multi-line calls to Diag().
llvm-svn: 39528
|
|
|
|
| |
llvm-svn: 39521
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Submitted by:
Reviewed by:
Implement some FIXME's that stand in the way of fully typechecking "for"
statements. This involved:
- Adding a DeclStmt AST node (with statement visitor). The DeclStmt
printer is preliminary.
- Added a ParseDeclStmt action, called from Parser::ParseForStatement()
and Parser::ParseStatementOrDeclaration(). DID NOT add to
Parser::ParseIdentifierStatement()...probably could have, however didn't
really understand the context of this rule (will speak with Chris).
- Removed ParseExprStmt (and it's clients)...it was vestigial.
llvm-svn: 39518
|
|
|
|
| |
llvm-svn: 39510
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
the label identifier. Handle fwd references etc. This allows us to detect
uses of undefined labels and label redefinitions, such as:
t.c:2:12: error: redefinition of label 'abc'
abc: ; abc:
^
t.c:2:3: error: previous definition is here
abc: ; abc:
^
t.c:12:12: error: use of undeclared label 'hijl'
goto hijl;
^
llvm-svn: 39509
|
|
|
|
| |
llvm-svn: 39507
|
|
|
|
| |
llvm-svn: 39505
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Submitted by:
Reviewed by:
- Added type checking to Sema::ParseReturnStmt (still under construction).
- Improved Expr::isLvalue() and Expr::isModifiableLvalue() to return more
info. Used the info in Sema::CheckAssignmentOperands() to produce more
descriptive diagnostics. Added FIXME to other clients of isLvalue()/etc.
- Added a SourceLocation slot to MemberExpr...changed the implementation
of getSourceRange().
- Added getResultType() helper to FunctionDecl.
- Changed many Diag calls to use the SourceRange support (now that it's
a big hit...we better milk it:-).
llvm-svn: 39501
|
|
|
|
|
|
|
|
|
| |
Submitted by: Bill Wendling
Reviewed by:
- Can do just a 'cast<>()' because we're checking that it's Tagged.
llvm-svn: 39500
|
|
|
|
|
|
|
|
|
|
| |
Submitted by: Bill Wendling
Reviewed by: Steve Naroff
- Steve suggested avoiding the dyn_cast by using the "Tagged" type class
and having the "default" just return false.
llvm-svn: 39499
|
|
|
|
|
|
|
|
|
|
|
| |
Submitted by: Bill Wendling
Reviewed by: Chris Lattner
- Rework the isDerivedType method so that if a language doesn't support
references, it won't have to pay the price for them. This inlines the
checks for derived types and turns it into a switch statement instead.
llvm-svn: 39498
|
|
|
|
|
|
|
|
|
|
|
| |
Submitted by: Bill Wendling
Reviewed by: Chris Lattner
- Initial support for C++ references. Adding to the AST and Parser.
Skeletal support added in the semantic analysis portion. Full semantic
analysis is to be done soon.
llvm-svn: 39496
|
|
|
|
|
|
| |
constants.
llvm-svn: 39493
|