aboutsummaryrefslogtreecommitdiff
path: root/Sema
AgeCommit message (Collapse)Author
2007-08-30Fix 80 col violations.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41611 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-30Fix a regression on test/Sema/unused-expr.c by fixing the type predicatesChris Lattner
to test for the right type class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41601 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-30Fix the following redefinition errors submitted by Keith Bauer...Steve Naroff
[dylan:~/llvm/tools/clang] admin% cat tentative_decls.c // incorrectly generates redefinition error extern int array[3]; int array[3]; // incorrectly generates a redefinition error extern void nup(int a[3]); void nup(int a[3]) {} It turns out that this exposed a fairly major flaw in the type system, array types were never getting uniqued! This is because all array types contained an expression, which aren't unique. To solve this, we now have 2 array types, ConstantArrayType and VariableArrayType. ConstantArrayType's are unique, VAT's aren't. This is a fairly extensive set of fundamental changes. Fortunately, all the tests pass. Nevertheless, there may be some collateral damage:-) If so, let me know! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41592 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-29Spaces not tabs.Neil Booth
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41582 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-29Ensure we diagnose long long literals in C90 mode.Neil Booth
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41581 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-29Added checking (during parsing) of comparison of floating point values using ↵Ted Kremenek
== or !=. This is the same functionality gcc provides via --Wfloat-equal. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41574 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-29Implement GCC-compatible layout and typing of enum constants and enum decl. Chris Lattner
A small bit of codegen work is still pending. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41571 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-29Fix a null dereference Neil ran intoChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41564 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28Implement default argument promotions (for old-style function calls and ↵Steve Naroff
variable argument lists). [dylan:~/llvm/tools/clang] admin% cat x.c int printf(const char *, ...); int oldschool(); void foo() { float f; short i; printf("foo %f", 1.0f); oldschool(f,i); } [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang x.c -parse-ast-dump int printf(char const *, ...); int oldschool(); void foo() (CompoundStmt 0x3105f00 (DeclStmt 0x3105ba0 0x3105ce0 "float f") (DeclStmt 0x3105c90 0x3105d10 "short i") (CallExpr 0x3105df0 'int' (ImplicitCastExpr 0x3105dc0 'int (*)(char const *, ...)' (DeclRefExpr 0x3105c20 'int (char const *, ...)' Decl='printf' 0x3105bd0)) (ImplicitCastExpr 0x3105dd0 'char const *' (StringLiteral 0x3105d60 'char *' "foo %f")) (ImplicitCastExpr 0x3105de0 'double' (FloatingLiteral 0x3105d80 'float' 1.000000))) (CallExpr 0x3105ed0 'int' (ImplicitCastExpr 0x3105ea0 'int (*)()' (DeclRefExpr 0x3105e20 'int ()' Decl='oldschool' 0x3105c40)) (ImplicitCastExpr 0x3105eb0 'double' (DeclRefExpr 0x3105e40 'float' Decl='f' 0x3105ce0)) (ImplicitCastExpr 0x3105ec0 'int' (DeclRefExpr 0x3105e60 'short' Decl='i' 0x3105d10)))) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41558 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28Finish converting decls over to the new invalid decl API.Steve Naroff
Also removed an old FIXME (FIXME: "auto func();" passes through...). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41555 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28Move the "invalid decl" idiom up to Decl (where we have some bits to steal:-)Steve Naroff
Converted ParmVarDecl, FileVarDecl, BlockVarDecl, and Sema::ParseIdentifierExpr() to use the idiom. Updated array-constraint.c to make sure we no longer get "undeclared identifier" errors:-) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41552 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28Emit a slightly better warning for unused values for unary and binary operators:Chris Lattner
t2.c:3:18: warning: expression result unused x = ++x, ++y, y+2; ~~~~~~~~~~~~^ ~~~ git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41551 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28add a sourcelocation to binary operator to keep track of the location of the ↵Chris Lattner
operator. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41550 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28Change EnumDecl to store its corresponding integer type Chris Lattner
directly in it. Remove TargetInfo::getEnumPolicy, as there is only one policy that we support right now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41548 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28Fixed return-of-stack-address checker to correctly handle stack/globalTed Kremenek
variables that have a pointer type, or arrays that contain pointers. This fixes a crash on the following code: int *h[3]; int **foo(int i) { return &(h[i]); } This bug was reported by Keith Bauer (thanks!). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41546 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28extwarn about VLAs in C89 mode.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41545 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28c++'0x has long long also.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41544 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28warn about long long when in c89 mode.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41543 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28fix 80 col violationChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41533 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28compute the required destination type for an enum, emitting various warnings.Chris Lattner
TODO: update the types of the constants and the enum. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41532 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28add a diagnostic:Chris Lattner
t.c:1:12: warning: ISO C restricts enumerator values to range of 'int' (180388626432 is too large) enum e {A, B = 42LL << 32, C = -4, D = 12456 }; ^ git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41530 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28move a todoChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41528 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28now that all the infrastructure is in place, enforce C99 6.8.5p3.Chris Lattner
Note the FIXME: we need some way to mark a decl erroneous :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41524 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28If the condition of a for statement is promoted, make sure theChris Lattner
implicit cast gets linked back into the AST. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41523 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28Implement more thoughful error recovery when dealing with bogus declarator ↵Steve Naroff
types. For example, the following code was resulting in spurious warnings. This was the result of Sema::GetTypeForDeclarator() synthesizing a type to hand back to the caller (in this case, "int []", instead of "struct s[]", which is invalid). struct s; struct s* t (struct s z[]) { // expected-error {{array has incomplete element type}} return z; } Strategy: Flag the error in Declarator/DeclaratorChunk. This info is later stored in the ParmVarDecl. If the decl is referenced, Sema::ParseIdentifierExpr() will check if the type is invalid. If so, it quietly returns "true", without instantiating a DeclRefExpr. This seems to work nicely. If Chris is happy with the approach, I will generalize this to all VarDecls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41521 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-27Some minor aesthetic changes to the control flow.Steve Naroff
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41517 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-27Fix remaining bugs with complex/float promotions.Steve Naroff
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41515 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-27Fix a few enum-related fixme'sChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41513 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-27better error recovery for non-i-c-e enum constants.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41499 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-27Updated checker for "return of address of stack variable" to look forTed Kremenek
implicit casts from T to T& at the topmost part of the return-value expression. This checking may be needed within EvalAddr later on. We'll wait until test cases show this kind of logic is necessary (as more C++ features are implemented in clang). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41493 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-27Replaced ASTContext::maxFloatingType() with ASTContext::compareFloatingType().Steve Naroff
Changed Sema::UsualArithmeticConversions to use the new API. This fixes the following case... _Complex double X; double y; void foo() { X = X + y; } [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang complex.c -parse-ast-dump Read top-level variable decl: 'X' Read top-level variable decl: 'y' void foo() (CompoundStmt 0x2605cc0 (BinaryOperator 0x2605ca0 '_Complex double' '=' (DeclRefExpr 0x2605c10 '_Complex double' Decl='X' 0x2605ab0) (BinaryOperator 0x2605c80 '_Complex double' '+' (DeclRefExpr 0x2605c30 '_Complex double' Decl='X' 0x2605ab0) (ImplicitCastExpr 0x2605c70 '_Complex double' (DeclRefExpr 0x2605c50 'double' Decl='y' 0x2605ae0))))) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41483 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-27extwarn about decls intermixed with code in c89 mode.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41477 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-27Add Type::getAsBuiltinType() and Type::builtinTypesAreCompatible().Steve Naroff
Modified Type::typesAreCompatible() to use the above. This fixes the following bug submitted by Keith Bauer (thanks!). int equal(char *a, const char *b) { return a == b; } Also tweaked Sema::CheckCompareOperands() to ignore the qualifiers when comparing two pointer types (though it doesn't relate directly to this bug). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41476 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-27Replaced ASTContext::maxComplexType() with ↵Steve Naroff
ASTContext::getFloatingTypeOfSizeWithinDomain(). Changed Sema::UsualArithmeticConversions to correctly implement complex/float conversions, using maxFloatingType() with getFloatingTypeOfSizeWithinDomain(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41474 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-27implement a fixme: __extension__ marker on decls in compound stmts.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41473 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-26Fix %p format checking, patch by Keith Bauer.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41454 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-26For warnings like this:Chris Lattner
t.c:3:9: warning: invalid conversion '%B' printf("%B\a\n", p); ~~~~~~ ^ Don't beep the console or print the newline. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41453 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-26Fix a bug reported by Keith BauerChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41452 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-26Fix bogus warnings (noticed by Chris) with array-constraints.c.Steve Naroff
Remove bogus type conversions in Sema::GetTypeForDeclarator(). This commit only deals with the array types (DeclaratorCheck::Array), though the rest of this routine should be reviewed. Given the complexity of C declarators, I don't want to change the entire routine now (will discuss with Chris tomorrow). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41443 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-26Break the assumption that any sort of scope (e.g. a loop scope) can Chris Lattner
hold declarations. Instead, introduce a new "DeclScope" scope type that holds them explicitly. For now, all scopes have this bit, but in the future we can use them to fix some issues Neil noticed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41431 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-26require that operands to __real/__imag are complex or arithmetic. ThisChris Lattner
fixes GCC PR33193 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41428 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-26Make parse-ast-print print the storage class and inline Chris Lattner
specifier of functions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41416 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-26add a new ImaginaryLiteral AST node that is used toChris Lattner
represent imaginary literals: float _Complex A; void foo() { A = 1.0iF; } generates: (BinaryOperator 0x2305ec0 '_Complex float' '=' (DeclRefExpr 0x2305e60 '_Complex float' Decl='A' 0x2305cf0) (ImaginaryLiteral 0x2305f40 '_Complex float' (FloatingLiteral 0x2305ea0 'float' 1.000000)))) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41413 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-261.0 is double, 1.0F is a float.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41412 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-26merge checkrelational and checkequality into CheckCompareOperands, Chris Lattner
to merge duplicate code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41410 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-26Cases like this:Chris Lattner
char *C; C != ((void*)0); Should not warn about incompatible pointer types. Also, make sure to insert an implicit conversion even if the operand is null. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41408 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-25Surpress the UsualUnaryConversions for compound assignment operators. This ↵Steve Naroff
change eliminates the possibility that the left hand expression is an ImplicitCastExpr. As a result, I removed the check for ImplicitCastExpr in Expr::isLvalue(). This results in the following AST's... [dylan:~/llvm/tools/clang] admin% cat fix.c short x; void test4(char c) { x += c; x = x + c; } [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang fix.c -parse-ast-dump Read top-level variable decl: 'x' void test4(char c) (CompoundStmt 0x2605d30 (CompoundAssignOperator 0x2605c40 'short' '+=' (DeclRefExpr 0x2605c00 'short' Decl='x' 0x2605a80) (DeclRefExpr 0x2605c20 'char' Decl='c' 0x2605bc0)) (BinaryOperator 0x2605d10 'short' '=' (DeclRefExpr 0x2605c60 'short' Decl='x' 0x2605a80) (ImplicitCastExpr 0x2605d00 'short' (BinaryOperator 0x2605ce0 'int' '+' (ImplicitCastExpr 0x2605cc0 'int' (DeclRefExpr 0x2605c80 'short' Decl='x' 0x2605a80)) (ImplicitCastExpr 0x2605cd0 'int' (DeclRefExpr 0x2605ca0 'char' Decl='c' 0x2605bc0)))))) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41404 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-25Give CXXBoolLiteralExpr a type (all expressions need a valid type).Steve Naroff
This fixes the following: ******************** TEST 'Parser/cxx-bool.cpp' FAILED! ******************** Command: clang -fsyntax-only Parser/cxx-bool.cpp Output: SemaExpr.cpp:731: failed assertion `!t.isNull() && "DefaultFunctionArrayConversion - missing type"' Output/cxx-bool.cpp.out.script: line 1: 22697 Abort trap clang -fsyntax-only Parser/cxx-bool.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41401 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-25Fix the test/Sema/format-strings.c regression. This code should be refactored.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41398 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-25Fix the regression on test/Sema/cfstring.cChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41396 91177308-0d34-0410-b5e6-96231b3b80d8