summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* Use dotted format of version tuple for availability diagnosticsJan Korous2018-05-171-0/+15
| | | | | | | | | | | | E. g. use "10.11" instead of "10_11". We are maintaining backward compatibility by parsing underscore-delimited version tuples but no longer keep track of the separator and using dot format for output. Differential Revision: https://reviews.llvm.org/D46747 rdar://problem/39845032 llvm-svn: 332598
* [AST] Fix printing tag decl groups in decl contextsJoel E. Denny2018-05-151-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For example, given: struct T1 { struct T2 *p0; }; -ast-print produced: struct T1 { struct T2; struct T2 *p0; }; Compiling that produces a warning that the first struct T2 declaration does not declare anything. Details: A tag decl group is one or more decls that share a type specifier that is a tag decl (that is, a struct/union/class/enum decl). Within functions, the parser builds such a tag decl group as part of a DeclStmt. However, in decl contexts, such as file scope or a member list, the parser does not group together the members of a tag decl group. Previously, detection of tag decl groups during printing was implemented but only if the tag decl was unnamed. Otherwise, as in the above example, the members of the group did not print together and so sometimes introduced warnings. This patch extends detection of tag decl groups in decl contexts to any tag decl that is recorded in the AST as not free-standing. Reviewed by: rsmith Differential Revision: https://reviews.llvm.org/D45465 llvm-svn: 332314
* Added atomic_fetch_min, max, umin, umax intrinsics to clang.Elena Demikhovsky2018-05-131-0/+17
| | | | | | | | | These intrinsics work exactly as all other atomic_fetch_* intrinsics and allow to create *atomicrmw* with ordering. Updated the clang-extensions document. Differential Revision: https://reviews.llvm.org/D46386 llvm-svn: 332193
* [Clang] Implement function attribute no_stack_protector.Manoj Gupta2018-05-091-0/+5
| | | | | | | | | | | | | | | | | | | | | | Summary: This attribute tells clang to skip this function from stack protector when -stack-protector option is passed. GCC option for this is: __attribute__((__optimize__("no-stack-protector"))) and the equivalent clang syntax would be: __attribute__((no_stack_protector)) This is used in Linux kernel to selectively disable stack protector in certain functions. Reviewers: aaron.ballman, rsmith, rnk, probinson Reviewed By: aaron.ballman Subscribers: probinson, srhines, cfe-commits Differential Revision: https://reviews.llvm.org/D46300 llvm-svn: 331925
* Disallow pointers to const in __sync_fetch_and_xxx.Aaron Ballman2018-05-051-0/+5
| | | | | | | | | | | | Diagnoses code like: void f(const int *ptr) { __sync_fetch_and_add(ptr, 1); } which matches the behavior of GCC and ICC. llvm-svn: 331598
* [Targets] Implement getConstraintRegister for ARM and AArch64Mikhail Maltsev2018-04-302-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The getConstraintRegister method is used by semantic checking of inline assembly statements in order to diagnose conflicts between clobber list and input/output lists. Currently ARM and AArch64 don't override getConstraintRegister, so conflicts between registers assigned to variables in asm labels and clobber lists are not diagnosed. Such conflicts can cause assertion failures in the back end and even miscompilations. This patch implements getConstraintRegister for ARM and AArch64 targets. Since these targets don't have single-register constraints, the implementation is trivial and just returns the register specified in an asm label (if any). Reviewers: eli.friedman, javed.absar, thopre Reviewed By: thopre Subscribers: rengolin, eraman, rogfer01, myatsina, kristof.beyls, cfe-commits, chrib Differential Revision: https://reviews.llvm.org/D45965 llvm-svn: 331164
* [X86] Make __builtin_ia32_readeflags_u32 and __builtin_ia32_writeeflags_u32 ↵Craig Topper2018-04-261-0/+5
| | | | | | | | | | | | only available on 32-bit targets. These builtins can't be handled by the backend on 64-bit targets. So error up front instead of throwing an isel error. Fixes PR37225 Differential Revision: https://reviews.llvm.org/D46132 llvm-svn: 330987
* [Attr] Print enum attributes at correct positionJoel E. Denny2018-04-241-7/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For example, given: void fn() { enum __attribute__((deprecated)) T *p; } -ast-print produced: void fn() { enum T __attribute__((deprecated(""))) *p; } -ast-print on that produced: void fn() { enum T *p __attribute__((deprecated(""))); } The attribute is on enum T in the first case, but it's on p in the other cases. Details: Within enum declarations, enum attributes were always printed after the tag and any member list. When no member list was present but the enum was a type specifier in a variable declaration, the attribute then applied to the variable not the enum, changing the semantics. This patch fixes that by always printing attributes between the enum's keyword and tag, as clang already does for structs, unions, and classes. Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D45456 llvm-svn: 330722
* Limit types of builtins that can be redeclared.Erich Keane2018-04-161-0/+18
| | | | | | | | | | | | | | | | | | As reported here: https://bugs.llvm.org/show_bug.cgi?id=37033 Any usage of a builtin function that uses a va_list by reference will cause an assertion when redeclaring it. After discussion in the review, it was concluded that the correct way of accomplishing this fix is to make attempts to redeclare certain builtins an error. Unfortunately, doing this limitation for all builtins is likely a breaking change, so this commit simply limits it to types with custom type checking and those that take a reference. Two tests needed to be updated to make this work. Differential Revision: https://reviews.llvm.org/D45383 llvm-svn: 330160
* Introduce a new builtin, __builtin_dump_struct, that is useful for dumping ↵Aaron Ballman2018-04-101-0/+42
| | | | | | | | structure contents at runtime in circumstances where debuggers may not be easily available (such as in kernel work). Patch by Paul Semel. llvm-svn: 329762
* Fix typos in clangAlexander Kornienko2018-04-0610-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 llvm-svn: 329399
* [Diag] Avoid emitting a redefinition note if no location is available.Matt Davis2018-03-281-0/+1
| | | | | | | | | | | | | | | | | Summary: The "previous definition is here" note is not helpful if there is no location information. The note will reference nothing in such a case. This patch first checks to see if there is location data, and if so the note diagnostic is emitted. This fixes PR15409. The issue in the first comment seems to already be resolved. This patch addresses the second example. Reviewers: bruno, rsmith Reviewed By: bruno Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44901 llvm-svn: 328712
* Fix some handling of AST nodes with diagnostics.Richard Trieu2018-03-281-10/+10
| | | | | | | | | The diagnostic system for Clang can already handle many AST nodes. Instead of converting them to strings first, just hand the AST node directly to the diagnostic system and let it handle the output. Minor changes in some diagnostic output. llvm-svn: 328688
* [Sema] Emit -Winteger-overflow for arguments in function calls, ObjC messages.Volodymyr Sapsai2018-03-271-0/+15
| | | | | | | | | | | | | | rdar://problem/35539384 Reviewers: ahatanak, nicholas, rsmith, jkorous-apple Reviewed By: jkorous-apple Subscribers: cfe-commits, jkorous-apple Differential Revision: https://reviews.llvm.org/D42938 llvm-svn: 328671
* [AMDGPU] Fix codegen for inline assemblyYaxun Liu2018-03-231-0/+5
| | | | | | | | Need to override convertConstraint to recognise amdgpu specific register names. Differential Revision: https://reviews.llvm.org/D44533 llvm-svn: 328359
* Basic: support PreserveMost and PreserveAll on Windows ARMSaleem Abdulrasool2018-03-201-0/+1
| | | | | | | Do not ignore these calling conventions on Windows ARM. They are used by the swift runtime for certain calls. llvm-svn: 328007
* Adding nocf_check attribute for cf-protection fine tuningOren Ben Simhon2018-03-173-0/+51
| | | | | | | | | | The patch adds nocf_check target independent attribute for disabling checks that were enabled by cf-protection flag. The attribute can be appertained to functions and function pointers. Attribute name follows GCC's similar attribute name. Differential Revision: https://reviews.llvm.org/D41880 llvm-svn: 327768
* More warnings when double truncation to float: compound assignment is ↵Andrew V. Tischenko2018-03-151-1/+6
| | | | | | supported now. llvm-svn: 327618
* [Attr] Merge two dependent tests from different directoriesJoel E. Denny2018-03-131-69/+0
| | | | | | Suggested at: https://reviews.llvm.org/D43248 llvm-svn: 327456
* Reland "[Attr] Fix parameter indexing for several attributes"Joel E. Denny2018-03-133-5/+104
| | | | | | | | | Relands r326602 (reverted in r326862) with new test and fix for PR36620. Differential Revision: https://reviews.llvm.org/D43248 llvm-svn: 327405
* Revert r326602, it caused PR36620.Nico Weber2018-03-073-102/+5
| | | | llvm-svn: 326862
* Amend r326665 to print out the `used` attribute subjects in a different order.Aaron Ballman2018-03-041-2/+2
| | | | llvm-svn: 326676
* Create a subject list for the `used` attribute rather than use custom ↵Aaron Ballman2018-03-031-2/+2
| | | | | | | | checking logic. This changes the diagnostic wording somewhat, but otherwise intends no functional change to the attribute. llvm-svn: 326665
* Don't claim that va_start has special semantic checksReid Kleckner2018-03-021-0/+9
| | | | | | | | | | | | | | We don't have special checks for BI_va_start in Sema::CheckBuiltinFunctionCall, so setting the 't' flag for va_start in Builtins.def disables semantic checking for it. That's not desired, and IRGen crashes when it tries to generate a call to va_start that doesn't have at least one argument. Follow-up to r322573 Fixes PR36565 llvm-svn: 326622
* [Attr] Use -fsyntax-only in testJoel E. Denny2018-03-021-1/+1
| | | | | | Suggested at: https://reviews.llvm.org/D43248 llvm-svn: 326603
* [Attr] Fix parameter indexing for several attributesJoel E. Denny2018-03-023-5/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The patch fixes a number of bugs related to parameter indexing in attributes: * Parameter indices in some attributes (argument_with_type_tag, pointer_with_type_tag, nonnull, ownership_takes, ownership_holds, and ownership_returns) are specified in source as one-origin including any C++ implicit this parameter, were stored as zero-origin excluding any this parameter, and were erroneously printing (-ast-print) and confusingly dumping (-ast-dump) as the stored values. * For alloc_size, the C++ implicit this parameter was not subtracted correctly in Sema, leading to assert failures or to silent failures of __builtin_object_size to compute a value. * For argument_with_type_tag, pointer_with_type_tag, and ownership_returns, the C++ implicit this parameter was not added back to parameter indices in some diagnostics. This patch fixes the above bugs and aims to prevent similar bugs in the future by introducing careful mechanisms for handling parameter indices in attributes. ParamIdx stores a parameter index and is designed to hide the stored encoding while providing accessors that require each use (such as printing) to make explicit the encoding that is needed. Attribute declarations declare parameter index arguments as [Variadic]ParamIdxArgument, which are exposed as ParamIdx[*]. This patch rewrites all attribute arguments that are processed by checkFunctionOrMethodParameterIndex in SemaDeclAttr.cpp to be declared as [Variadic]ParamIdxArgument. The only exception is xray_log_args's argument, which is encoded as a count not an index. Differential Revision: https://reviews.llvm.org/D43248 llvm-svn: 326602
* Improve the way attribute argument printing happens for omitted optional ↵Aaron Ballman2018-02-272-0/+9
| | | | | | | | arguments when pretty printing. Patch by Joel Denny. llvm-svn: 326266
* When diagnosing the arguments to alloc_size, report the failing argument ↵Aaron Ballman2018-02-251-6/+6
| | | | | | | | using a 1-based index instead of a 0-based index for consistency. Patch by Joel Denny. llvm-svn: 326058
* Fix a failing assertion with the pointer_with_type_tag attribute when the ↵Aaron Ballman2018-02-251-0/+4
| | | | | | | | function the attribute appertains to is variadic. Patch by Joel Denny. llvm-svn: 326057
* Add a C2x spelling for the external_source_symbol and internal_linkage ↵Aaron Ballman2018-02-252-2/+20
| | | | | | | | attributes in the clang vendor namespace. Both of these attributes have existing meaning in C code, so there was no reason to exclude them from using the new spelling. llvm-svn: 326053
* Add a C++11 and C2x spelling for the type safety attribute ↵Aaron Ballman2018-02-252-2/+47
| | | | | | | | (argument_with_type_tag, pointer_with_type_tag, and type_tag_for_datatype) in the clang vendor namespace. The TypeTagForDatatype attribute had custom parsing rules that previously prevented it from being supported with square bracket notation. The ArgumentWithTypeTag attribute previously had unnecessary custom parsing that could be handled declaratively. llvm-svn: 326052
* Add a C++11 and C2x spelling for the objc_bridge_related attribute in the ↵Aaron Ballman2018-02-241-0/+7
| | | | | | | | clang vendor namespace. This attribute has custom parsing rules that previously prevented it from being supported with square bracket notation. llvm-svn: 326038
* Add a C++11 and C2x spelling for the availability attribute in the clang ↵Aaron Ballman2018-02-241-0/+25
| | | | | | | | vendor namespace. This attribute has custom parsing rules that previously prevented it from being supported with square bracket notation. Rework the clang attribute argument parsing to be more easily extended for other custom-parsed attributes. llvm-svn: 326036
* Add another test for PR36157.Richard Smith2018-02-241-0/+8
| | | | llvm-svn: 325998
* Correct multiversion unsupported target behavior, add a test.Erich Keane2018-02-201-0/+12
| | | | | | | | | | Multiversioning SEMA failed to set the declaration as invalid on unsupported targets. This patch does that. Additionally, I noticed that there is no test to validate this error message. This patch adds one, and uses 'mips' as the test architecture. llvm-svn: 325610
* Add several more attributes to be parsed in C with [[]] when ↵Aaron Ballman2018-02-191-0/+26
| | | | | | | | -fdouble-square-bracket-attributes is specified. Also flags a few attributes that should not be available with the C spelling as they only matter in C++. llvm-svn: 325520
* Clean up 'target' attribute diagnosticsErich Keane2018-02-162-9/+21
| | | | | | | | | | | | | | There were a few issues previously with the target attribute diagnostics implementation that lead to the attribute being added to the AST despite having an error in it. This patch changes that, and adds a test to ensure it does not get added to the AST. Differential Revision: https://reviews.llvm.org/D43359 llvm-svn: 325364
* [ARM] Add tests for the vcvtr builtinsSjoerd Meijer2018-02-161-0/+15
| | | | | | | | | This adds Sema and Codegen tests for the vcvtr builtins (because they were missing). Differential Revision: https://reviews.llvm.org/D43372 llvm-svn: 325351
* Implement function attribute artificialErich Keane2018-02-141-0/+4
| | | | | | | | | | | | Added support in clang for GCC function attribute 'artificial'. This attribute is used to control stepping behavior of debugger with respect to inline functions. Patch By: Elizabeth Andrews (eandrews) Differential Revision: https://reviews.llvm.org/D43259 llvm-svn: 325081
* Teach Wreturn-type, Wunreachable-code, and alpha.deadcode.UnreachableCode to ↵Nico Weber2018-02-132-0/+16
| | | | | | | | | treat __assume(0) like __builtin_unreachable. Fixes PR29134. https://reviews.llvm.org/D43221 llvm-svn: 325052
* An updated test to show the current warnings produced for implicit ↵Andrew V. Tischenko2018-02-131-0/+14
| | | | | | conversions from 'double' to 'float'. llvm-svn: 325011
* [Sema] Don't mark plain MS enums as fixedReid Kleckner2018-02-121-13/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This fixes a flaw in our AST: PR27098 MSVC always gives plain enums the underlying type 'int'. Clang does this as well, but we claim the enum is "fixed", as if the user actually wrote ': int'. It means we end up emitting spurious -Wsign-compare warnings on code like this: enum Vals { E1, E2, E3 }; bool f(unsigned v1, Vals v2) { return v1 == v2; } We think 'v2' can take on negative values because we think 'Vals' is fixed. This fixes that. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43110 llvm-svn: 324913
* Fif for an issue when Clang permits assignment to vector/extvector elements ↵Andrew V. Tischenko2018-02-092-6/+6
| | | | | | in a const method. llvm-svn: 324721
* PR36307: Consume the #pragma options align annotation token afterAlex Lorenz2018-02-082-0/+10
| | | | | | | | | semantic analysis to prevent incorrect -Wpragma-pack warning for an included file rdar://37354951 llvm-svn: 324651
* [PR36008] Avoid -Wsign-compare warning for enum constants inAlex Lorenz2018-02-071-0/+13
| | | | | | | | | | | | | typeof expressions This commit looks through typeof type at the original expression when diagnosing -Wsign-compare to avoid an unfriendly diagnostic. rdar://36588828 Differential Revision: https://reviews.llvm.org/D42561 llvm-svn: 324514
* PR36157: When injecting an implicit function declaration in C89, find the rightRichard Smith2018-02-012-0/+13
| | | | | | | | DeclContext rather than injecting it wherever we happen to be. This avoids creating functions whose DeclContext is a struct or similar. llvm-svn: 323998
* [PR32482] Fix bitfield layout for -mms-bitfield and pragma packAlex Lorenz2018-01-311-0/+15
| | | | | | | | | | | The patch ensures that a new storage unit is created when the new bitfield's size is wider than the available bits. rdar://36343145 Differential Revision: https://reviews.llvm.org/D42660 llvm-svn: 323921
* 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
* Remove TautologicalInRangeCompare from Extra and TautologicalCompare.Nico Weber2018-01-181-2/+2
| | | | | | | | | | | | | | | | | | | | | This removes the following (already default-off) warnings from -Wextra: -Wtautological-type-limit-compare, -Wtautological-unsigned-zero-compare -Wtautological-unsigned-enum-zero-compare On the thread "[cfe-dev] -Wtautological-constant-compare issues", clang code owners Richard Smith, John McCall, and Reid Kleckner as well as libc++ code owner Marshall Clow stated that these new warnings are not yet ready for prime time and shouldn't be part of -Wextra. Furthermore, Vedant Kumar (Apple), Peter Hosek (Fuchsia), and me (Chromium) expressed the same concerns (Vedant on that thread, Peter on https://reviews.llvm.org/D39462, me on https://reviews.llvm.org/D41512). So remove them from -Wextra, and remove TautologicalInRangeCompare from TautologicalCompare too until they're usable with real-world code. llvm-svn: 322901
* [Sema] Allow conversion between long double and __float128.Benjamin Kramer2018-01-171-0/+3
| | | | | | | We should only ban this if long double is a double double. x86's 80 bit long double is fine and supported by the backend. llvm-svn: 322779
OpenPOWER on IntegriCloud