Commit Graph

21 Commits

Author SHA1 Message Date
Abramo Bagnara b59a5b6784 Fixed isConstantInitializer for __builtin_choose_expr.
llvm-svn: 114820
2010-09-27 07:13:32 +00:00
Douglas Gregor da2955ed74 Reword the empty struct/union warning in C to note that such structs and unions have size 0 in C, size 1 in C++. Put this warning under -Wc++-compat.
llvm-svn: 109748
2010-07-29 14:29:34 +00:00
Douglas Gregor b10646d4ce Improve diagnostics like "initializing <type> from an expression of
type..." with "initializing <type> with an expression of type...",
which reads better. Thanks to John for the improved wording.

llvm-svn: 100873
2010-04-09 17:53:29 +00:00
Douglas Gregor c68e140657 Improve diagnostics when we fail to convert from a source type to a
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
2010-04-09 00:35:39 +00:00
John McCall 5d7aa7fa0a The type of a compound literal expression is not necessarily the same as the
type which was syntactically written.  Fixes PR 6080.

llvm-svn: 93933
2010-01-19 22:33:45 +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
Eli Friedman 0b4af8f755 PR3009: Get rid of bogus warning for scalar compound literals.
This patch isn't quite ideal in that it eliminates the warning for 
constructs like "int a = {1};", where the braces are in fact redundant.  
However, that would have required a bunch of refactoring, and it's 
much less likely to cause confusion compared to redundant nested braces.

llvm-svn: 71939
2009-05-16 11:45:48 +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
Douglas Gregor dd430f7ec9 Centralize error reporting of improper uses of incomplete types in the
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
2009-01-19 19:26:10 +00:00
Chris Lattner 1e5665e6be Change a whole lot of diagnostics to take QualType's directly
instead of converting them to strings first.  This also fixes a
bunch of minor inconsistencies in the diagnostics emitted by clang
and adds a bunch of FIXME's to DiagnosticKinds.def.

llvm-svn: 59948
2008-11-24 06:25:27 +00:00
Sebastian Redl 15b7160a17 64-bit test fixes.
llvm-svn: 59165
2008-11-12 21:19:11 +00:00
Steve Naroff eaf5853004 InitListChecker::CheckListElementTypes(): Check for function types and issue an appropriate diagnostic.
llvm-svn: 54614
2008-08-10 16:05:48 +00:00
Chris Lattner 28b4294ccf wrap some long diagnostics, make 'initializer is not a constant' diagnostic
a bit more clear (rdar://5646070)

llvm-svn: 54606
2008-08-10 01:58:45 +00:00
Nuno Lopes 7bfa180056 fix CheckForConstantInitializer() for Compound Literals
also fix the correspondent test (it was expecting more errors than it should. please confirm my fix is correct (at least gcc agrees with me)

llvm-svn: 53174
2008-07-07 16:46:50 +00:00
Eli Friedman d0e48ea682 Be a bit more defensive in SemaInit.
llvm-svn: 51301
2008-05-20 05:25:56 +00:00
Eli Friedman 37a186d765 Add some more checking for compound literals.
llvm-svn: 51300
2008-05-20 05:22:08 +00:00
Chris Lattner 36fc8790b7 Fix PR1992 by computing the right type for string literals, which
is an array type not a pointer type.  This requires updating some
diags that change and updating the code generator to handle the
proper form of strings.

llvm-svn: 46941
2008-02-11 00:02:17 +00:00
Steve Naroff d32419de0d Record if a compound literal expression is @ file scope. This allows us to implement C99 6.5.2.5p6. This could have been done without modifying the AST (by checking the decl type and passing the info down to isContextExpr), however we concluded this is more desirable.
Bug/patch by Eli Friedman!

llvm-svn: 45966
2008-01-14 18:19:28 +00:00
Steve Naroff 08ddb8c55c Teach Sema::ActOnCompoundLiteral about constraint C99 6.5.2.5p3.
llvm-svn: 45782
2008-01-09 20:58:06 +00:00
Steve Naroff 66a26044f8 Teach Expr::isConstantExpr() about CompoundLiterals.
llvm-svn: 45764
2008-01-09 00:05:37 +00:00
Steve Naroff 2644aaf537 Recognize CompoundLiteralExpr's as valid lvalue's.
Also updated a FIXME in Sema::CheckInitializer()...

llvm-svn: 44602
2007-12-05 04:00:10 +00:00