summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/transparent-union.c
Commit message (Collapse)AuthorAgeFilesLines
* Reland "[CodeGen] Fix crash when a function taking transparent union is ↵Volodymyr Sapsai2018-01-221-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | redeclared." When a function taking transparent union is declared as taking one of union members earlier in the translation unit, clang would hit an "Invalid cast" assertion during EmitFunctionProlog. This case corresponds to function f1 in test/CodeGen/transparent-union-redecl.c. We decided to cast i32 to union because after merging function declarations function parameter type becomes int, CGFunctionInfo::ArgInfo type matches with ABIArgInfo type, so we decide it is a trivial case. But these types should also be castable to parameter declaration type which is not the case here. Now the fix is in converting from ABIArgInfo type to VarDecl type and using argument demotion when necessary. Additional tests in Sema/transparent-union.c capture current behavior and make sure there are no regressions. rdar://problem/34949329 Reviewers: rjmccall, rafael Reviewed By: rjmccall Subscribers: aemerson, cfe-commits, kristof.beyls, ahatanak Differential Revision: https://reviews.llvm.org/D41311 llvm-svn: 323156
* Revert "[CodeGen] Fix crash when a function taking transparent union is ↵Volodymyr Sapsai2017-12-211-29/+0
| | | | | | | | | | | | redeclared." This reverts commit r321296. It caused performance regressions FAIL: imp.execution_time FAIL: 2007-01-04-KNR-Args.execution_time FAIL: sse_expandfft.execution_time FAIL: sse_stepfft.execution_time llvm-svn: 321306
* [CodeGen] Fix crash when a function taking transparent union is redeclared.Volodymyr Sapsai2017-12-211-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a function taking transparent union is declared as taking one of union members earlier in the translation unit, clang would hit an "Invalid cast" assertion during EmitFunctionProlog. This case corresponds to function f1 in test/CodeGen/transparent-union-redecl.c. We decided to cast i32 to union because after merging function declarations function parameter type becomes int, CGFunctionInfo::ArgInfo type matches with ABIArgInfo type, so we decide it is a trivial case. But these types should also be castable to parameter declaration type which is not the case here. The fix is in checking for the trivial case if ABIArgInfo type matches with parameter declaration type. It exposed inconsistency that we check hasScalarEvaluationKind for different types in EmitParmDecl and EmitFunctionProlog, and comment says they should match. Additional tests in Sema/transparent-union.c capture current behavior and make sure there are no regressions. rdar://problem/34949329 Reviewers: rjmccall, rafael Reviewed By: rjmccall Subscribers: aemerson, cfe-commits, kristof.beyls Differential Revision: https://reviews.llvm.org/D41311 llvm-svn: 321296
* [Sema] Add support for flexible array members in Obj-C.Volodymyr Sapsai2017-10-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow Obj-C ivars with incomplete array type but only as the last ivar. Also add a requirement for ivars that contain a flexible array member to be at the end of class too. It is possible to add in a subclass another ivar at the end but we'll emit a warning in this case. Also we'll emit a warning if a variable sized ivar is declared in class extension or in implementation because subclasses won't know they should avoid adding new ivars. In ARC incomplete array objects are treated as __unsafe_unretained so require them to be marked as such. Prohibit synthesizing ivars with flexible array members because order of synthesized ivars is not obvious and tricky to control. Spelling out ivar explicitly gives control to developers and helps to avoid surprises with unexpected ivar ordering. For C and C++ changed diagnostic to tell explicitly a field is not the last one and point to the next field. It is not as useful as in Obj-C but it is an improvement and it is consistent with Obj-C. For C for unions emit more specific err_flexible_array_union instead of generic err_field_incomplete. rdar://problem/21054495 Reviewers: rjmccall, theraven Reviewed By: rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D38773 llvm-svn: 316381
* Allow attributes before union definitionErich Keane2017-02-281-0/+24
| | | | | | | | permits typedef union __attribute__((transparent_union)) {...} Differential Revision: https://reviews.llvm.org/D28266 llvm-svn: 296518
* [Sema] Fix PR30520: Handle incomplete field types in transparent_union unionsAlex Lorenz2016-10-061-0/+9
| | | | | | | | | | | This commit fixes a crash that happens when clang is analyzing a transparent_union attribute on a union which has a field with incomplete type. rdar://28630028 Differential Revision: https://reviews.llvm.org/D25273 llvm-svn: 283432
* Print detailed vector type information on diagnostics.Benjamin Kramer2014-04-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | We never aka vector types because our attributed syntax for it is less comprehensible than the typedefs. This leaves the user in the dark when the typedef isn't named that well. Example: v2s v; v4f w; w = v; The naming in this cases isn't even that bad, but the error we give is useless without looking up the actual typedefs. t.c:6:5: error: assigning to 'v4f' from incompatible type 'v2s' Now: t.c:6:5: error: assigning to 'v4f' (vector of 4 'float' values) from incompatible type 'v2s' (vector of 2 'int' values) We do this for all diagnostics that print a vector type. llvm-svn: 207267
* Relaxing the alignment requirements for fields in a transparent_union. Emits ↵Aaron Ballman2014-01-281-1/+19
| | | | | | | | the diagnostic only when subsequent alignments are more strict than the alignment required by the first field. Fixes PR15134 llvm-svn: 200277
* Forbid driver use in Sema testsAlp Toker2014-01-161-1/+1
| | | | | | | | This ports the last Sema tests over to use the frontend directly, and adds a local lit substitution to disable inappropriate %clang usage under this directory. llvm-svn: 199348
* Merge transparent union types using member's unqualified typePeter Collingbourne2010-12-021-0/+4
| | | | llvm-svn: 120736
* Merge transparent union types using member's canonical param typePeter Collingbourne2010-12-021-0/+4
| | | | llvm-svn: 120729
* Implement GNU C extension: two types are compatible if they appearPeter Collingbourne2010-10-241-0/+18
| | | | | | | as a function argument, one of the types is a transparent union type and the other type is compatible with a union member llvm-svn: 117243
* Complain about the application of a transparent_union attribute to aDouglas Gregor2010-06-301-0/+7
| | | | | | | | union whose first field has integral vector type. Also, clean up this diagnostic a bit. Thanks to Eli for spotting this change in semantics last week. llvm-svn: 107296
* Whenever we complain about a failed initialization of a function orDouglas Gregor2010-04-221-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
* Update tests to use %clang instead of 'clang', and forcibly disable use of 'Daniel Dunbar2009-12-151-1/+1
| | | | | | | clang ' or ' clang -cc1 ' or ' clang-cc ' in test lines (by substituting them to garbage). llvm-svn: 91460
* Implement semantic analysis for transparent unions. This is largelyDouglas Gregor2009-04-291-0/+40
based on a patch from Anders Johnsen. CodeGen support is incomplete, in that we do not properly coerce to the first field's type. llvm-svn: 70419
OpenPOWER on IntegriCloud