summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* Batch up access-related diagnostics on enum constants until the whole enum ↵Jordan Rose2015-04-301-0/+81
| | | | | | | | | | is parsed. That way we can take any trailing availability attributes into account. rdar://problem/20713550 llvm-svn: 236241
* Fix Sema tests using __try by adding tripleReid Kleckner2015-04-281-2/+2
| | | | llvm-svn: 236057
* [Sema] Don't allow unverified bitfields in FieldDeclsDavid Majnemer2015-04-261-0/+4
| | | | | | | | VerifyBitField must be called if we are to form a bitfield FieldDecl. We will not verify the bitfield if the decl is known to be malformed in other ways; pretend that we don't have a bitfield if this happens. llvm-svn: 235816
* [Sema] Check if a builtin is FunctionPrototype().Davide Italiano2015-04-251-0/+4
| | | | | | | | | | | Don't assume it's always is. This prevents a crash in Sema while trying to merge return type for a builtin w/out function prototype. PR: 23086 Differential Revision: http://reviews.llvm.org/D9235 Reviewed by: rsmith llvm-svn: 235806
* Diagnose variadic main() as an extension; addresses PR17905.Aaron Ballman2015-04-231-0/+2
| | | | llvm-svn: 235605
* Implement target-specific __attribute__((aligned)) valueUlrich Weigand2015-04-211-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The GCC construct __attribute__((aligned)) is defined to set alignment to "the default alignment for the target architecture" according to the GCC documentation: The default alignment is sufficient for all scalar types, but may not be enough for all vector types on a target that supports vector operations. The default alignment is fixed for a particular target ABI. clang currently hard-coded an alignment of 16 bytes for that construct, which is correct on some platforms (including X86), but wrong on others (including SystemZ). Since this value is ABI-relevant, it is important to get correct for compatibility purposes. This patch adds a new TargetInfo member "DefaultAlignForAttributeAligned" that targets can set to the appropriate default __attribute__((aligned)) value. Note that I'm deliberately *not* using the existing "SuitableAlign" value, which is used to set the pre-defined macro __BIGGEST_ALIGNMENT__, since those two values may not be the same on all platforms. In fact, on X86, __attribute__((aligned)) always uses 16-byte alignment, while __BIGGEST_ALIGNMENT__ may be larger if AVX-2 or AVX-512 are supported. (This is actually not yet correctly implemented in clang either.) The patch provides a value for DefaultAlignForAttributeAligned only for SystemZ, and leaves the default for all other targets at 16, which means no visible change in behavior on all other targets. (The value is still wrong for some other targets, but I'd prefer to leave it to the target maintainers for those platforms to fix.) llvm-svn: 235397
* Fix __alignof__ of global variables on SystemZUlrich Weigand2015-04-211-0/+17
| | | | | | | | | | | | | | | | | SystemZ prefers to align all global variables to two bytes, which is implemented by setting the TargetInfo member MinGlobalAlign. However, for compatibility with existing compilers this should *not* change the ABI alignment value as retrieved via __alignof__, which it currently does. This patch fixes the issue by having ASTContext::getDeclAlign ignore the MinGlobalAlign setting in the ForAlignof case. Since SystemZ is the only platform setting MinGlobalAlign, this should cause no change for any other target. llvm-svn: 235395
* Put statement expression decls in the enclosing code DeclContextReid Kleckner2015-04-201-1/+14
| | | | | | | | | | We already check that statement expressions are in a function or block, but we didn't do anything with that information. Now we use that DeclContext for the duration of the statement expression. Otherwise, we'd treat statement expression locals as static data members and go into the weeds. llvm-svn: 235335
* Comment parsing: fix an assertion failure on a verbatim block terminated ↵Dmitri Gribenko2015-04-151-0/+6
| | | | | | with "**/" llvm-svn: 235057
* Improve the error message for assigning to read-only variables.Richard Trieu2015-04-113-6/+10
| | | | | | | | | | Previously, many error messages would simply be "read-only variable is not assignable" This change provides more information about why the variable is not assignable, as well as note to where the const is located. Differential Revision: http://reviews.llvm.org/D4479 llvm-svn: 234677
* [Sema] Correctly recurse when looking for [*] in function definitionsDavid Majnemer2015-04-071-0/+3
| | | | | | | | | | A [*] is only allowed in a declaration for a function, not in its definition. We didn't correctly recurse while looking for it, causing us to crash in CodeGen instead of rejecting it. This fixes PR23151. llvm-svn: 234363
* HasSideEffects() should return false for calls to pure and const functions.Michael Kuperstein2015-04-061-1/+13
| | | | | | Differential Revision: http://reviews.llvm.org/D8548 llvm-svn: 234152
* Unify warnings/errors from "maybe you meant" to "did you mean".Eric Christopher2015-04-021-1/+1
| | | | llvm-svn: 233981
* Correct typos in SEH filter expressionsReid Kleckner2015-04-021-0/+6
| | | | | | Otherwise we assert due to uncorrected delayed typos. llvm-svn: 233980
* Add test intended for commit in r231317Reid Kleckner2015-04-011-0/+7
| | | | llvm-svn: 233866
* Sema: Accept pointers to any address space for builtin functionsTom Stellard2015-03-311-0/+8
| | | | | | | | As long as they don't have an address space explicitly defined. This allows builtins with pointer arguments to be used with OpenCL. llvm-svn: 233706
* [PPC] Move argument range checks for HTM and crypto builtins to SemaKit Barton2015-03-301-0/+51
| | | | | | | | | | | The argument range checks for the HTM and Crypto builtins were implemented in CGBuiltin.cpp, not in Sema. This change moves them to the appropriate location in SemaChecking.cpp. It requires the creation of a new method in the Sema class to do checks for PPC-specific builtins. http://reviews.llvm.org/D8672 llvm-svn: 233586
* Fix -Wshift-count-negative. It didn't work if the right hand sideDavide Italiano2015-03-261-0/+6
| | | | | | | | of the shift wasn't a constant integer expression, now it (hopefully) does. PR: 22059 llvm-svn: 233320
* Create android x86_32 and x86_64 target infoTamas Berghammer2015-03-252-0/+16
| | | | | | | | | | | On android x86_32 the long double is only 64 bits (compared to 80 bits on linux x86_32) and on android x86_64 the long double is IEEEquad (compared to x87DoubleExtended on linux x86_64). This CL creates new TargetInfo classes for this targets to represent these differences. Differential revision: http://reviews.llvm.org/D8357 llvm-svn: 233177
* Correct typos in C11 generic-selection expressions.Kaelyn Takata2015-03-191-0/+6
| | | | llvm-svn: 232760
* Add -Wpartial-availability.Nico Weber2015-03-191-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | This warns when using decls that are not available on all deployment targets. For example, a call to - (void)ppartialMethod __attribute__((availability(macosx,introduced=10.8))); will warn if -mmacosx-version-min is set to less than 10.8. To silence the warning, one has to explicitly redeclare the method like so: @interface Whatever(MountainLionAPI) - (void)ppartialMethod; @end This way, one cannot accidentally call a function that isn't available everywhere. Having to add the redeclaration will hopefully remind the user to add an explicit respondsToSelector: call as well. Some projects build against old SDKs to get this effect, but building against old SDKs suppresses some bug fixes -- see http://crbug.com/463171 for examples. The hope is that SDK headers are annotated well enough with availability attributes that new SDK + this warning offers the same amount of protection as using an old SDK. llvm-svn: 232750
* Comment parsing: move a diagnostic to the correct group.Dmitri Gribenko2015-03-172-3/+15
| | | | | | Based on a patch by LE GARREC Vincent. llvm-svn: 232511
* Use Sema's PrintingPolicy when diagnosing DeclSpecs.Benjamin Kramer2015-03-121-0/+21
| | | | | | | | | | | | | Sema overrides ASTContext's policy on the first emitted diagnostic (doesn't matter if it's ignored or not). This means changing the order of diagnostic emission in Sema suddenly changes the text of diagnostic emitted from the parser. In the test case -Wmissing-prototypes (ignored) was the culprit, use 'int main' to suppress that warning so we see when this regresses. Also move it into Sema/ as it's not testing any C++. llvm-svn: 232039
* Under duress, move check for target support of __builtin_setjmp/Joerg Sonnenberger2015-03-111-0/+34
| | | | | | __builtin_longjmp to Sema as requested by John McCall. llvm-svn: 231986
* Warn when jumping out of a __finally block via continue, break, return, __leave.Nico Weber2015-03-091-2/+76
| | | | | | | | | | | | | | | Since continue, break, return are much more common than __finally, this tries to keep the work for continue, break, return O(1). Sema keeps a stack of active __finally scopes (to do this, ActOnSEHFinally() is split into ActOnStartSEHFinally() and ActOnFinishSEHFinally()), and the various jump statements then check if the current __finally scope (if present) is deeper than then destination scope of the jump. The same warning for goto statements is still missing. This is the moral equivalent of MSVC's C4532. llvm-svn: 231623
* Support __attribute__((availability)) on Android.Dan Albert2015-03-031-0/+31
| | | | | | | | | | | | Reviewers: srhines Reviewed By: srhines Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D7929 llvm-svn: 231092
* Add clang support for Objective-C application extensions.Bob Wilson2015-03-021-0/+18
| | | | | | | | This adds the -fapplication-extension option, along with the ios_app_extension and macosx_app_extension availability attributes. Patch by Ted Kremenek llvm-svn: 230989
* Win64: Silently ignore __stdcall, __fastcall, and __thiscallReid Kleckner2015-02-261-4/+9
| | | | | | | | | | MSVC doesn't warn on this. Users are expected to apply the WINAPI macro to functions passed by pointer to the Win32 API, and this macro expands to __stdcall. This means we end up with a lot of useless noisy warnings about ignored calling conventions when compiling code with clang for Win64. llvm-svn: 230668
* Add support for analyzing FreeBSD kernel printf extensions.Dimitry Andric2015-02-192-0/+47
| | | | | | | | | | | | This adds a new __freebsd_kprintf__ format string type, which enables checking when used in __attribute__((format(...))) attributes. It can check the FreeBSD kernel specific %b, %D, %r and %y specifiers, using existing diagnostic messages. Also adds test cases for all these specifiers. Differential Revision: http://reviews.llvm.org/D7154 llvm-svn: 229921
* Sema: size_t is available in C when -fms-compatibility is enabledDavid Majnemer2015-02-181-0/+2
| | | | llvm-svn: 229616
* [X86] Add range checking on immediate arguments on XOP vpcom builtins.Craig Topper2015-02-131-0/+33
| | | | llvm-svn: 229067
* Sema: Semantically check _Atomic-qualified pointersDavid Majnemer2015-02-121-2/+4
| | | | | | This fixes PR22568. llvm-svn: 228959
* Make the byte-shift SSE intrinsics emit vector shuffles which we know the ↵Filipe Cabecinhas2015-02-071-7/+0
| | | | | | | | | | | | | | | | backend can handle. Also removed unused builtins. Original patch by Andrea Di Biagio! Reviewers: craig.topper, nadav Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D7199 llvm-svn: 228481
* Implement IRGen for SEH __finally and AbnormalTerminationReid Kleckner2015-02-041-1/+1
| | | | | | | | | | | Previously we would simply double-emit the body of the __finally block, but that doesn't work when it contains any kind of Decl, which we can't double emit. This fixes that by emitting the block once and branching into a shared code region and then branching back out. llvm-svn: 228222
* Catch more cases when diagnosing integer-constant-expression overflows.Josh Magee2015-02-042-0/+149
| | | | | | | | | When visiting AssignmentOps, keep evaluating after a failure (when possible) in order to identify overflow in subexpressions. Differential Revision: http://reviews.llvm.org/D1238 llvm-svn: 228202
* Sema: Add support for __declspec(restrict)David Majnemer2015-02-041-5/+5
| | | | | | | | | | __declspec(restrict) and __attribute(malloc) are both handled identically by clang: they are allowed to the noalias LLVM attribute. Seeing as how noalias models the C99 notion of 'restrict', rename the internal clang attribute to Restrict from Malloc. llvm-svn: 228120
* [inlineasm] Fix an incorrect warning about register constraint and modifier.Akira Hatanaka2015-02-041-0/+16
| | | | | | | | | | | | | | | Previously, when the following piece of code was compiled, clang would incorrectly warn that the size of "wide_two" does not match register size specified by the constraint and modifier": long wide_two = two; asm ("%w0 %1" : "+r" (one), "+r"(wide_two)); This was caused by a miscalculation of ConstraintIdx in Sema::ActOnGCCAsmStmt. This commit fixes PR21270 and rdar://problem/18668354. llvm-svn: 228089
* Diagnose CXX 'this' pointer reference in funcs with naked attrWeiming Zhao2015-02-031-0/+15
| | | | | | | | | Clang asserts for this pointer reference in asms of naked functions. This patch diagnoses if this pointer reference is used. Differential Revision: http://reviews.llvm.org/D7329 llvm-svn: 228052
* Allow objc_bridge(id) to be used on typedefs of [cv] void*.John McCall2015-02-011-2/+2
| | | | | | rdar://19678874 llvm-svn: 227774
* Remove support for pnaclcall attributeDerek Schuff2015-01-281-2/+0
| | | | | | | | | | | | | | | | | | Summary: It was used for interoperability with PNaCl's calling conventions, but it's no longer needed. Also Remove NaCl*ABIInfo which just existed to delegate to either the portable or native ABIInfo, and remove checkCallingConvention which was now a no-op override. Reviewers: jvoung Subscribers: jfb, llvm-commits Differential Revision: http://reviews.llvm.org/D7206 llvm-svn: 227362
* PR 20146Nathan Sidwell2015-01-281-1/+1
| | | | | | make new diagnostic an ExtWarn llvm-svn: 227312
* Sema: Ensure that __c11_atomic_fetch_add has a pointer to complete typeDavid Majnemer2015-01-281-1/+5
| | | | | | | | Pointer arithmetic is only makes sense if the pointee type is complete. This fixes PR22361. llvm-svn: 227295
* Check wchar_t type on PS4.Alex Rosenberg2015-01-271-1/+1
| | | | llvm-svn: 227223
* Properly handle typos in the conditional of ?: expressions in C.Kaelyn Takata2015-01-271-0/+5
| | | | | | | | | | In particular, remove the OpaqueExpr transformation from r225389 and move the correction of the conditional from CheckConditionalOperands to ActOnConditionalOp before the OpaqueExpr is created. This fixes the typo correction behavior in C code that uses the GNU extension for a binary ?: (without an expression between the "?" and the ":"). llvm-svn: 227220
* Make the ?: precedence warning handle pointers to the left of ?Hans Wennborg2015-01-221-1/+9
| | | | | | | | | | Previously, Clang would fail to warn on: int n = x + foo ? 1 : 2; when foo is a pointer. llvm-svn: 226870
* When reporting constraints that should be constant, the type doesn'tJoerg Sonnenberger2015-01-221-6/+6
| | | | | | really help. Improve diagnostics. llvm-svn: 226863
* Initial support for Win64 SEH IR emissionReid Kleckner2015-01-221-9/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The lowering looks a lot like normal EH lowering, with the exception that the exceptions are caught by executing filter expression code instead of matching typeinfo globals. The filter expressions are outlined into functions which are used in landingpad clauses where typeinfo would normally go. Major aspects that still need work: - Non-call exceptions in __try bodies won't work yet. The plan is to outline the __try block in the frontend to keep things simple. - Filter expressions cannot use local variables until capturing is implemented. - __finally blocks will not run after exceptions. Fixing this requires work in the LLVM SEH preparation pass. The IR lowering looks like this: // C code: bool safe_div(int n, int d, int *r) { __try { *r = normal_div(n, d); } __except(_exception_code() == EXCEPTION_INT_DIVIDE_BY_ZERO) { return false; } return true; } ; LLVM IR: define i32 @filter(i8* %e, i8* %fp) { %ehptrs = bitcast i8* %e to i32** %ehrec = load i32** %ehptrs %code = load i32* %ehrec %matches = icmp eq i32 %code, i32 u0xC0000094 %matches.i32 = zext i1 %matches to i32 ret i32 %matches.i32 } define i1 zeroext @safe_div(i32 %n, i32 %d, i32* %r) { %rr = invoke i32 @normal_div(i32 %n, i32 %d) to label %normal unwind to label %lpad normal: store i32 %rr, i32* %r ret i1 1 lpad: %ehvals = landingpad {i8*, i32} personality i32 (...)* @__C_specific_handler catch i8* bitcast (i32 (i8*, i8*)* @filter to i8*) %ehptr = extractvalue {i8*, i32} %ehvals, i32 0 %sel = extractvalue {i8*, i32} %ehvals, i32 1 %filter_sel = call i32 @llvm.eh.seh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @filter to i8*)) %matches = icmp eq i32 %sel, %filter_sel br i1 %matches, label %eh.except, label %eh.resume eh.except: ret i1 false eh.resume: resume } Reviewers: rjmccall, rsmith, majnemer Differential Revision: http://reviews.llvm.org/D5607 llvm-svn: 226760
* AST: Don't ignore alignas on EnumDecls when calculating alignmentDavid Majnemer2015-01-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | We didn't consider any alignment attributes on an EnumDecl when calculating alignment. While we are here, ignore alignment specifications on typedef types if one is used as the underlying type. Otherwise, weird things happen: enum Y : int; Y y; typedef int __attribute__((aligned(64))) u; enum Y : u {}; What is the alignment of 'Y'? It would be more consistent with the overall design of enums with fixed underlying types to consider the underlying type's UnqualifiedDesugaredType. This fixes PR22279. llvm-svn: 226653
* Revert "Sema: err_after_alias is unreachable, remove it"David Majnemer2015-01-211-3/+2
| | | | | | This reverts commit r226626. err_after_alias is, in fact, reachable. llvm-svn: 226633
* Sema: err_after_alias is unreachable, remove itDavid Majnemer2015-01-211-0/+4
| | | | | | | Examples this would have catched are now handled by the attribute verification code. llvm-svn: 226626
OpenPOWER on IntegriCloud