Commit Graph

23 Commits

Author SHA1 Message Date
Richard Smith 0875c53239 If a comma operator is followed by a token which unambiguously indicates the
start of a statement or the end of a compound-statement, diagnose the comma as
a typo for a semicolon. Patch by Ahmed Bougacha! Additional test cases and
minor refactoring by me.

llvm-svn: 164085
2012-09-18 00:52:05 +00:00
Dmitri Gribenko 800ddf3dda Generalize -Wempty-body: warn when statement body is empty (closes: PR11329)
* if, switch, range-based for: warn if semicolon is on the same line.
* for, while: warn if semicolon is on the same line and either next
statement is compound statement or next statement has more
indentation.

Replacing the semicolon with {} or moving the semicolon to the next
line will always silence the warning.

Tests from SemaCXX/if-empty-body.cpp merged into SemaCXX/warn-empty-body.cpp.

llvm-svn: 150515
2012-02-14 22:14:32 +00:00
Argyrios Kyrtzidis 90ab3b7779 Don't skip past the '}' if an expression has error and is not followed by ';'.
llvm-svn: 99972
2010-03-31 00:37:59 +00:00
Mike Stump 0978af83b3 Insulate these from changes to the default for -Wunreachable-code.
llvm-svn: 94326
2010-01-23 20:12:18 +00:00
Daniel Dunbar 8fbe78f6fc Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
- 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-12-15 20:14:24 +00:00
Daniel Dunbar 769f940655 Ok, ok, I give in. Fix tests for unused result warning.
llvm-svn: 77780
2009-08-01 06:07:15 +00:00
Mike Stump 753d120975 Prep for new warning.
llvm-svn: 76709
2009-07-22 00:43:08 +00:00
Chris Lattner 8e3eed0890 change ParseStatementOrDeclaration to emit the 'missing ;' with
ExpectAndConsume instead of custom diag logic.  This gets us an
insertion hint and positions the ; at the end of the line 
instead of on the next token.  Before:

t.c:5:1: error: expected ';' after return statement
}
^

after:

t.c:4:11: error: expected ';' after return statement
  return 4
          ^
          ;

llvm-svn: 73315
2009-06-14 00:23:56 +00:00
Daniel Dunbar a45cf5b6b0 Rename clang to clang-cc.
Tests and drivers updated, still need to shuffle dirs.

llvm-svn: 67602
2009-03-24 02:24:46 +00:00
Chris Lattner 0046de17e5 Fix a couple of suboptimalities in error recovery.
1. In the top level of ParseStatementOrDeclaration, don't eat a } if we
   just parsed a statement if it list there.  Also, don't even bother
   emitting an error about a missing semicolon if the statement had a 
   bug (an rbrace is fine).
2. In do/while parsing, don't require a 'while' to be present if the do
   body didn't parse.

This allows us to generate a clean diagnostic for this code:

t.c:1:22: error: expected expression
void foo (void) { do . while (0); }
                     ^

Thanks to Neil for pointing this out.

llvm-svn: 59256
2008-11-13 18:52:53 +00:00
Chris Lattner 9226b92563 implement a fixme :), switch to -verify mode.
llvm-svn: 59253
2008-11-13 18:42:17 +00:00
Chris Lattner e66218bf49 Split the expression tests out of statements.c into expressions.c
llvm-svn: 38882
2006-08-12 17:19:28 +00:00
Chris Lattner 89d53752f5 Fix parsing of assignment expressions and handling of right-associative
things.

llvm-svn: 38881
2006-08-12 17:18:19 +00:00
Chris Lattner eb17652f5f Check that ?: parses its RHS as 'expression'.
llvm-svn: 38878
2006-08-12 17:04:23 +00:00
Chris Lattner 3401781548 Add another testcase
llvm-svn: 38870
2006-08-11 02:12:35 +00:00
Chris Lattner eddbcb2b12 Add sizeof/cast/compound_expr tests.
llvm-svn: 38867
2006-08-11 01:38:08 +00:00
Chris Lattner 2f9980ef14 Implement Parser/statements.c:test5: parsing decls that start with identifiers
in blocks.

llvm-svn: 38854
2006-08-10 18:39:24 +00:00
Chris Lattner 6dfd97806e Add support for simple labels.
llvm-svn: 38853
2006-08-10 18:31:37 +00:00
Chris Lattner f8afb62ef9 Add support for parsing declarations in blocks. This implements
Parser/statements.c:test4

llvm-svn: 38852
2006-08-10 18:26:31 +00:00
Chris Lattner 97353f2327 add test3
llvm-svn: 38850
2006-08-10 05:59:30 +00:00
Chris Lattner 53361ac130 Refactor init-declarator-list parsing code to allow for-statements to have
initializers in them.

llvm-svn: 38847
2006-08-10 05:19:57 +00:00
Chris Lattner 905caf37a0 add test2
llvm-svn: 38845
2006-08-10 04:59:23 +00:00
Chris Lattner 4dfe4b9da1 new testcase
llvm-svn: 38843
2006-08-09 05:47:56 +00:00