summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* Make __builtin_object_size always answer correctlyGeorge Burgess IV2015-08-181-4/+0
| | | | | | | | | | | | | | | | | __builtin_object_size would return incorrect answers for many uses where type=3. This fixes the inaccuracy by making us emit 0 instead of LLVM's objectsize intrinsic. Additionally, there are many cases where we would emit suboptimal (but correct) answers, such as when arrays are involved. This patch fixes some of these cases (please see new tests in test/CodeGen/object-size.c for specifics on which cases are improved) Patch mostly by Richard Smith. Differential Revision: http://reviews.llvm.org/D12000 This fixes PR15212. llvm-svn: 245323
* [Sema] Be consistent about diagnostic wording: always use "cannot".Davide Italiano2015-08-152-80/+80
| | | | | | Discussed with Richard Smith. llvm-svn: 245162
* [Sema] main can't be declared as global variable, in C++.Davide Italiano2015-08-141-0/+56
| | | | | | | | | | | So, we now reject that. We also warn for any external-linkage global variable named main in C, because it results in undefined behavior. PR: 24309 Differential Revision: http://reviews.llvm.org/D11658 Reviewed by: rsmith llvm-svn: 245051
* Additional fix for PR14269: Crash on vector elements / global register vars ↵Andrey Bokhanko2015-08-031-3/+18
| | | | | | | | | | in inline assembler. Compiler crashed when vector elements / global register vars were used in inline assembler with "m" restriction. This patch fixes this. Differential Revision: http://reviews.llvm.org/D10476 llvm-svn: 243870
* Add support for System z vector language extensionsUlrich Weigand2015-07-301-0/+1009
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The z13 vector facility has an associated language extension, closely modeled on AltiVec/VSX. The main differences are: - vector long, vector float and vector pixel are not supported - vector long long and vector double are supported (like VSX) - comparison operators return a vector rather than a scalar integer - shift operators behave like the OpenCL shift operators - vector bool is only supported as argument to certain operators; some operators allow mixing a bool with a non-bool vector This patch adds clang support for the extension. It is closely modelled on the AltiVec support. Similarly to the -faltivec option, there's a new -fzvector option to enable the extensions (as well as an -mzvector alias for compatibility with GCC). There's also a separate LangOpt. The extension as implemented here is intended to be compatible with the -mzvector extension recently implemented by GCC. Based on a patch by Richard Sandiford. Differential Revision: http://reviews.llvm.org/D11001 llvm-svn: 243642
* [MS Extensions] Remove support for the i128 integer literal suffixDavid Majnemer2015-07-261-16/+2
| | | | | | | | | | | | | There is currently no support in MSVC for using i128 as an integer literal suffix. In fact, there appears to be no evidence that they have ever supported this feature in any of their compilers. This was an over generalization of their actual feature and is a nasty source of bugs. Why is it a source of bugs? Because most code in clang expects that evaluation of an integer constant expression won't give them something that 'long long' can't represent. Instead of providing a meaningful feature, i128 gives us cute ways of exploding the compiler. llvm-svn: 243243
* [Sema] The alignment of an object has an upper bound from the object file formatDavid Majnemer2015-07-261-1/+1
| | | | | | | Don't use the spelling of the alignment attribute to determine whether or not an alignment amount makes sense. llvm-svn: 243233
* Fix the equal-vector-size rule for reinterpret_casts in C++John McCall2015-07-231-0/+8
| | | | | | | | | | | | | to consider the storage size of the vector instead of its sizeof. In other words, ban <3 x int> to <4 x int> casts, which produced invalid IR anyway. Also, attempt to be a little more rigorous, or at least explicit, about when enums are allowed in these casts. rdar://21901132 llvm-svn: 243069
* Downgrade error about adding 'dllimport' to used free function to warning ↵Hans Wennborg2015-07-221-1/+1
| | | | | | | | (PR24215) The code will still work as it can reference the function via its thunk. llvm-svn: 242973
* [X86, inlineasm] Improve analysis of x,Y0,Yi,Ym,Yt,L,e,Z,s asm constraints ↵Alexey Bataev2015-07-201-0/+26
| | | | | | | | | (patch by Alexey Frolov) Improve Sema checking of 9 existing inline asm constraints (‘x’, ‘Y*’, ‘L’, ‘e’, ‘Z’, ‘s’). Differential Revision: http://reviews.llvm.org/D10536 llvm-svn: 242665
* Tests for "Disabling of "redefine_extname" pragma for C++ code"Alexey Bataev2015-07-171-0/+6
| | | | | | | In response to Richard Smith's comment (http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150622/131782.html), this patch disables "redefine_extname" pragma for C++ code. Also, I added a test that this pragma doesn't apply to static declarations. Differential Revision: http://reviews.llvm.org/D10805 llvm-svn: 242507
* __builtin_setjmp/__builtin_longjmp is support on ARM nowMatthias Braun2015-07-171-1/+0
| | | | llvm-svn: 242492
* PR10405 - Desugar FunctionType and TemplateSpecializationType if any type ↵Nikola Smiljanic2015-07-162-6/+8
| | | | | | that appears inside needs to be desugared. llvm-svn: 242371
* Add a "maximum TLS alignment" characteristic to the target info, so itPaul Robinson2015-07-141-0/+75
| | | | | | | | | | can be different from the normal variable maximum. Add an error diagnostic for when TLS variables exceed maximum TLS alignment. Currenty only PS4 sets an explicit maximum TLS alignment. Patch by Charles Li! llvm-svn: 242198
* [Sema] Emit a better diagnostic when variable redeclarations disagreeDavid Majnemer2015-07-146-30/+30
| | | | | | | | | | | We referred to all declaration in definitions in our diagnostic messages which is can be inaccurate. Instead, classify the declaration and emit an appropriate diagnostic for the new declaration and an appropriate note pointing to the old one. This fixes PR24116. llvm-svn: 242190
* Fixed 22941: Integer template parameter as immediate 'I' expectes an integer ↵Sunil Srivastava2015-07-141-0/+25
| | | | | | | | | constant Basically fixed premature testing of integer constraints during template parsing Reviewed at http://reviews.llvm.org/D10452 llvm-svn: 242175
* Support alternate attribute spelling __enable_if__Ulrich Weigand2015-07-131-0/+15
| | | | | | | | | | | | | | | | | | | | Attribute names usually support an alternate spelling that uses double underscores before and after the attribute name, like e.g. attribute ((__aligned__)) for attribute ((aligned)). This is necessary to allow use of attributes in system headers without polluting the name space. However, for attribute ((enable_if)) that alternate spelling does not work correctly. This is because of code in Parser::ParseGNUAttributeArgs (ParseDecl.cpp) that specifically checks for the "enable_if" spelling without allowing the alternate spelling. Similar code in ParseDecl.cpp uses the normalizeAttrName helper to allow both spellings. This patch adds use of that helper for the "enable_if" check as well, which fixes attribute ((__enable_if__)). Differential Revision: http://reviews.llvm.org/D11142 llvm-svn: 242029
* Revert "Revert r241620 and follow-up commits" and move the initializationAdrian Prantl2015-07-081-1/+1
| | | | | | of the llvm targets from clang/CodeGen into ClangCheck.cpp and CIndex.cpp. llvm-svn: 241653
* Revert r241620 and follow-up commits while investigating linux buildbot ↵Adrian Prantl2015-07-071-1/+1
| | | | | | failures. llvm-svn: 241642
* Add target requirements to testcases that emit PCH.Adrian Prantl2015-07-071-1/+1
| | | | llvm-svn: 241630
* [Sema] Warn when shifting a negative value.Davide Italiano2015-07-061-2/+3
| | | | | | | | | | | | | | | Example: % ./clang -Wshift-negative-value emit.c emit.c:3:14: warning: shifting a negative signed value is undefined [-Wshift-negative-value] int a = -1 << 3; ~~ ^ 1 warning generated. PR: 24026 Differential Revision: http://reviews.llvm.org/D10938 Reviewed by: rsmith llvm-svn: 241478
* Add support for the x86 builtin __builtin_cpu_supports.Eric Christopher2015-06-291-0/+21
| | | | | | | | | | | | | | | | | | | | This matches the implementation of the gcc support for the same feature, including checking the values set up by libgcc at runtime. The structure looks like this: unsigned int __cpu_vendor; unsigned int __cpu_type; unsigned int __cpu_subtype; unsigned int __cpu_features[1]; with a set of enums to match various fields that are field out after parsing the output of the cpuid instruction. This also adds a set of errors checking for valid input (and cpu). compiler-rt support for this and the other builtins in this family (__builtin_cpu_init and __builtin_cpu_is) are forthcoming. llvm-svn: 240994
* Account for calling convention specifiers in function definitions in IR test ↵David Blaikie2015-06-292-3/+3
| | | | | | | | | | | | | cases Several tests wouldn't pass when executed on an armv7a_pc_linux triple due to the non-default arm_aapcs calling convention produced on the function definitions in the IR output. Account for this with the application of a little regex. Patch by Ying Yi. llvm-svn: 240971
* Replace __double_underscored type nullability qualifiers with ↵Douglas Gregor2015-06-242-56/+56
| | | | | | | | | | | | | | | | _Uppercase_underscored Addresses a conflict with glibc's __nonnull macro by renaming the type nullability qualifiers as follows: __nonnull -> _Nonnull __nullable -> _Nullable __null_unspecified -> _Null_unspecified This is the major part of rdar://problem/21530726, but does not yet provide the Darwin-specific behavior for the old names. llvm-svn: 240596
* Improve error handling for PR22560.Bob Wilson2015-06-231-0/+9
| | | | | | | | | The ARM _MoveToCoprocessor and _MoveFromCoprocessor builtins require integer constants for most arguments, but clang was not checking that. With this change, we now report meaningful errors instead of crashing in the backend. llvm-svn: 240463
* Make the typo resolution in r240441 apply to all function calls.Kaelyn Takata2015-06-231-0/+5
| | | | | | | | | | Regular function calls (such as to cabs()) run into the same problem with handling dependent exprs, not just builtins with custom type checking. Fixes PR23775. llvm-svn: 240443
* Ensure delayed typos have been corrected in calls to builtins beforeKaelyn Takata2015-06-231-0/+4
| | | | | | | | | checking those calls when not in C++ mode, since those code paths can't handle dependent exprs. Fixes PR23740. llvm-svn: 240441
* Diagnose unsafe uses of nil and __nonnull pointers.Douglas Gregor2015-06-192-1/+34
| | | | | | | | | | | | | | | | | | | This generalizes the checking of null arguments to also work with values of pointer-to-function, reference-to-function, and block pointer type, using the nullability information within the underling function prototype to extend non-null checking, and diagnoses returns of 'nil' within a function with a __nonnull return type. Note that we don't warn about nil returns from Objective-C methods, because it's common for Objective-C methods to mimic the nil-swallowing behavior of the receiver by checking ostensibly non-null parameters and returning nil from otherwise non-null methods in that case. It also diagnoses (via a separate flag) conversions from nullable to nonnull pointers. It's a separate flag because this warning can be noisy. llvm-svn: 240153
* Introduce type nullability specifiers for C/C++.Douglas Gregor2015-06-192-0/+122
| | | | | | | | | | | | | | | | | | | | | | | | | Introduces the type specifiers __nonnull, __nullable, and __null_unspecified that describe the nullability of the pointer type to which the specifier appertains. Nullability type specifiers improve on the existing nonnull attributes in a few ways: - They apply to types, so one can represent a pointer to a non-null pointer, use them in function pointer types, etc. - As type specifiers, they are syntactically more lightweight than __attribute__s or [[attribute]]s. - They can express both the notion of 'should never be null' and also 'it makes sense for this to be null', and therefore can more easily catch errors of omission where one forgot to annotate the nullability of a particular pointer (this will come in a subsequent patch). Nullability type specifiers are maintained as type sugar, and therefore have no effect on mangling, encoding, overloading, etc. Nonetheless, they will be used for warnings about, e.g., passing 'null' to a method that does not accept it. This is the C/C++ part of rdar://problem/18868820. llvm-svn: 240146
* [ATTRIBUTE] Fixed test compatibility.Alexey Bataev2015-06-191-1/+1
| | | | llvm-svn: 240126
* [ATTRIBUTE] Support base vector types of __attribute__((mode)), patch by ↵Alexey Bataev2015-06-191-0/+26
| | | | | | | | | | | | Alexey Frolov Base type of attribute((mode)) can actually be a vector type. The patch is to distinguish between base type and base element type. This fixes http://llvm.org/PR17453. Differential Revision: http://reviews.llvm.org/D10058 llvm-svn: 240125
* Add -Winfinite-recursion to -Wmost (and -Wall), PR23789.Nico Weber2015-06-181-1/+1
| | | | llvm-svn: 240056
* This patch implements clang support for the ACLE special register intrinsicsLuke Cheeseman2015-06-152-0/+166
| | | | | | | | | | | | | in section 10.1, __arm_{w,r}sr{,p,64}. This includes arm_acle.h definitions with builtins and codegen to support these, the intrinsics are implemented by generating read/write_register calls which get appropriately lowered in the backend based on the register string provided. SemaChecking is also implemented to fault invalid parameters. Differential Revision: http://reviews.llvm.org/D9697 llvm-svn: 239737
* Quote the user provided string in the warning message and updateEric Christopher2015-06-121-2/+2
| | | | | | tests accordingly. llvm-svn: 239635
* Add a warning for unsupported elements of the target attribute.Eric Christopher2015-06-121-0/+2
| | | | | | | | | Since we're ignoring the tune= and fpmath= attributes go ahead and add a warning alerting people to the fact that we're going to ignore that part of it during code generation and tie it to the attribute warning set. llvm-svn: 239583
* Add support for the the target attribute.Eric Christopher2015-06-121-0/+6
| | | | | | | | | | | | | | | Modeled after the gcc attribute of the same name, this feature allows source level annotations to correspond to backend code generation. In llvm particular parlance, this allows the adding of subtarget features and changing the cpu for a particular function based on source level hints. This has been added into the existing support for function level attributes without particular verification for any target outside of whether or not the backend will support the features/cpu given (similar to section, etc). llvm-svn: 239579
* some StmtExprs do not have side-effectsScott Douglass2015-06-101-0/+9
| | | | | | Differential Revision: http://reviews.llvm.org/D10211 llvm-svn: 239476
* Implementing C99 partial re-initialization behavior (DR-253)Yunzhong Gao2015-06-101-7/+17
| | | | | | | | | | | | | | | | | | | | | | | | | Based on previous discussion on the mailing list, clang currently lacks support for C99 partial re-initialization behavior: Reference: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-April/029188.html Reference: http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_253.htm This patch attempts to fix this problem. Given the following code snippet, struct P1 { char x[6]; }; struct LP1 { struct P1 p1; }; struct LP1 l = { .p1 = { "foo" }, .p1.x[2] = 'x' }; // this example is adapted from the example for "struct fred x[]" in DR-253; // currently clang produces in l: { "\0\0x" }, // whereas gcc 4.8 produces { "fox" }; // with this fix, clang will also produce: { "fox" }; Differential Review: http://reviews.llvm.org/D5789 llvm-svn: 239446
* Move target-specific Sema test to its own file.Jonathan Roelofs2015-06-092-6/+9
| | | | | | Fixing the build-break introduced in r239406. llvm-svn: 239407
* Fix printing of GCCAsmExprs with input or output arguments.Jonathan Roelofs2015-06-091-0/+6
| | | | | | Patch by Nick Sumner! llvm-svn: 239406
* Consider unsigned long for non-u/U decimal literals (C90/C++03)Hubert Tong2015-06-081-0/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This modifies Clang to reflect that under pre-C99 ISO C, decimal constants may have type `unsigned long` even if they do not contain `u` or `U` in their suffix (C90 subclause 6.1.3.2 paragraph 5). The same is done for C++ without C++11 which--because of undefined behaviour--allows for behaviour compatible with ISO C90 in the case of an unsuffixed decimal literal and is otherwise identical to C90 in its treatment of integer literals (C++03 subclause 2.13.1 [lex.icon] paragraph 2). Messages are added to the `c99-compat` and `c++11-compat` groups to warn on such literals, since they behave differently under the newer standards. Fixes PR 16678. Test Plan: A new test file is added to exercise both pre-C99/C++11 and C99/C++11-up on decimal literals with no suffix or suffixes `l`/`L` for both 32-bit and 64-bit `long`. In the file, 2^31 (being `INT_MAX+1`) is tested for the expected type using `__typeof__` and multiple declarations of the same entity. 2^63 is similarly tested when it is within the range of `unsigned long`. Preprocessor arithmetic tests are added to ensure consistency given that Clang (like GCC) uses greater than 32 bits for preprocessor arithmetic even when `long` and `unsigned long` is 32 bits and a pre-C99/C++11 mode is in effect. Tests added: test/Sema/PR16678.c Reviewers: fraggamuffin, rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D9794 llvm-svn: 239356
* Fix for PR14269: Clang crashes when a bit field is used as inline assemblerAlexander Musman2015-06-051-0/+17
| | | | | | | | | | | | input / output with memory constraint. One generally can't get address of a bit field, so the general solution is to error on such cases. GCC does the same. Patch by Andrey Bokhanko Differential Revision: http://reviews.llvm.org/D10086 llvm-svn: 239153
* Fix PR21945: Crash in constant evaluator.Jonathan Roelofs2015-06-011-0/+3
| | | | | | Patch by Косов Евгений! llvm-svn: 238758
* AST: Fix printing GNU old-style field designatorsJustin Bogner2015-05-281-0/+8
| | | | | | | | | | | | Allows StmtPrinter to print old style field designators in initializers, fixing an issue where we would print the following invalid code: struct A a = {b: = 3, .c = 4}; Patch by Nick Sumner. Thanks! llvm-svn: 238517
* __declspec is not a core Clang language extension. Instead, require ↵Aaron Ballman2015-05-264-10/+10
| | | | | | | -fms-extensions or -fborland to enable the language extension. Note: __declspec is also temporarily enabled when compiling for a CUDA target because there are implementation details relying on __declspec(property) support currently. When those details change, __declspec should be disabled for CUDA targets. llvm-svn: 238238
* [Sema] Don't use dyn_cast to detect an AtomicTypeDavid Majnemer2015-05-231-0/+5
| | | | | | | | | | An AtomicType might be hidden behind arbitrary levels of typedefs. getAs<> will reliably walk through the sugar to get the underlying AtomicType. This fixes PR23638. llvm-svn: 238083
* Fix assertion when assigning to object in OpenCL constant address space.Richard Smith2015-05-221-0/+8
| | | | | | Patch by John Garvin! llvm-svn: 237983
* Check for bool-like conversion in conditional expressions.Richard Trieu2015-05-202-4/+30
| | | | | | | | | | Add a check for bool-like conversions for the condition expression of conditional operators. This is similiar to the checking of condition expressions of if statements, for-loops, while-loops, and do-while loops. Specificially, this is to fix the problem of assert("message") not triggering -Wstring-conversion when the assert macro uses a conditional operator. llvm-svn: 237856
* Eagerly correct typos in ParenExprs that may be type casts for non-C++ code.Kaelyn Takata2015-05-011-0/+6
| | | | | | | This is needed to ensure the type casts are parsed properly. Fixes PR23101. llvm-svn: 236337
* Don't warn about use of deprecated API when the containing context is ↵Jordan Rose2015-04-301-6/+6
| | | | | | | | | | unavailable. This probably won't come up much, but it seems tidier. Related to rdar://problem/20713550 llvm-svn: 236242
OpenPOWER on IntegriCloud