summaryrefslogtreecommitdiffstats
path: root/clang/test/Parser/declarators.c
Commit message (Collapse)AuthorAgeFilesLines
* revert patch r216469.Fariborz Jahanian2014-08-261-0/+1
| | | | llvm-svn: 216485
* c11- Check for c11 language option as documentation saysFariborz Jahanian2014-08-261-1/+0
| | | | | | | | feature is c11 about nested struct declarations must have struct-declarator-list. Without this change, code which was meant for c99 breaks. rdar://18125536 llvm-svn: 216469
* PR20634: add some more cases that can legitimately come after a struct ↵Richard Smith2014-08-131-0/+2
| | | | | | declaration to our list of special cases. llvm-svn: 215520
* Sema: Handle declspecs without declarators in records properly in C modeDavid Majnemer2014-08-111-0/+1
| | | | | | | | | | | | | | | | | | | | | We had two bugs: - We wouldn't properly warn when a struct/union/enum was mentioned inside of a record definition if no declarator was provided. We should have mentioned that this declaration declares nothing. - We didn't properly support Microsoft's extension where certain declspecs without declarators would act as anonymous structs/unions. * We completely ignored the case where such a declspec could be a union. * We didn't properly handle the case where a record was defined inside another record: struct X { int a; struct Y { int b; }; }; llvm-svn: 215347
* Parser: Array decls with static but without array size are illformedDavid Majnemer2014-08-081-0/+1
| | | | | | | | | | | | Array declarators involving the static keyword take on two forms: D[ static type-qualifier-listopt assignment-expression ] D[ type-qualifier-list static assignment-expression ] Raise a diagnostic if the assignment-expression is missing. This fixes PR20584. llvm-svn: 215187
* Fix bungled parse recovery in K&R function declarationsAlp Toker2014-01-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | void knrNoSemi(i) int i { } Adherents of The C Programming Language unfortunate enough to miss a semicolon as above would be met with a cascade of errors spanning the remainder of the TU. This patch introduces a beautiful parse error recovery, complete with helpful FixIt to restore sanity. Before (output redacted for brevity): error: 'error' diagnostics seen but not expected: File declarators.c Line 119: declaration does not declare a parameter File declarators.c Line 123: declaration does not declare a parameter File declarators.c Line 127: parameter named 'func_E12' is missing File declarators.c Line 127: expected ';' at end of declaration File declarators.c Line 133: parameter named 'func_E13' is missing File declarators.c Line 133: expected ';' at end of declaration File declarators.c Line 139: parameter named 'func_E14' is missing File declarators.c Line 139: expected ';' at end of declaration File declarators.c Line 145: parameter named 'func_E15' is missing File declarators.c Line 145: expected ';' at end of declaration File declarators.c Line 150: expected function body after function declarator File declarators.c Line 119: declaration of 'enum E11' will not be visible outside of this function File declarators.c Line 123: declaration of 'enum E12' will not be visible outside of this function File declarators.c Line 133: ISO C forbids forward references to 'enum' types File declarators.c Line 133: declaration of 'enum E13' will not be visible outside of this function File declarators.c Line 139: ISO C forbids forward references to 'enum' types File declarators.c Line 139: declaration of 'enum E14' will not be visible outside of this function File declarators.c Line 145: ISO C forbids forward references to 'enum' types File declarators.c Line 145: declaration of 'enum E15' will not be visible outside of this function ... After: declarators.c:103:24: error: expected ';' at end of declaration void knrNoSemi(i) int i { } ^ ; Patch found in a sealed envelope dated 1978 with the message "Do not open until January 2014" llvm-svn: 198540
* Recover from errors in enum definitionSerge Pavlov2013-12-311-0/+34
| | | | | | | | | | Previously any error in enum definition body stopped parsing it. With this change parser tries to recover from errors. The patch fixes PR10982. Differential Revision: http://llvm-reviews.chandlerc.com/D2018 llvm-svn: 198259
* Recognition of empty structures and unions is moved to semantic stageSerge Pavlov2013-06-081-1/+2
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D586 llvm-svn: 183609
* A ':' after an enum-specifier at class scope is a bitfield, not a typo for a ↵Richard Smith2012-07-021-0/+5
| | | | | | ';'. llvm-svn: 159549
* switch some uses of ExpectAndConsume(tok::semi to use ExpectAndConsumeSemi. ↵Chris Lattner2012-04-281-0/+7
| | | | | | | | | | | | | | | | | | | | This allows us to improve this diagnostic (telling us to insert another ")": t.c:2:19: error: expected ';' at end of declaration int x = 4+(5-12)); ^ ; to: t.c:2:19: error: extraneous ')' before ';' int x = 4+(5-12)); ^ ...telling us to remove the ")". This is PR12595. There are more uses of ExpectAndConsumeSemi that could be switched over, but I don't hit them on a daily basis :) llvm-svn: 155759
* Remove "parse error" in favor of more descriptive diagnostics.David Blaikie2012-04-061-0/+3
| | | | | | | | | | | In a few cases clang emitted a rather content-free diagnostic: 'parse error'. This change replaces two actual cases (template parameter parsing and K&R parameter declaration parsing) with more specific diagnostics and removes a third dead case of this in the BalancedDelimiterTracker (the ctor already checked the invariant necessary to ensure that the diag::parse_error was never actually used). llvm-svn: 154224
* ...I forgot to check my new test after adding it, and lo, there's slightly ↵John McCall2010-08-261-1/+1
| | | | | | | | different behavior in C than in C++ (which is what the original test case was). llvm-svn: 112199
* Make sure we clear TypeSpecOwned when setting TypeSpecType to something whenJohn McCall2010-08-261-0/+3
| | | | | | it might previously have been a tag TST. llvm-svn: 112196
* change the 'invalid token after top level declarator' message to beChris Lattner2010-07-111-1/+1
| | | | | | 'expected ';' after top level declarator' which is much less vague. llvm-svn: 108106
* Fix PR7617 by not entering ParseFunctionDefinition whenChris Lattner2010-07-111-0/+8
| | | | | | | | | | | | | | | | | | | | | a function prototype is followed by a declarator if we aren't parsing a K&R style identifier list. Also, avoid skipping randomly after a declaration if a semicolon is missing. Before we'd get: t.c:3:1: error: expected function body after function declarator void bar(); ^ Now we get: t.c:1:11: error: invalid token after top level declarator void foo() ^ ; llvm-svn: 108105
* Don't try to parse class template specializations in C. It can onlyDouglas Gregor2010-05-301-0/+3
| | | | | | lead to heartache. Fixes <rdar://problem/8044088>. llvm-svn: 105178
* Improve diagnostics when we fail to convert from a source type to aDouglas Gregor2010-04-091-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
* Improve the diagnostic given when referring to a tag type without a tag (in C)John McCall2010-02-141-2/+2
| | | | | | | | | or that's been hidden by a non-type (in C++). The ideal C++ diagnostic here would note the hiding declaration, but this is a good start. llvm-svn: 96141
* Declarators can have grouping parens. This fixes rdar://7608537.Chris Lattner2010-02-031-0/+3
| | | | llvm-svn: 95246
* fix PR6216Chris Lattner2010-02-031-0/+5
| | | | llvm-svn: 95185
* the declspec of a declaration can have storage-class specifiers,Chris Lattner2010-02-021-0/+4
| | | | | | | | | type qualifiers and type specifiers in any order. For example, this is valid: struct x {...} typedef y; This fixes PR6208. llvm-svn: 95094
* improve diagnostics on missing ; in a struct. Before:Chris Lattner2010-02-021-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | t.c:4:3: error: expected ';' at end of declaration list int y; ^ t.c:4:8: warning: extra ';' inside a struct or union int y; ^ t.c:6:1: warning: expected ';' at end of declaration list }; ^ After: t.c:3:8: error: expected ';' at end of declaration list int x // expected-error {{expected ';' at end of declaration list}} ^ ; t.c:5:8: warning: expected ';' at end of declaration list int z ^ ; llvm-svn: 95038
* Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar2009-12-151-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
* Prep for new warning.Mike Stump2009-07-221-5/+5
| | | | llvm-svn: 76709
* Simplify the scheme used for keywords, and change the classification Eli Friedman2009-04-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | scheme to be more useful. The new scheme introduces a set of categories that should be more readable, and also reflects what we want to consider as an extension more accurately. Specifically, it makes the "what is a keyword" determination accurately reflect whether the keyword is a GNU or Microsoft extension. I also introduced separate flags for keyword aliases; this is useful because the classification of the aliases is mostly unrelated to the classification of the original keyword. This patch treats anything that's in the implementation namespace (prefixed with "__", or "_X" where "X" is any upper-case letter) as a keyword without marking it as an extension. This is consistent with the standards in that an implementation is allowed to define arbitrary extensions in the implementation namespace without violating the standard. This gets rid of all the nasty "extension used" warnings for stuff like __attribute__ in -pedantic mode. We still warn for extensions outside of the the implementation namespace, like typeof. If someone wants to implement -Wextensions or something like that, we could add additional information to the keyword table. This also removes processing for the unused "Boolean" language option; such an extension isn't supported on any other C implementation, so I don't see any point to adding it. The changes to test/CodeGen/inline.c are required because previously, we weren't actually disabling the "inline" keyword in -std=c89 mode. I'll remove Boolean and NoExtensions from LangOptions in a follow-up commit. llvm-svn: 70281
* fix another case that assumed that GetTypeForDeclarator would never return null.Chris Lattner2009-04-121-1/+0
| | | | llvm-svn: 68918
* mark the declspec as invalid when we recover instead of forcing to int,Chris Lattner2009-04-121-2/+4
| | | | | | this allows downstream diags to be properly silenced. llvm-svn: 68917
* Diagnose invalid uses of tagged types with a missing tag. For example, in:Chris Lattner2009-04-121-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | struct xyz { int y; }; enum abc { ZZZ }; static xyz b; abc c; we used to produce: t2.c:4:8: error: unknown type name 'xyz' static xyz b; ^ t2.c:5:1: error: unknown type name 'abc' abc c; ^ we now produce: t2.c:4:8: error: use of tagged type 'xyz' without 'struct' tag static xyz b; ^ struct t2.c:5:1: error: use of tagged type 'abc' without 'enum' tag abc c; ^ enum GCC produces the normal: t2.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘b’ t2.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c’ rdar://6783347 llvm-svn: 68914
* Implement the first set of changes for PR3963 and rdar://6759604,Chris Lattner2009-04-121-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which tries to do better error recovery when it is "obvious" that an identifier is a mis-typed typename. In this case, we try to parse it as a typename instead of as the identifier in a declarator, which gives us several options for better error recovery and immediately makes diagnostics more useful. For example, we now produce: t.c:4:8: error: unknown type name 'foo_t' static foo_t a = 4; ^ instead of: t.c:4:14: error: invalid token after top level declarator static foo_t a = 4; ^ Also, since we now parse "a" correctly, we make a decl for it, preventing later uses of 'a' from emitting things like: t.c:12:20: error: use of undeclared identifier 'a' int bar() { return a + b; } ^ I'd really appreciate any scrutiny possible on this, it is a tricky area. llvm-svn: 68911
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Fix PR3031 by silencing follow-on errors in invalid declarations.Chris Lattner2008-11-111-0/+4
| | | | llvm-svn: 59027
* reject 'int test(x, x) int x; {}'Chris Lattner2008-04-061-0/+2
| | | | llvm-svn: 49271
* reject 'typedef int y; int test(x, y)'.Chris Lattner2008-04-061-0/+4
| | | | llvm-svn: 49270
* Fix handling of implicit int, resolving PR2012 and reverting (andChris Lattner2008-04-051-1/+1
| | | | | | subsuming) my patch for PR1999. llvm-svn: 49251
* Fix PR1999, by emitting a hard error only if an argument declarator is ↵Chris Lattner2008-02-101-2/+2
| | | | | | | | | completely missing. Otherwise, it is an implicit int case, which is valid in c90 and invalid elsewhere, but accepted as an extension. llvm-svn: 46938
* Fix PR1965: missing diagnostics for parameters that are missingChris Lattner2008-01-311-1/+1
| | | | | | | type specifiers. This required updating some (buggy) tests, and the testcase was previously accidentally committed. llvm-svn: 46603
* reenable this code, fix the testcase.Chris Lattner2007-12-191-2/+2
| | | | llvm-svn: 45205
* we correctly reject array of void nowChris Lattner2007-06-081-1/+1
| | | | llvm-svn: 39614
* add bare struct tag decls.Chris Lattner2006-08-131-1/+7
| | | | llvm-svn: 38899
* new testcaseChris Lattner2006-08-121-0/+4
| | | | llvm-svn: 38889
* new testcaseChris Lattner2006-08-061-0/+18
llvm-svn: 38825
OpenPOWER on IntegriCloud