summaryrefslogtreecommitdiffstats
path: root/clang/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix 80 col violations.Chris Lattner2007-08-302-3/+3
| | | | llvm-svn: 41611
* Fix a regression on test/Sema/unused-expr.c by fixing the type predicatesChris Lattner2007-08-301-1/+1
| | | | | | to test for the right type class. llvm-svn: 41601
* Fix the following redefinition errors submitted by Keith Bauer...Steve Naroff2007-08-301-22/+41
| | | | | | | | | | | | | | | | | | | | | | | | [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! llvm-svn: 41592
* Spaces not tabs.Neil Booth2007-08-291-1/+1
| | | | llvm-svn: 41582
* Ensure we diagnose long long literals in C90 mode.Neil Booth2007-08-291-0/+5
| | | | llvm-svn: 41581
* Added checking (during parsing) of comparison of floating point values using ↵Ted Kremenek2007-08-291-0/+3
| | | | | | | | == or !=. This is the same functionality gcc provides via --Wfloat-equal. llvm-svn: 41574
* Implement GCC-compatible layout and typing of enum constants and enum decl. Chris Lattner2007-08-291-11/+64
| | | | | | A small bit of codegen work is still pending. llvm-svn: 41571
* Fix a null dereference Neil ran intoChris Lattner2007-08-291-1/+2
| | | | llvm-svn: 41564
* Implement default argument promotions (for old-style function calls and ↵Steve Naroff2007-08-282-3/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)))) llvm-svn: 41558
* Finish converting decls over to the new invalid decl API.Steve Naroff2007-08-283-23/+35
| | | | | | Also removed an old FIXME (FIXME: "auto func();" passes through...). llvm-svn: 41555
* Move the "invalid decl" idiom up to Decl (where we have some bits to steal:-)Steve Naroff2007-08-282-13/+18
| | | | | | | | 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:-) llvm-svn: 41552
* Emit a slightly better warning for unused values for unary and binary operators:Chris Lattner2007-08-281-1/+15
| | | | | | | | t2.c:3:18: warning: expression result unused x = ++x, ++y, y+2; ~~~~~~~~~~~~^ ~~~ llvm-svn: 41551
* add a sourcelocation to binary operator to keep track of the location of the ↵Chris Lattner2007-08-281-2/+2
| | | | | | operator. llvm-svn: 41550
* Change EnumDecl to store its corresponding integer type Chris Lattner2007-08-281-1/+1
| | | | | | | directly in it. Remove TargetInfo::getEnumPolicy, as there is only one policy that we support right now. llvm-svn: 41548
* Fixed return-of-stack-address checker to correctly handle stack/globalTed Kremenek2007-08-281-5/+6
| | | | | | | | | | | | | | | | | 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!). llvm-svn: 41546
* extwarn about VLAs in C89 mode.Chris Lattner2007-08-281-2/+8
| | | | llvm-svn: 41545
* c++'0x has long long also.Chris Lattner2007-08-281-1/+1
| | | | llvm-svn: 41544
* warn about long long when in c89 mode.Chris Lattner2007-08-281-0/+6
| | | | llvm-svn: 41543
* fix 80 col violationChris Lattner2007-08-281-1/+2
| | | | llvm-svn: 41533
* compute the required destination type for an enum, emitting various warnings.Chris Lattner2007-08-281-2/+56
| | | | | TODO: update the types of the constants and the enum. llvm-svn: 41532
* add a diagnostic:Chris Lattner2007-08-281-0/+14
| | | | | | | | 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 }; ^ llvm-svn: 41530
* move a todoChris Lattner2007-08-281-4/+5
| | | | llvm-svn: 41528
* now that all the infrastructure is in place, enforce C99 6.8.5p3.Chris Lattner2007-08-281-4/+11
| | | | | | Note the FIXME: we need some way to mark a decl erroneous :) llvm-svn: 41524
* If the condition of a for statement is promoted, make sure theChris Lattner2007-08-281-8/+12
| | | | | | implicit cast gets linked back into the AST. llvm-svn: 41523
* Implement more thoughful error recovery when dealing with bogus declarator ↵Steve Naroff2007-08-283-4/+22
| | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 41521
* Some minor aesthetic changes to the control flow.Steve Naroff2007-08-271-10/+7
| | | | llvm-svn: 41517
* Fix remaining bugs with complex/float promotions.Steve Naroff2007-08-271-16/+25
| | | | llvm-svn: 41515
* Fix a few enum-related fixme'sChris Lattner2007-08-271-4/+9
| | | | llvm-svn: 41513
* better error recovery for non-i-c-e enum constants.Chris Lattner2007-08-271-11/+15
| | | | llvm-svn: 41499
* Updated checker for "return of address of stack variable" to look forTed Kremenek2007-08-271-4/+6
| | | | | | | | | | 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). llvm-svn: 41493
* Replaced ASTContext::maxFloatingType() with ASTContext::compareFloatingType().Steve Naroff2007-08-271-9/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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))))) llvm-svn: 41483
* extwarn about decls intermixed with code in c89 mode.Chris Lattner2007-08-271-5/+21
| | | | llvm-svn: 41477
* Add Type::getAsBuiltinType() and Type::builtinTypesAreCompatible().Steve Naroff2007-08-271-2/+3
| | | | | | | | | | | | | | | | 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). llvm-svn: 41476
* Replaced ASTContext::maxComplexType() with ↵Steve Naroff2007-08-271-6/+19
| | | | | | | | | ASTContext::getFloatingTypeOfSizeWithinDomain(). Changed Sema::UsualArithmeticConversions to correctly implement complex/float conversions, using maxFloatingType() with getFloatingTypeOfSizeWithinDomain(). llvm-svn: 41474
* implement a fixme: __extension__ marker on decls in compound stmts.Chris Lattner2007-08-271-0/+4
| | | | llvm-svn: 41473
* Fix %p format checking, patch by Keith Bauer.Chris Lattner2007-08-261-1/+1
| | | | llvm-svn: 41454
* For warnings like this:Chris Lattner2007-08-261-1/+2
| | | | | | | | | | t.c:3:9: warning: invalid conversion '%B' printf("%B\a\n", p); ~~~~~~ ^ Don't beep the console or print the newline. llvm-svn: 41453
* Fix a bug reported by Keith BauerChris Lattner2007-08-261-1/+1
| | | | llvm-svn: 41452
* Fix bogus warnings (noticed by Chris) with array-constraints.c.Steve Naroff2007-08-261-4/+0
| | | | | | | | | 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). llvm-svn: 41443
* Break the assumption that any sort of scope (e.g. a loop scope) can Chris Lattner2007-08-261-0/+23
| | | | | | | | 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. llvm-svn: 41431
* require that operands to __real/__imag are complex or arithmetic. ThisChris Lattner2007-08-261-1/+9
| | | | | | fixes GCC PR33193 llvm-svn: 41428
* Make parse-ast-print print the storage class and inline Chris Lattner2007-08-261-1/+2
| | | | | | specifier of functions. llvm-svn: 41416
* add a new ImaginaryLiteral AST node that is used toChris Lattner2007-08-261-7/+16
| | | | | | | | | | | | | | | | | | 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)))) llvm-svn: 41413
* 1.0 is double, 1.0F is a float.Chris Lattner2007-08-261-2/+2
| | | | llvm-svn: 41412
* merge checkrelational and checkequality into CheckCompareOperands, Chris Lattner2007-08-262-66/+17
| | | | | | to merge duplicate code. llvm-svn: 41410
* Cases like this:Chris Lattner2007-08-261-14/+20
| | | | | | | | | | 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. llvm-svn: 41408
* Surpress the UsualUnaryConversions for compound assignment operators. This ↵Steve Naroff2007-08-251-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)))))) llvm-svn: 41404
* Give CXXBoolLiteralExpr a type (all expressions need a valid type).Steve Naroff2007-08-251-1/+2
| | | | | | | | | | | | | 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 llvm-svn: 41401
* Fix the test/Sema/format-strings.c regression. This code should be refactored.Chris Lattner2007-08-251-1/+13
| | | | llvm-svn: 41398
* Fix the regression on test/Sema/cfstring.cChris Lattner2007-08-251-4/+9
| | | | llvm-svn: 41396
OpenPOWER on IntegriCloud