aboutsummaryrefslogtreecommitdiff
path: root/clang/test/Sema/array-constraint.c
AgeCommit message (Collapse)AuthorFilesLines
2011-01-04Enhance the diagnostic for negative array sizes to include theChandler Carruth1-1/+1
declaration name of the array when present. This ensures that a poor-man's C++03 static_assert will include the user error message often embedded in the name. Update all the tests to reflect the new wording, and add a test for the name behavior. llvm-svn: 122802
2010-09-05make clang print types as "const int *" instead of "int const*",Chris Lattner1-1/+1
which is should have done from the beginning. As usual, the most fun with this sort of change is updating all the testcases. llvm-svn: 113090
2010-04-22Whenever we complain about a failed initialization of a function orDouglas Gregor1-1/+1
method parameter, provide a note pointing at the parameter itself so the user does not have to manually look for the function/method being called and match up parameters to arguments. For example, we now get: t.c:4:5: warning: incompatible pointer types passing 'long *' to parameter of type 'int *' [-pedantic] f(long_ptr); ^~~~~~~~ t.c:1:13: note: passing argument to parameter 'x' here void f(int *x); ^ llvm-svn: 102038
2010-04-09Improve diagnostics when we fail to convert from a source type to aDouglas Gregor1-1/+1
destination type for initialization, assignment, parameter-passing, etc. The main issue fixed here is that we used rather confusing wording for diagnostics such as t.c:2:9: warning: initializing 'char const [2]' discards qualifiers, expected 'char *' [-pedantic] char *name = __func__; ^ ~~~~~~~~ We're not initializing a 'char const [2]', we're initializing a 'char *' with an expression of type 'char const [2]'. Similar problems existed for other diagnostics in this area, so I've normalized them all with more precise descriptive text to say what we're initializing/converting/assigning/etc. from and to. The warning for the code above is now: t.c:2:9: warning: initializing 'char *' from an expression of type 'char const [2]' discards qualifiers [-pedantic] char *name = __func__; ^ ~~~~~~~~ Fixes <rdar://problem/7447179>. llvm-svn: 100832
2009-12-15Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar1-1/+1
- This is designed to make it obvious that %clang_cc1 is a "test variable" which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it can be useful to redefine what gets run as 'clang -cc1' (for example, to set a default target). llvm-svn: 91446
2009-07-22Prep for new warning.Mike Stump1-1/+1
llvm-svn: 76709
2009-03-24Rename clang to clang-cc.Daniel Dunbar1-1/+1
Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
2009-02-10GNU allows structs with flexible array members to be placed insideDouglas Gregor1-1/+1
arrays and other structs/unions as an extension. Downgrade our error to a warning. Fixes PR3540. llvm-svn: 64239
2009-02-07Make one expected-diag directive match exactly one actual diagnostic.Sebastian Redl1-1/+1
This uncovers some bugs, so several test cases now fail. llvm-svn: 64025
2009-01-19Centralize error reporting of improper uses of incomplete types in theDouglas Gregor1-1/+1
new DiagnoseIncompleteType. It provides additional information about struct/class/union/enum types when possible, either by pointing to the forward declaration of that type or by pointing to the definition (if we're in the process of defining that type). Fixes <rdar://problem/6500531>. llvm-svn: 62521
2008-12-07a minor grammar fixChris Lattner1-1/+1
llvm-svn: 60646
2008-12-07Improve VLA diagnostics/sema checking. Fixes PR2361 and PR2352.Anders Carlsson1-1/+1
llvm-svn: 60638
2008-05-27Change diagnostic per suggestion, to make it a bit clearer what is Eli Friedman1-1/+1
happening. llvm-svn: 51574
2008-01-18Sema::FinalizeDeclaratorGroup(): Tighten up the tentative definition rule ↵Steve Naroff1-1/+1
when dealing with arrays. Bug submitted by Eli. llvm-svn: 46179
2008-01-18Sema::FinalizeDeclaratorGroup()...make sure we emit an diagnostic for ↵Steve Naroff1-1/+2
tentative definitions with incomplete types. Touch up all test cases that are effected. llvm-svn: 46152
2008-01-04Merge all the 'assignment' diagnostic code into one routine, decloning Chris Lattner1-1/+1
it from several places. This merges the diagnostics, making them more uniform and fewer in number. This also simplifies and cleans up the code. Some highlights: 1. This removes a bunch of very-similar diagnostics. 2. This renames AssignmentCheckResult -> AssignConvertType 3. This merges PointerFromInt + IntFromPointer which were always treated the same. 4. This updates a bunch of test cases that have minor changes to the produced diagnostics. llvm-svn: 45589
2007-12-10Add support for initializing char arrays from string literals.Steve Naroff1-1/+1
Adapted from a patch by Anders Carlsson. llvm-svn: 44816
2007-10-11rename -parse-ast-print to -ast-printChris Lattner1-1/+1
rename -parse-ast-dump to -ast-dump remove -parse-ast, which is redundant with -fsyntax-only llvm-svn: 42852
2007-09-26Removed option "-parse-ast-check" from clang driver. This is now implementedTed Kremenek1-1/+1
using "-parse-ast -verify". Updated all test cases (using a sed script) that invoked -parse-ast-check to now use -parse-ast -verify. Fixed a bug where using "-verify" instead of "-parse-ast-check" would not correctly create the DiagClient needed to accumulate diagnostics. llvm-svn: 42365
2007-08-31Removed Sema::VerifyConstantArrayType(). With the new ↵Steve Naroff1-0/+10
Array/ConstantArray/VariableArray nodes, this routine was causing more trouble than it was worth. Anders/Chris noticed that it could return an error code without emiting a diagnostic (which results in an silent invalid decl, which should *never* happen). In addition, this routine didn't work well for typedefs and field decls. Lastly, it didn't consider that initializers aren't in place yet. Added Type::getAsConstantArrayType(), Type::getAsVariableArrayType(), Type::getAsVariablyModifiedType(), and Type::isVariablyModifiedType(); Modified Sema::ParseDeclarator() and Sema::ParseField() to use the new predicates. Also added a FIXME for the initializer omission. Also added a missing test for "static" @ file scope. llvm-svn: 41647
2007-08-30Final phase of array cleanup (for now), removing a FIXME from yesterday.Steve Naroff1-0/+8
Moved several array constraints checks from Sema::VerifyConstantArrayType() to Sema::GetTypeForDeclarator(). VerifyConstantArrayType() is now very simple, and could be removed eventually. Now, we get the following (correct) messages for BlockVarDecls:-) [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang x.c -pedantic x.c:4:20: error: size of array has non-integer type 'float' int size_not_int[f]; ^ x.c:5:21: error: array size is negative int negative_size[1-2]; ^~~ x.c:6:17: warning: zero size arrays are an extension int zero_size[0]; ^ 3 diagnostics generated. llvm-svn: 41624
2007-08-28Move the "invalid decl" idiom up to Decl (where we have some bits to steal:-)Steve Naroff1-0/+6
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
2007-08-26Fix bogus warnings (noticed by Chris) with array-constraints.c.Steve Naroff1-1/+17
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
2007-08-26steve's recent changes fixed this bogus warning.Chris Lattner1-1/+1
llvm-svn: 41432
2007-08-02oops, this is the real fix.Chris Lattner1-1/+1
llvm-svn: 40766
2007-08-02update testChris Lattner1-1/+1
llvm-svn: 40765
2007-07-19Fix a crasher that Neil reported: Sema::GetTypeForDeclarator should never Chris Lattner1-0/+11
return a null type. If there is an error parsing the type, pick a new type for error recovery purposes. llvm-svn: 40029