Vendor import of clang release_80 branch r354130:

https://llvm.org/svn/llvm-project/cfe/branches/release_80@354130
This commit is contained in:
Dimitry Andric 2019-02-15 20:49:05 +00:00
parent d87c9e7da2
commit 5df36aae64
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/clang/dist-release_80/; revision=344168
svn path=/vendor/clang/clang-release_80-r354130/; revision=344169; tag=vendor/clang/clang-release_80-r354130
58 changed files with 5910 additions and 451 deletions

File diff suppressed because it is too large Load Diff

View File

@ -198,6 +198,10 @@ Filename (or -) to write dependency output to
Emit Clang AST files for source inputs
.. option:: -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang<arg>
Trivial automatic variable initialization to zero is only here for benchmarks, it'll eventually be removed, and I'm OK with that because I'm only using it to benchmark
.. option:: -exported\_symbols\_list <arg>
.. option:: -faligned-new=<arg>
@ -210,10 +214,6 @@ Use approximate transcendental functions
Flush denormal floating point values to zero in CUDA device mode.
.. option:: -fcuda-rdc, -fno-cuda-rdc
Generate relocatable device code, also known as separate compilation mode.
.. option:: -fcuda-short-ptr, -fno-cuda-short-ptr
Use 32-bit pointers for accessing const/local/shared address spaces.
@ -222,6 +222,10 @@ Use 32-bit pointers for accessing const/local/shared address spaces.
Reserve register r19 (Hexagon only)
.. option:: -fgpu-rdc, -fcuda-rdc, -fno-gpu-rdc
Generate relocatable device code, also known as separate compilation mode.
.. option:: -fheinous-gnu-extensions
.. option:: -flat\_namespace
@ -254,6 +258,10 @@ Use the gcc toolchain at the given directory
Generate CodeView debug information
.. option:: -gcodeview-ghash, -gno-codeview-ghash
Emit type record hashes in a .debug$H section
.. option:: -headerpad\_max\_install\_names<arg>
.. option:: -help, --help
@ -288,6 +296,10 @@ Make the next included directory (-I or -F) an indexer header map
.. option:: -mbig-endian, -EB
.. option:: -mbranch-protection=<arg>
Enforce targets of indirect branches and function returns
.. option:: --migrate
Run the migrator
@ -792,15 +804,7 @@ Don't use blacklist file for sanitizers
.. option:: -fparse-all-comments
.. option:: -frecord-command-line, -frecord-gcc-switches, -fno-record-command-line, -fno-record-gcc-switches
Generate a section named ".GCC.command.line" containing the clang driver
command-line. After linking, the section may contain multiple command lines,
which will be individually terminated by null bytes. Separate arguments within
a command line are combined with spaces; spaces and backslashes within an
argument are escaped with backslashes. This format differs from the format of
the equivalent section produced by GCC with the -frecord-gcc-switches flag.
This option is currently only supported on ELF targets.
.. option:: -frecord-command-line, -fno-record-command-line, -frecord-gcc-switches
.. option:: -fsanitize-address-field-padding=<arg>
@ -810,20 +814,18 @@ Level of field padding for AddressSanitizer
Enable linker dead stripping of globals in AddressSanitizer
.. option:: -fsanitize-address-use-odr-indicator, -fno-sanitize-address-use-odr-indicator
Enable ODR indicator globals to avoid false ODR violation reports in partially sanitized programs at the cost of an increase in binary size
.. option:: -fsanitize-address-poison-custom-array-cookie, -fno-sanitize-address-poison-custom-array-cookie
Enable "poisoning" array cookies when allocating arrays with a custom operator new\[\] in Address Sanitizer, preventing accesses to the cookies from user code. An array cookie is a small implementation-defined header added to certain array allocations to record metadata such as the length of the array. Accesses to array cookies from user code are technically allowed by the standard but are more likely to be the result of an out-of-bounds array access.
An operator new\[\] is "custom" if it is not one of the allocation functions provided by the C++ standard library. Array cookies from non-custom allocation functions are always poisoned.
Enable poisoning array cookies when using custom operator new\[\] in AddressSanitizer
.. option:: -fsanitize-address-use-after-scope, -fno-sanitize-address-use-after-scope
Enable use-after-scope detection in AddressSanitizer
.. option:: -fsanitize-address-use-odr-indicator, -fno-sanitize-address-use-odr-indicator
Enable ODR indicator globals to avoid false ODR violation reports in partially sanitized programs at the cost of an increase in binary size
.. option:: -fsanitize-blacklist=<arg>
Path to blacklist file for sanitizers
@ -840,6 +842,10 @@ Generalize pointers in CFI indirect call type signature checks
Specify the type of coverage instrumentation for Sanitizers
.. option:: -fsanitize-hwaddress-abi=<arg>
Select the HWAddressSanitizer ABI to target (interceptor or platform, default interceptor)
.. option:: -fsanitize-link-c++-runtime
.. option:: -fsanitize-memory-track-origins, -fno-sanitize-memory-track-origins
@ -1072,6 +1078,10 @@ Set directory to include search path with prefix
Add directory to SYSTEM include search path, absolute paths are relative to -isysroot
.. option:: --libomptarget-nvptx-path=<arg>
Path to libomptarget-nvptx libraries
.. option:: --ptxas-path=<arg>
Path to ptxas (used for compiling CUDA code)
@ -1283,6 +1293,8 @@ Enable C++ static destructor registration (the default)
Instrument control-flow architecture protection. Options: return, branch, full, none.
.. option:: -fcf-runtime-abi=<arg>
.. option:: -fchar8\_t, -fno-char8\_t
Enable C++ builtin type char8\_t
@ -1343,6 +1355,10 @@ Emit macro debug information
remap file source paths in debug info
.. option:: -fdebug-ranges-base-address, -fno-debug-ranges-base-address
Use DWARF base address selection entries in debug\_ranges
.. option:: -fdebug-types-section, -fno-debug-types-section
Place debug types in their own section (ELF Only)
@ -1651,6 +1667,8 @@ Synthesize retain and release calls for Objective-C pointers
Use EH-safe code when synthesizing retains and releases in -fobjc-arc
.. option:: -fobjc-convert-messages-to-runtime-calls, -fno-objc-convert-messages-to-runtime-calls
.. option:: -fobjc-exceptions, -fno-objc-exceptions
Enable Objective-C exceptions
@ -1737,6 +1755,14 @@ Load the named plugin (dynamic shared object)
.. option:: -fprofile-dir=<arg>
.. option:: -fprofile-exclude-files=<arg>
Instrument only functions from files where names don't match all the regexes separated by a semi-colon
.. option:: -fprofile-filter-files=<arg>
Instrument only functions from files where names match any regex separated by a semi-colon
.. option:: -fprofile-generate, -fno-profile-generate
Generate instrumented code to collect execution counts into default.profraw (overridden by LLVM\_PROFILE\_FILE env var)
@ -1765,6 +1791,10 @@ Generate instrumented code to collect execution counts into <file> (overridden b
Use instrumentation data for profile-guided optimization
.. option:: -fprofile-remapping-file=<file>, -fprofile-remapping-file <arg>
Use the remappings described in <file> to match the profile data against names in the program
.. option:: -fprofile-sample-accurate, -fauto-profile-accurate, -fno-profile-sample-accurate
Specifies that the sample profile is accurate. If the sample
@ -1876,19 +1906,23 @@ Enable the superword-level parallelism vectorization passes
Provide minimal debug info in the object/executable to facilitate online symbolication/stack traces in the absence of .dwo/.dwp files when using Split DWARF
.. option:: -fsplit-lto-unit, -fno-split-lto-unit
Enables splitting of the LTO unit.
.. option:: -fsplit-stack
.. option:: -fstack-protector, -fno-stack-protector
Enable stack protectors for functions potentially vulnerable to stack smashing
Enable stack protectors for some functions vulnerable to stack smashing. This uses a loose heuristic which considers functions vulnerable if they contain a char (or 8bit integer) array or constant sized calls to alloca, which are of greater size than ssp-buffer-size (default: 8 bytes). All variable sized calls to alloca are considered vulnerable
.. option:: -fstack-protector-all
Force the usage of stack protectors for all functions
Enable stack protectors for all functions
.. option:: -fstack-protector-strong
Use a strong heuristic to apply stack protectors to functions
Enable stack protectors for some functions vulnerable to stack smashing. Compared to -fstack-protector, this uses a stronger heuristic that includes functions containing arrays of any size (and any type), as well as any calls to alloca or the taking of an address from a local variable
.. option:: -fstack-size-section, -fno-stack-size-section
@ -1962,6 +1996,10 @@ Specify the function to be called on overflow
Process trigraph sequences
.. option:: -ftrivial-auto-var-init=<arg>
Initialize trivial automatic stack variables: uninitialized (default) \| pattern
.. option:: -funique-section-names, -fno-unique-section-names
Use unique names for text and data sections (ELF Only)
@ -2000,6 +2038,10 @@ Enable the loop vectorization passes
.. option:: -fverbose-asm, -fno-verbose-asm
.. option:: -fvisibility-global-new-delete-hidden
Give global C++ operator new and delete declarations hidden visibility
.. option:: -fvisibility-inlines-hidden
Give inline C++ member functions hidden visibility by default
@ -2162,7 +2204,7 @@ Link stack frames through backchain on System Z
.. option:: -mconsole<arg>
.. option:: -mcpu=<arg>, -mv5 (equivalent to -mcpu=hexagonv5), -mv55 (equivalent to -mcpu=hexagonv55), -mv60 (equivalent to -mcpu=hexagonv60), -mv62 (equivalent to -mcpu=hexagonv62), -mv65 (equivalent to -mcpu=hexagonv65)
.. option:: -mcpu=<arg>, -mv5 (equivalent to -mcpu=hexagonv5), -mv55 (equivalent to -mcpu=hexagonv55), -mv60 (equivalent to -mcpu=hexagonv60), -mv62 (equivalent to -mcpu=hexagonv62), -mv65 (equivalent to -mcpu=hexagonv65), -mv66 (equivalent to -mcpu=hexagonv66)
.. option:: -mcrc, -mno-crc
@ -2196,6 +2238,8 @@ Enable merging of globals
.. option:: -mhwdiv=<arg>, --mhwdiv <arg>, --mhwdiv=<arg>
.. option:: -mhwmult=<arg>
.. option:: -miamcu, -mno-iamcu
Use Intel MCU ABI
@ -2272,6 +2316,8 @@ Select return address signing scope
Use software floating point
.. option:: -mspeculative-load-hardening, -mno-speculative-load-hardening
.. option:: -mstack-alignment=<arg>
Set the stack alignment
@ -2296,6 +2342,10 @@ The thread model to use, e.g. posix, single (posix by default)
.. option:: -mthumb, -mno-thumb
.. option:: -mtls-direct-seg-refs, -mno-tls-direct-seg-refs
Enable direct TLS access through segment registers (default)
.. option:: -mtune=<arg>
.. option:: -mtvos-version-min=<arg>, -mappletvos-version-min=<arg>
@ -2314,50 +2364,6 @@ The thread model to use, e.g. posix, single (posix by default)
AARCH64
-------
.. option:: -ffixed-x1
Reserve the x1 register (AArch64 only)
.. option:: -ffixed-x2
Reserve the x2 register (AArch64 only)
.. option:: -ffixed-x3
Reserve the x3 register (AArch64 only)
.. option:: -ffixed-x4
Reserve the x4 register (AArch64 only)
.. option:: -ffixed-x5
Reserve the x5 register (AArch64 only)
.. option:: -ffixed-x6
Reserve the x6 register (AArch64 only)
.. option:: -ffixed-x7
Reserve the x7 register (AArch64 only)
.. option:: -ffixed-x18
Reserve the x18 register (AArch64 only)
.. option:: -ffixed-x20
Reserve the x20 register (AArch64 only)
.. option:: -fcall-saved-x8
Make the x8 register call-saved (AArch64 only)
.. option:: -fcall-saved-x9
Make the x9 register call-saved (AArch64 only)
.. option:: -fcall-saved-x10
Make the x10 register call-saved (AArch64 only)
@ -2386,6 +2392,50 @@ Make the x15 register call-saved (AArch64 only)
Make the x18 register call-saved (AArch64 only)
.. option:: -fcall-saved-x8
Make the x8 register call-saved (AArch64 only)
.. option:: -fcall-saved-x9
Make the x9 register call-saved (AArch64 only)
.. option:: -ffixed-x1
Reserve the 1 register (AArch64 only)
.. option:: -ffixed-x18
Reserve the 18 register (AArch64 only)
.. option:: -ffixed-x2
Reserve the 2 register (AArch64 only)
.. option:: -ffixed-x20
Reserve the 20 register (AArch64 only)
.. option:: -ffixed-x3
Reserve the 3 register (AArch64 only)
.. option:: -ffixed-x4
Reserve the 4 register (AArch64 only)
.. option:: -ffixed-x5
Reserve the 5 register (AArch64 only)
.. option:: -ffixed-x6
Reserve the 6 register (AArch64 only)
.. option:: -ffixed-x7
Reserve the 7 register (AArch64 only)
.. option:: -mfix-cortex-a53-835769, -mno-fix-cortex-a53-835769
Workaround Cortex-A53 erratum 835769 (AArch64 only)
@ -2396,6 +2446,14 @@ Generate code which only uses the general purpose registers (AArch64 only)
AMDGPU
------
.. option:: -mcode-object-v3, -mno-code-object-v3
Enable code object v3 (AMDGPU only)
.. option:: -msram-ecc, -mno-sram-ecc
Enable SRAM ECC (AMDGPU only)
.. option:: -mxnack, -mno-xnack
Enable XNACK (AMDGPU only)
@ -2594,6 +2652,8 @@ WebAssembly
.. option:: -msimd128, -mno-simd128
.. option:: -munimplemented-simd128, -mno-unimplemented-simd128
X86
---
.. option:: -m3dnow, -mno-3dnow
@ -2811,6 +2871,10 @@ ___________
.. option:: -ggdb3
.. option:: -gline-directives-only
Emit debug line info directives only
.. option:: -gline-tables-only, -g1, -gmlt
Emit debug line number tables only
@ -2841,10 +2905,16 @@ Embed source text in DWARF debug sections
.. option:: -gpubnames, -gno-pubnames
.. option:: -grecord-command-line, -grecord-gcc-switches, -gno-record-command-line, -gno-record-gcc-switches
.. option:: -grecord-command-line, -gno-record-command-line, -grecord-gcc-switches
.. option:: -gsplit-dwarf
.. program:: clang1
.. option:: -gsplit-dwarf=<arg>
.. program:: clang
Set DWARF fission mode to either 'split' or 'single'
.. option:: -gstrict-dwarf, -gno-strict-dwarf
.. option:: -gz

View File

@ -103,13 +103,6 @@ def ObjCInstanceMethod : SubsetSubject<ObjCMethod,
[{S->isInstanceMethod()}],
"Objective-C instance methods">;
def ObjCInterfaceDeclInitMethod : SubsetSubject<ObjCMethod,
[{S->getMethodFamily() == OMF_init &&
(isa<ObjCInterfaceDecl>(S->getDeclContext()) ||
(isa<ObjCCategoryDecl>(S->getDeclContext()) &&
cast<ObjCCategoryDecl>(S->getDeclContext())->IsClassExtension()))}],
"init methods of interface or class extension declarations">;
def Struct : SubsetSubject<Record,
[{!S->isUnion()}], "structs">;
@ -329,6 +322,7 @@ def TargetMSP430 : TargetArch<["msp430"]>;
def TargetRISCV : TargetArch<["riscv32", "riscv64"]>;
def TargetX86 : TargetArch<["x86"]>;
def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
def TargetWebAssembly : TargetArch<["wasm32", "wasm64"]>;
def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
let OSes = ["Win32"];
}
@ -1500,6 +1494,22 @@ def AMDGPUNumVGPR : InheritableAttr {
let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
}
def WebAssemblyImportModule : InheritableAttr,
TargetSpecificAttr<TargetWebAssembly> {
let Spellings = [Clang<"import_module">];
let Args = [StringArgument<"ImportModule">];
let Documentation = [WebAssemblyImportModuleDocs];
let Subjects = SubjectList<[Function], ErrorDiag>;
}
def WebAssemblyImportName : InheritableAttr,
TargetSpecificAttr<TargetWebAssembly> {
let Spellings = [Clang<"import_name">];
let Args = [StringArgument<"ImportName">];
let Documentation = [WebAssemblyImportNameDocs];
let Subjects = SubjectList<[Function], ErrorDiag>;
}
def NoSplitStack : InheritableAttr {
let Spellings = [GCC<"no_split_stack">];
let Subjects = SubjectList<[Function], ErrorDiag>;
@ -1745,7 +1755,7 @@ def ObjCExplicitProtocolImpl : InheritableAttr {
def ObjCDesignatedInitializer : Attr {
let Spellings = [Clang<"objc_designated_initializer">];
let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag>;
let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
let Documentation = [Undocumented];
}

View File

@ -3652,7 +3652,40 @@ definition (
For more information see
`gcc documentation <https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Microsoft-Windows-Variable-Attributes.html>`_
or `msvc documentation <https://docs.microsoft.com/pl-pl/cpp/cpp/selectany>`_.
}];
}]; }
def WebAssemblyImportModuleDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
Clang supports the ``__attribute__((import_module(<module_name>)))``
attribute for the WebAssembly target. This attribute may be attached to a
function declaration, where it modifies how the symbol is to be imported
within the WebAssembly linking environment.
WebAssembly imports use a two-level namespace scheme, consisting of a module
name, which typically identifies a module from which to import, and a field
name, which typically identifies a field from that module to import. By
default, module names for C/C++ symbols are assigned automatically by the
linker. This attribute can be used to override the default behavior, and
reuqest a specific module name be used instead.
}];
}
def WebAssemblyImportNameDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
Clang supports the ``__attribute__((import_name(<name>)))``
attribute for the WebAssembly target. This attribute may be attached to a
function declaration, where it modifies how the symbol is to be imported
within the WebAssembly linking environment.
WebAssembly imports use a two-level namespace scheme, consisting of a module
name, which typically identifies a module from which to import, and a field
name, which typically identifies a field from that module to import. By
default, field names for C/C++ symbols are the same as their C/C++ symbol
names. This attribute can be used to override the default behavior, and
reuqest a specific field name be used instead.
}];
}
def ArtificialDocs : Documentation {

View File

@ -204,8 +204,8 @@ TARGET_HEADER_BUILTIN(_InterlockedDecrement64_rel, "LLiLLiD*", "nh", "intrin.h",
TARGET_HEADER_BUILTIN(_ReadWriteBarrier, "v", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
TARGET_HEADER_BUILTIN(__getReg, "ULLii", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
TARGET_HEADER_BUILTIN(_ReadStatusReg, "ii", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
TARGET_HEADER_BUILTIN(_WriteStatusReg, "vii", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
TARGET_HEADER_BUILTIN(_ReadStatusReg, "LLii", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
TARGET_HEADER_BUILTIN(_WriteStatusReg, "viLLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
TARGET_HEADER_BUILTIN(_AddressOfReturnAddress, "v*", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
#undef BUILTIN

View File

@ -3460,6 +3460,9 @@ def warn_objc_secondary_init_missing_init_call : Warning<
def warn_objc_implementation_missing_designated_init_override : Warning<
"method override for the designated initializer of the superclass %objcinstance0 not found">,
InGroup<ObjCDesignatedInit>;
def err_designated_init_attr_non_init : Error<
"'objc_designated_initializer' attribute only applies to init methods "
"of interface or class extension declarations">;
// objc_bridge attribute diagnostics.
def err_objc_attr_not_id : Error<

View File

@ -15,6 +15,7 @@
#ifndef LLVM_CLANG_BASIC_OPENCLOPTIONS_H
#define LLVM_CLANG_BASIC_OPENCLOPTIONS_H
#include "clang/Basic/LangOptions.h"
#include "llvm/ADT/StringMap.h"
namespace clang {
@ -42,25 +43,29 @@ class OpenCLOptions {
// Is supported as either an extension or an (optional) core feature for
// OpenCL version \p CLVer.
bool isSupported(llvm::StringRef Ext, unsigned CLVer) const {
bool isSupported(llvm::StringRef Ext, LangOptions LO) const {
// In C++ mode all extensions should work at least as in v2.0.
auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
auto I = OptMap.find(Ext)->getValue();
return I.Supported && I.Avail <= CLVer;
}
// Is supported (optional) OpenCL core features for OpenCL version \p CLVer.
// For supported extension, return false.
bool isSupportedCore(llvm::StringRef Ext, unsigned CLVer) const {
bool isSupportedCore(llvm::StringRef Ext, LangOptions LO) const {
// In C++ mode all extensions should work at least as in v2.0.
auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
auto I = OptMap.find(Ext)->getValue();
return I.Supported && I.Avail <= CLVer &&
I.Core != ~0U && CLVer >= I.Core;
return I.Supported && I.Avail <= CLVer && I.Core != ~0U && CLVer >= I.Core;
}
// Is supported OpenCL extension for OpenCL version \p CLVer.
// For supported (optional) core feature, return false.
bool isSupportedExtension(llvm::StringRef Ext, unsigned CLVer) const {
bool isSupportedExtension(llvm::StringRef Ext, LangOptions LO) const {
// In C++ mode all extensions should work at least as in v2.0.
auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
auto I = OptMap.find(Ext)->getValue();
return I.Supported && I.Avail <= CLVer &&
(I.Core == ~0U || CLVer < I.Core);
return I.Supported && I.Avail <= CLVer && (I.Core == ~0U || CLVer < I.Core);
}
void enable(llvm::StringRef Ext, bool V = true) {
@ -122,10 +127,10 @@ class OpenCLOptions {
I->second.Enabled = false;
}
void enableSupportedCore(unsigned CLVer) {
for (llvm::StringMap<Info>::iterator I = OptMap.begin(),
E = OptMap.end(); I != E; ++I)
if (isSupportedCore(I->getKey(), CLVer))
void enableSupportedCore(LangOptions LO) {
for (llvm::StringMap<Info>::iterator I = OptMap.begin(), E = OptMap.end();
I != E; ++I)
if (isSupportedCore(I->getKey(), LO))
I->second.Enabled = true;
}
@ -133,6 +138,6 @@ class OpenCLOptions {
friend class ASTReader;
};
} // end namespace clang
} // end namespace clang
#endif

View File

@ -552,9 +552,9 @@ def cuda_compile_host_device : Flag<["--"], "cuda-compile-host-device">,
HelpText<"Compile CUDA code for both host and device (default). Has no "
"effect on non-CUDA compilations.">;
def cuda_include_ptx_EQ : Joined<["--"], "cuda-include-ptx=">, Flags<[DriverOption]>,
HelpText<"Include PTX for the follwing GPU architecture (e.g. sm_35) or 'all'. May be specified more than once.">;
HelpText<"Include PTX for the following GPU architecture (e.g. sm_35) or 'all'. May be specified more than once.">;
def no_cuda_include_ptx_EQ : Joined<["--"], "no-cuda-include-ptx=">, Flags<[DriverOption]>,
HelpText<"Do not include PTX for the follwing GPU architecture (e.g. sm_35) or 'all'. May be specified more than once.">;
HelpText<"Do not include PTX for the following GPU architecture (e.g. sm_35) or 'all'. May be specified more than once.">;
def cuda_gpu_arch_EQ : Joined<["--"], "cuda-gpu-arch=">, Flags<[DriverOption]>,
HelpText<"CUDA GPU architecture (e.g. sm_35). May be specified more than once.">;
def hip_link : Flag<["--"], "hip-link">,

View File

@ -360,11 +360,6 @@ class Parser : public CodeCompletionHandler {
/// just a regular sub-expression.
SourceLocation ExprStatementTokLoc;
/// Tests whether an expression value is discarded based on token lookahead.
/// It will return true if the lexer is currently processing the })
/// terminating a GNU statement expression and false otherwise.
bool isExprValueDiscarded();
public:
Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies);
~Parser() override;

View File

@ -1369,7 +1369,6 @@ class Sema {
void PopCompoundScope();
sema::CompoundScopeInfo &getCurCompoundScope() const;
bool isCurCompoundStmtAStmtExpr() const;
bool hasAnyUnrecoverableErrorsInThisFunction() const;
@ -3690,17 +3689,16 @@ class Sema {
return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
}
FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC) {
return FullExprArg(
ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
return FullExprArg(ActOnFinishFullExpr(Arg, CC).get());
}
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg) {
ExprResult FE =
ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
/*DiscardedValue*/ true);
ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
/*DiscardedValue*/ true);
return FullExprArg(FE.get());
}
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true);
StmtResult ActOnExprStmt(ExprResult Arg);
StmtResult ActOnExprStmtError();
StmtResult ActOnNullStmt(SourceLocation SemiLoc,
@ -5346,12 +5344,13 @@ class Sema {
CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary,
bool BoundToLvalueReference);
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) {
return ActOnFinishFullExpr(
Expr, Expr ? Expr->getExprLoc() : SourceLocation(), DiscardedValue);
ExprResult ActOnFinishFullExpr(Expr *Expr) {
return ActOnFinishFullExpr(Expr, Expr ? Expr->getExprLoc()
: SourceLocation());
}
ExprResult ActOnFinishFullExpr(Expr *Expr, SourceLocation CC,
bool DiscardedValue, bool IsConstexpr = false);
bool DiscardedValue = false,
bool IsConstexpr = false);
StmtResult ActOnFinishFullStmt(Stmt *Stmt);
// Marks SS invalid if it represents an incomplete type.

View File

@ -331,9 +331,15 @@ class LLVM_LIBRARY_VISIBILITY PPC32TargetInfo : public PPCTargetInfo {
break;
}
if (getTriple().isOSFreeBSD()) {
switch (getTriple().getOS()) {
case llvm::Triple::FreeBSD:
case llvm::Triple::NetBSD:
case llvm::Triple::OpenBSD:
LongDoubleWidth = LongDoubleAlign = 64;
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
break;
default:
break;
}
// PPC32 supports atomics up to 4 bytes.

View File

@ -7052,19 +7052,16 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
llvm::Value *Metadata = llvm::MetadataAsValue::get(Context, RegName);
llvm::Type *RegisterType = Int64Ty;
llvm::Type *ValueType = Int32Ty;
llvm::Type *Types[] = { RegisterType };
if (BuiltinID == AArch64::BI_ReadStatusReg) {
llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::read_register, Types);
llvm::Value *Call = Builder.CreateCall(F, Metadata);
return Builder.CreateTrunc(Call, ValueType);
return Builder.CreateCall(F, Metadata);
}
llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::write_register, Types);
llvm::Value *ArgValue = EmitScalarExpr(E->getArg(1));
ArgValue = Builder.CreateZExt(ArgValue, RegisterType);
return Builder.CreateCall(F, { Metadata, ArgValue });
}

View File

@ -1631,11 +1631,15 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
? LangOptions::TrivialAutoVarInitKind::Uninitialized
: getContext().getLangOpts().getTrivialAutoVarInit()));
auto initializeWhatIsTechnicallyUninitialized = [&]() {
auto initializeWhatIsTechnicallyUninitialized = [&](Address Loc) {
if (trivialAutoVarInit ==
LangOptions::TrivialAutoVarInitKind::Uninitialized)
return;
// Only initialize a __block's storage: we always initialize the header.
if (emission.IsEscapingByRef)
Loc = emitBlockByrefAddress(Loc, &D, /*follow=*/false);
CharUnits Size = getContext().getTypeSizeInChars(type);
if (!Size.isZero()) {
switch (trivialAutoVarInit) {
@ -1713,7 +1717,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
};
if (isTrivialInitializer(Init)) {
initializeWhatIsTechnicallyUninitialized();
initializeWhatIsTechnicallyUninitialized(Loc);
return;
}
@ -1727,7 +1731,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
}
if (!constant) {
initializeWhatIsTechnicallyUninitialized();
initializeWhatIsTechnicallyUninitialized(Loc);
LValue lv = MakeAddrLValue(Loc, type);
lv.setNonGC(true);
return EmitExprAsInit(Init, &D, lv, capturedByInit);

View File

@ -3762,13 +3762,15 @@ static bool isVarDeclStrongDefinition(const ASTContext &Context,
}
}
// Microsoft's link.exe doesn't support alignments greater than 32 for common
// symbols, so symbols with greater alignment requirements cannot be common.
// Microsoft's link.exe doesn't support alignments greater than 32 bytes for
// common symbols, so symbols with greater alignment requirements cannot be
// common.
// Other COFF linkers (ld.bfd and LLD) support arbitrary power-of-two
// alignments for common symbols via the aligncomm directive, so this
// restriction only applies to MSVC environments.
if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
Context.getTypeAlignIfKnown(D->getType()) > 32)
Context.getTypeAlignIfKnown(D->getType()) >
Context.toBits(CharUnits::fromQuantity(32)))
return true;
return false;

View File

@ -761,6 +761,22 @@ class WebAssemblyTargetCodeGenInfo final : public TargetCodeGenInfo {
void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &CGM) const override {
TargetCodeGenInfo::setTargetAttributes(D, GV, CGM);
if (const auto *FD = dyn_cast_or_null<FunctionDecl>(D)) {
if (const auto *Attr = FD->getAttr<WebAssemblyImportModuleAttr>()) {
llvm::Function *Fn = cast<llvm::Function>(GV);
llvm::AttrBuilder B;
B.addAttribute("wasm-import-module", Attr->getImportModule());
Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
}
if (const auto *Attr = FD->getAttr<WebAssemblyImportNameAttr>()) {
llvm::Function *Fn = cast<llvm::Function>(GV);
llvm::AttrBuilder B;
B.addAttribute("wasm-import-name", Attr->getImportName());
Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
}
}
if (auto *FD = dyn_cast_or_null<FunctionDecl>(D)) {
llvm::Function *Fn = cast<llvm::Function>(GV);
if (!FD->doesThisDeclarationHaveABody() && !FD->hasPrototype())

View File

@ -1408,10 +1408,10 @@ static void TranslateOptArg(Arg *A, llvm::opt::DerivedArgList &DAL,
DAL.AddFlagArg(
A, Opts.getOption(options::OPT_fno_omit_frame_pointer));
} else {
// Don't warn about /Oy- in 64-bit builds (where
// Don't warn about /Oy- in x86-64 builds (where
// SupportsForcingFramePointer is false). The flag having no effect
// there is a compiler-internal optimization, and people shouldn't have
// to special-case their build files for 64-bit clang-cl.
// to special-case their build files for x86-64 clang-cl.
A->claim();
}
break;
@ -1442,8 +1442,8 @@ MSVCToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
const OptTable &Opts = getDriver().getOpts();
// /Oy and /Oy- only has an effect under X86-32.
bool SupportsForcingFramePointer = getArch() == llvm::Triple::x86;
// /Oy and /Oy- don't have an effect on X86-64
bool SupportsForcingFramePointer = getArch() != llvm::Triple::x86_64;
// The -O[12xd] flag actually expands to several flags. We must desugar the
// flags so that options embedded can be negated. For example, the '-O2' flag

View File

@ -1059,10 +1059,9 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
// OpenCL definitions.
if (LangOpts.OpenCL) {
#define OPENCLEXT(Ext) \
if (TI.getSupportedOpenCLOpts().isSupported(#Ext, \
LangOpts.OpenCLVersion)) \
Builder.defineMacro(#Ext);
#define OPENCLEXT(Ext) \
if (TI.getSupportedOpenCLOpts().isSupported(#Ext, LangOpts)) \
Builder.defineMacro(#Ext);
#include "clang/Basic/OpenCLExtensions.def"
auto Arch = TI.getTriple().getArch();

View File

@ -564,8 +564,8 @@ __nop(void) {
#if defined(__aarch64__)
unsigned __int64 __getReg(int);
long _InterlockedAdd(long volatile *Addend, long Value);
int _ReadStatusReg(int);
void _WriteStatusReg(int, int);
__int64 _ReadStatusReg(int);
void _WriteStatusReg(int, __int64);
static inline unsigned short _byteswap_ushort (unsigned short val) {
return __builtin_bswap16(val);

View File

@ -2741,7 +2741,7 @@ StmtResult Parser::ParseObjCAtStatement(SourceLocation AtLoc) {
// Otherwise, eat the semicolon.
ExpectAndConsumeSemi(diag::err_expected_semi_after_expr);
return Actions.ActOnExprStmt(Res, isExprValueDiscarded());
return Actions.ActOnExprStmt(Res);
}
ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) {

View File

@ -314,7 +314,7 @@ Parser::ParseOpenMPDeclareReductionDirective(AccessSpecifier AS) {
Actions.ActOnOpenMPDeclareReductionCombinerStart(getCurScope(), D);
ExprResult CombinerResult =
Actions.ActOnFinishFullExpr(ParseAssignmentExpression().get(),
D->getLocation(), /*DiscardedValue*/ false);
D->getLocation(), /*DiscardedValue=*/true);
Actions.ActOnOpenMPDeclareReductionCombinerEnd(D, CombinerResult.get());
if (CombinerResult.isInvalid() && Tok.isNot(tok::r_paren) &&
@ -356,7 +356,7 @@ Parser::ParseOpenMPDeclareReductionDirective(AccessSpecifier AS) {
if (Actions.getLangOpts().CPlusPlus) {
InitializerResult = Actions.ActOnFinishFullExpr(
ParseAssignmentExpression().get(), D->getLocation(),
/*DiscardedValue*/ false);
/*DiscardedValue=*/true);
} else {
ConsumeToken();
ParseOpenMPReductionInitializerForDecl(OmpPrivParm);
@ -364,7 +364,7 @@ Parser::ParseOpenMPDeclareReductionDirective(AccessSpecifier AS) {
} else {
InitializerResult = Actions.ActOnFinishFullExpr(
ParseAssignmentExpression().get(), D->getLocation(),
/*DiscardedValue*/ false);
/*DiscardedValue=*/true);
}
Actions.ActOnOpenMPDeclareReductionInitializerEnd(
D, InitializerResult.get(), OmpPrivParm);
@ -1455,7 +1455,7 @@ ExprResult Parser::ParseOpenMPParensExpr(StringRef ClauseName,
ExprResult LHS(ParseCastExpression(
/*isUnaryExpression=*/false, /*isAddressOfOperand=*/false, NotTypeCast));
ExprResult Val(ParseRHSOfBinaryExpression(LHS, prec::Conditional));
Val = Actions.ActOnFinishFullExpr(Val.get(), ELoc, /*DiscardedValue*/ false);
Val = Actions.ActOnFinishFullExpr(Val.get(), ELoc);
// Parse ')'.
RLoc = Tok.getLocation();
@ -1711,8 +1711,7 @@ OMPClause *Parser::ParseOpenMPSingleExprWithArgClause(OpenMPClauseKind Kind,
SourceLocation ELoc = Tok.getLocation();
ExprResult LHS(ParseCastExpression(false, false, NotTypeCast));
Val = ParseRHSOfBinaryExpression(LHS, prec::Conditional);
Val =
Actions.ActOnFinishFullExpr(Val.get(), ELoc, /*DiscardedValue*/ false);
Val = Actions.ActOnFinishFullExpr(Val.get(), ELoc);
}
// Parse ')'.
@ -1997,8 +1996,7 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
Data.ColonLoc = Tok.getLocation();
SourceLocation ELoc = ConsumeToken();
ExprResult Tail = ParseAssignmentExpression();
Tail =
Actions.ActOnFinishFullExpr(Tail.get(), ELoc, /*DiscardedValue*/ false);
Tail = Actions.ActOnFinishFullExpr(Tail.get(), ELoc);
if (Tail.isUsable())
Data.TailExpr = Tail.get();
else

View File

@ -693,13 +693,12 @@ void Parser::HandlePragmaOpenCLExtension() {
if (Name == "all") {
if (State == Disable) {
Opt.disableAll();
Opt.enableSupportedCore(getLangOpts().OpenCLVersion);
Opt.enableSupportedCore(getLangOpts());
} else {
PP.Diag(NameLoc, diag::warn_pragma_expected_predicate) << 1;
}
} else if (State == Begin) {
if (!Opt.isKnown(Name) ||
!Opt.isSupported(Name, getLangOpts().OpenCLVersion)) {
if (!Opt.isKnown(Name) || !Opt.isSupported(Name, getLangOpts())) {
Opt.support(Name);
}
Actions.setCurrentOpenCLExtension(Name);
@ -709,9 +708,9 @@ void Parser::HandlePragmaOpenCLExtension() {
Actions.setCurrentOpenCLExtension("");
} else if (!Opt.isKnown(Name))
PP.Diag(NameLoc, diag::warn_pragma_unknown_extension) << Ident;
else if (Opt.isSupportedExtension(Name, getLangOpts().OpenCLVersion))
else if (Opt.isSupportedExtension(Name, getLangOpts()))
Opt.enable(Name, State == Enable);
else if (Opt.isSupportedCore(Name, getLangOpts().OpenCLVersion))
else if (Opt.isSupportedCore(Name, getLangOpts()))
PP.Diag(NameLoc, diag::warn_pragma_extension_is_core) << Ident;
else
PP.Diag(NameLoc, diag::warn_pragma_unsupported_extension) << Ident;

View File

@ -439,7 +439,7 @@ StmtResult Parser::ParseExprStatement() {
// Otherwise, eat the semicolon.
ExpectAndConsumeSemi(diag::err_expected_semi_after_expr);
return Actions.ActOnExprStmt(Expr, isExprValueDiscarded());
return Actions.ActOnExprStmt(Expr);
}
/// ParseSEHTryBlockCommon
@ -958,16 +958,6 @@ bool Parser::ConsumeNullStmt(StmtVector &Stmts) {
return true;
}
bool Parser::isExprValueDiscarded() {
if (Actions.isCurCompoundStmtAStmtExpr()) {
// Look to see if the next two tokens close the statement expression;
// if so, this expression statement is the last statement in a
// statment expression.
return Tok.isNot(tok::r_brace) || NextToken().isNot(tok::r_paren);
}
return true;
}
/// ParseCompoundStatementBody - Parse a sequence of statements and invoke the
/// ActOnCompoundStmt action. This expects the '{' to be the current token, and
/// consume the '}' at the end of the block. It does not manipulate the scope
@ -1072,7 +1062,7 @@ StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
// Eat the semicolon at the end of stmt and convert the expr into a
// statement.
ExpectAndConsumeSemi(diag::err_expected_semi_after_expr);
R = Actions.ActOnExprStmt(Res, isExprValueDiscarded());
R = Actions.ActOnExprStmt(Res);
}
}
@ -1708,16 +1698,8 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) {
if (!Value.isInvalid()) {
if (ForEach)
FirstPart = Actions.ActOnForEachLValueExpr(Value.get());
else {
// We already know this is not an init-statement within a for loop, so
// if we are parsing a C++11 range-based for loop, we should treat this
// expression statement as being a discarded value expression because
// we will err below. This way we do not warn on an unused expression
// that was an error in the first place, like with: for (expr : expr);
bool IsRangeBasedFor =
getLangOpts().CPlusPlus11 && !ForEach && Tok.is(tok::colon);
FirstPart = Actions.ActOnExprStmt(Value, !IsRangeBasedFor);
}
else
FirstPart = Actions.ActOnExprStmt(Value);
}
if (Tok.is(tok::semi)) {

View File

@ -637,7 +637,7 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
// Filter out "fpsw" and "mxcsr". They aren't valid GCC asm clobber
// constraints. Clang always adds fpsr to the clobber list anyway.
llvm::erase_if(Clobbers, [](const std::string &C) {
return C == "fpsw" || C == "mxcsr";
return C == "fpsr" || C == "mxcsr";
});
// Build the vector of clobber StringRefs.

View File

@ -256,11 +256,12 @@ void Sema::Initialize() {
// Initialize predefined OpenCL types and supported extensions and (optional)
// core features.
if (getLangOpts().OpenCL) {
getOpenCLOptions().addSupport(Context.getTargetInfo().getSupportedOpenCLOpts());
getOpenCLOptions().enableSupportedCore(getLangOpts().OpenCLVersion);
getOpenCLOptions().addSupport(
Context.getTargetInfo().getSupportedOpenCLOpts());
getOpenCLOptions().enableSupportedCore(getLangOpts());
addImplicitTypedef("sampler_t", Context.OCLSamplerTy);
addImplicitTypedef("event_t", Context.OCLEventTy);
if (getLangOpts().OpenCLVersion >= 200) {
if (getLangOpts().OpenCLCPlusPlus || getLangOpts().OpenCLVersion >= 200) {
addImplicitTypedef("clk_event_t", Context.OCLClkEventTy);
addImplicitTypedef("queue_t", Context.OCLQueueTy);
addImplicitTypedef("reserve_id_t", Context.OCLReserveIDTy);

View File

@ -10622,16 +10622,16 @@ static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E) {
// The below checks assume source is floating point.
if (!ResultBT || !RBT || !RBT->isFloatingPoint()) return;
// If source is floating point but target is not.
if (!ResultBT->isFloatingPoint())
return DiagnoseFloatingImpCast(S, E, E->getRHS()->getType(),
E->getExprLoc());
// If both source and target are floating points.
// Builtin FP kinds are ordered by increasing FP rank.
if (ResultBT->getKind() < RBT->getKind() &&
// We don't want to warn for system macro.
!S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
// If source is floating point but target is an integer.
if (ResultBT->isInteger())
DiagnoseImpCast(S, E, E->getRHS()->getType(), E->getLHS()->getType(),
E->getExprLoc(), diag::warn_impcast_float_integer);
// If both source and target are floating points. Builtin FP kinds are ordered
// by increasing FP rank. FIXME: except _Float16, we currently emit a bogus
// warning.
else if (ResultBT->isFloatingPoint() && ResultBT->getKind() < RBT->getKind() &&
// We don't want to warn for system macro.
!S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
// warn about dropping FP rank.
DiagnoseImpCast(S, E->getRHS(), E->getLHS()->getType(), E->getOperatorLoc(),
diag::warn_impcast_float_result_precision);

View File

@ -646,7 +646,7 @@ bool Sema::ActOnCoroutineBodyStart(Scope *SC, SourceLocation KWLoc,
return StmtError();
Suspend = BuildResolvedCoawaitExpr(Loc, Suspend.get(),
/*IsImplicit*/ true);
Suspend = ActOnFinishFullExpr(Suspend.get(), /*DiscardedValue*/ false);
Suspend = ActOnFinishFullExpr(Suspend.get());
if (Suspend.isInvalid()) {
Diag(Loc, diag::note_coroutine_promise_suspend_implicitly_required)
<< ((Name == "initial_suspend") ? 0 : 1);
@ -867,7 +867,7 @@ StmtResult Sema::BuildCoreturnStmt(SourceLocation Loc, Expr *E,
if (PC.isInvalid())
return StmtError();
Expr *PCE = ActOnFinishFullExpr(PC.get(), /*DiscardedValue*/ false).get();
Expr *PCE = ActOnFinishFullExpr(PC.get()).get();
Stmt *Res = new (Context) CoreturnStmt(Loc, E, PCE, IsImplicit);
return Res;
@ -1236,7 +1236,7 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() {
ExprResult NewExpr =
S.ActOnCallExpr(S.getCurScope(), NewRef.get(), Loc, NewArgs, Loc);
NewExpr = S.ActOnFinishFullExpr(NewExpr.get(), /*DiscardedValue*/ false);
NewExpr = S.ActOnFinishFullExpr(NewExpr.get());
if (NewExpr.isInvalid())
return false;
@ -1262,8 +1262,7 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() {
ExprResult DeleteExpr =
S.ActOnCallExpr(S.getCurScope(), DeleteRef.get(), Loc, DeleteArgs, Loc);
DeleteExpr =
S.ActOnFinishFullExpr(DeleteExpr.get(), /*DiscardedValue*/ false);
DeleteExpr = S.ActOnFinishFullExpr(DeleteExpr.get());
if (DeleteExpr.isInvalid())
return false;
@ -1348,8 +1347,7 @@ bool CoroutineStmtBuilder::makeOnException() {
ExprResult UnhandledException = buildPromiseCall(S, Fn.CoroutinePromise, Loc,
"unhandled_exception", None);
UnhandledException = S.ActOnFinishFullExpr(UnhandledException.get(), Loc,
/*DiscardedValue*/ false);
UnhandledException = S.ActOnFinishFullExpr(UnhandledException.get(), Loc);
if (UnhandledException.isInvalid())
return false;
@ -1402,8 +1400,7 @@ bool CoroutineStmtBuilder::makeGroDeclAndReturnStmt() {
"get_return_object type must no longer be dependent");
if (FnRetType->isVoidType()) {
ExprResult Res =
S.ActOnFinishFullExpr(this->ReturnValue, Loc, /*DiscardedValue*/ false);
ExprResult Res = S.ActOnFinishFullExpr(this->ReturnValue, Loc);
if (Res.isInvalid())
return false;
@ -1435,7 +1432,7 @@ bool CoroutineStmtBuilder::makeGroDeclAndReturnStmt() {
if (Res.isInvalid())
return false;
Res = S.ActOnFinishFullExpr(Res.get(), /*DiscardedValue*/ false);
Res = S.ActOnFinishFullExpr(Res.get());
if (Res.isInvalid())
return false;

View File

@ -11200,9 +11200,9 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
// struct T { S a, b; } t = { Temp(), Temp() }
//
// we should destroy the first Temp before constructing the second.
ExprResult Result =
ActOnFinishFullExpr(Init, VDecl->getLocation(),
/*DiscardedValue*/ false, VDecl->isConstexpr());
ExprResult Result = ActOnFinishFullExpr(Init, VDecl->getLocation(),
false,
VDecl->isConstexpr());
if (Result.isInvalid()) {
VDecl->setInvalidDecl();
return;

View File

@ -5116,11 +5116,22 @@ static void handleObjCBridgeRelatedAttr(Sema &S, Decl *D,
static void handleObjCDesignatedInitializer(Sema &S, Decl *D,
const ParsedAttr &AL) {
DeclContext *Ctx = D->getDeclContext();
// This attribute can only be applied to methods in interfaces or class
// extensions.
if (!isa<ObjCInterfaceDecl>(Ctx) &&
!(isa<ObjCCategoryDecl>(Ctx) &&
cast<ObjCCategoryDecl>(Ctx)->IsClassExtension())) {
S.Diag(D->getLocation(), diag::err_designated_init_attr_non_init);
return;
}
ObjCInterfaceDecl *IFace;
if (auto *CatDecl = dyn_cast<ObjCCategoryDecl>(D->getDeclContext()))
if (auto *CatDecl = dyn_cast<ObjCCategoryDecl>(Ctx))
IFace = CatDecl->getClassInterface();
else
IFace = cast<ObjCInterfaceDecl>(D->getDeclContext());
IFace = cast<ObjCInterfaceDecl>(Ctx);
if (!IFace)
return;
@ -5577,6 +5588,51 @@ static void handleAVRSignalAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
handleSimpleAttribute<AVRSignalAttr>(S, D, AL);
}
static void handleWebAssemblyImportModuleAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
if (!isFunctionOrMethod(D)) {
S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
<< "'import_module'" << ExpectedFunction;
return;
}
auto *FD = cast<FunctionDecl>(D);
if (FD->isThisDeclarationADefinition()) {
S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0;
return;
}
StringRef Str;
SourceLocation ArgLoc;
if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc))
return;
FD->addAttr(::new (S.Context) WebAssemblyImportModuleAttr(
AL.getRange(), S.Context, Str,
AL.getAttributeSpellingListIndex()));
}
static void handleWebAssemblyImportNameAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
if (!isFunctionOrMethod(D)) {
S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
<< "'import_name'" << ExpectedFunction;
return;
}
auto *FD = cast<FunctionDecl>(D);
if (FD->isThisDeclarationADefinition()) {
S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0;
return;
}
StringRef Str;
SourceLocation ArgLoc;
if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc))
return;
FD->addAttr(::new (S.Context) WebAssemblyImportNameAttr(
AL.getRange(), S.Context, Str,
AL.getAttributeSpellingListIndex()));
}
static void handleRISCVInterruptAttr(Sema &S, Decl *D,
const ParsedAttr &AL) {
@ -6330,6 +6386,12 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
case ParsedAttr::AT_AVRSignal:
handleAVRSignalAttr(S, D, AL);
break;
case ParsedAttr::AT_WebAssemblyImportModule:
handleWebAssemblyImportModuleAttr(S, D, AL);
break;
case ParsedAttr::AT_WebAssemblyImportName:
handleWebAssemblyImportNameAttr(S, D, AL);
break;
case ParsedAttr::AT_IBAction:
handleSimpleAttribute<IBActionAttr>(S, D, AL);
break;
@ -7016,6 +7078,17 @@ void Sema::ProcessDeclAttributeList(Scope *S, Decl *D,
}
}
}
// Do this check after processing D's attributes because the attribute
// objc_method_family can change whether the given method is in the init
// family, and it can be applied after objc_designated_initializer. This is a
// bit of a hack, but we need it to be compatible with versions of clang that
// processed the attribute list in the wrong order.
if (D->hasAttr<ObjCDesignatedInitializerAttr>() &&
cast<ObjCMethodDecl>(D)->getMethodFamily() != OMF_init) {
Diag(D->getLocation(), diag::err_designated_init_attr_non_init);
D->dropAttr<ObjCDesignatedInitializerAttr>();
}
}
// Helper for delayed processing TransparentUnion attribute.

View File

@ -1205,7 +1205,7 @@ static bool checkTupleLikeDecomposition(Sema &S,
E = Seq.Perform(S, Entity, Kind, Init);
if (E.isInvalid())
return true;
E = S.ActOnFinishFullExpr(E.get(), Loc, /*DiscardedValue*/ false);
E = S.ActOnFinishFullExpr(E.get(), Loc);
if (E.isInvalid())
return true;
RefVD->setInit(E.get());
@ -3686,7 +3686,7 @@ void Sema::ActOnFinishCXXInClassMemberInitializer(Decl *D,
// C++11 [class.base.init]p7:
// The initialization of each base and member constitutes a
// full-expression.
Init = ActOnFinishFullExpr(Init.get(), InitLoc, /*DiscardedValue*/ false);
Init = ActOnFinishFullExpr(Init.get(), InitLoc);
if (Init.isInvalid()) {
FD->setInvalidDecl();
return;
@ -4044,8 +4044,7 @@ Sema::BuildMemberInitializer(ValueDecl *Member, Expr *Init,
// C++11 [class.base.init]p7:
// The initialization of each base and member constitutes a
// full-expression.
MemberInit = ActOnFinishFullExpr(MemberInit.get(), InitRange.getBegin(),
/*DiscardedValue*/ false);
MemberInit = ActOnFinishFullExpr(MemberInit.get(), InitRange.getBegin());
if (MemberInit.isInvalid())
return true;
@ -4100,8 +4099,8 @@ Sema::BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init,
// C++11 [class.base.init]p7:
// The initialization of each base and member constitutes a
// full-expression.
DelegationInit = ActOnFinishFullExpr(
DelegationInit.get(), InitRange.getBegin(), /*DiscardedValue*/ false);
DelegationInit = ActOnFinishFullExpr(DelegationInit.get(),
InitRange.getBegin());
if (DelegationInit.isInvalid())
return true;
@ -4230,8 +4229,7 @@ Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo,
// C++11 [class.base.init]p7:
// The initialization of each base and member constitutes a
// full-expression.
BaseInit = ActOnFinishFullExpr(BaseInit.get(), InitRange.getBegin(),
/*DiscardedValue*/ false);
BaseInit = ActOnFinishFullExpr(BaseInit.get(), InitRange.getBegin());
if (BaseInit.isInvalid())
return true;

View File

@ -4723,9 +4723,8 @@ bool Sema::CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD,
if (Result.isInvalid())
return true;
Result =
ActOnFinishFullExpr(Result.getAs<Expr>(), Param->getOuterLocStart(),
/*DiscardedValue*/ false);
Result = ActOnFinishFullExpr(Result.getAs<Expr>(),
Param->getOuterLocStart());
if (Result.isInvalid())
return true;

View File

@ -7815,8 +7815,6 @@ ExprResult Sema::ActOnFinishFullExpr(Expr *FE, SourceLocation CC,
FullExpr = IgnoredValueConversions(FullExpr.get());
if (FullExpr.isInvalid())
return ExprError();
DiagnoseUnusedExprResult(FullExpr.get());
}
FullExpr = CorrectDelayedTyposInExpr(FullExpr.get());

View File

@ -1724,7 +1724,7 @@ ExprResult Sema::BuildBlockForLambdaConversion(SourceLocation CurrentLocation,
/*NRVO=*/false),
CurrentLocation, Src);
if (!Init.isInvalid())
Init = ActOnFinishFullExpr(Init.get(), /*DiscardedValue*/ false);
Init = ActOnFinishFullExpr(Init.get());
if (Init.isInvalid())
return ExprError();

View File

@ -5367,7 +5367,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
LastIteration.get(), UB.get());
EUB = SemaRef.BuildBinOp(CurScope, InitLoc, BO_Assign, UB.get(),
CondOp.get());
EUB = SemaRef.ActOnFinishFullExpr(EUB.get(), /*DiscardedValue*/ false);
EUB = SemaRef.ActOnFinishFullExpr(EUB.get());
// If we have a combined directive that combines 'distribute', 'for' or
// 'simd' we need to be able to access the bounds of the schedule of the
@ -5396,8 +5396,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
LastIteration.get(), CombUB.get());
CombEUB = SemaRef.BuildBinOp(CurScope, InitLoc, BO_Assign, CombUB.get(),
CombCondOp.get());
CombEUB =
SemaRef.ActOnFinishFullExpr(CombEUB.get(), /*DiscardedValue*/ false);
CombEUB = SemaRef.ActOnFinishFullExpr(CombEUB.get());
const CapturedDecl *CD = cast<CapturedStmt>(AStmt)->getCapturedDecl();
// We expect to have at least 2 more parameters than the 'parallel'
@ -5431,7 +5430,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
? LB.get()
: SemaRef.ActOnIntegerConstant(SourceLocation(), 0).get();
Init = SemaRef.BuildBinOp(CurScope, InitLoc, BO_Assign, IV.get(), RHS);
Init = SemaRef.ActOnFinishFullExpr(Init.get(), /*DiscardedValue*/ false);
Init = SemaRef.ActOnFinishFullExpr(Init.get());
if (isOpenMPLoopBoundSharingDirective(DKind)) {
Expr *CombRHS =
@ -5442,8 +5441,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
: SemaRef.ActOnIntegerConstant(SourceLocation(), 0).get();
CombInit =
SemaRef.BuildBinOp(CurScope, InitLoc, BO_Assign, IV.get(), CombRHS);
CombInit =
SemaRef.ActOnFinishFullExpr(CombInit.get(), /*DiscardedValue*/ false);
CombInit = SemaRef.ActOnFinishFullExpr(CombInit.get());
}
}
@ -5475,7 +5473,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
if (!Inc.isUsable())
return 0;
Inc = SemaRef.BuildBinOp(CurScope, IncLoc, BO_Assign, IV.get(), Inc.get());
Inc = SemaRef.ActOnFinishFullExpr(Inc.get(), /*DiscardedValue*/ false);
Inc = SemaRef.ActOnFinishFullExpr(Inc.get());
if (!Inc.isUsable())
return 0;
@ -5493,8 +5491,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
// LB = LB + ST
NextLB =
SemaRef.BuildBinOp(CurScope, IncLoc, BO_Assign, LB.get(), NextLB.get());
NextLB =
SemaRef.ActOnFinishFullExpr(NextLB.get(), /*DiscardedValue*/ false);
NextLB = SemaRef.ActOnFinishFullExpr(NextLB.get());
if (!NextLB.isUsable())
return 0;
// UB + ST
@ -5504,8 +5501,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
// UB = UB + ST
NextUB =
SemaRef.BuildBinOp(CurScope, IncLoc, BO_Assign, UB.get(), NextUB.get());
NextUB =
SemaRef.ActOnFinishFullExpr(NextUB.get(), /*DiscardedValue*/ false);
NextUB = SemaRef.ActOnFinishFullExpr(NextUB.get());
if (!NextUB.isUsable())
return 0;
if (isOpenMPLoopBoundSharingDirective(DKind)) {
@ -5516,8 +5512,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
// LB = LB + ST
CombNextLB = SemaRef.BuildBinOp(CurScope, IncLoc, BO_Assign, CombLB.get(),
CombNextLB.get());
CombNextLB = SemaRef.ActOnFinishFullExpr(CombNextLB.get(),
/*DiscardedValue*/ false);
CombNextLB = SemaRef.ActOnFinishFullExpr(CombNextLB.get());
if (!CombNextLB.isUsable())
return 0;
// UB + ST
@ -5528,8 +5523,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
// UB = UB + ST
CombNextUB = SemaRef.BuildBinOp(CurScope, IncLoc, BO_Assign, CombUB.get(),
CombNextUB.get());
CombNextUB = SemaRef.ActOnFinishFullExpr(CombNextUB.get(),
/*DiscardedValue*/ false);
CombNextUB = SemaRef.ActOnFinishFullExpr(CombNextUB.get());
if (!CombNextUB.isUsable())
return 0;
}
@ -5550,8 +5544,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
assert(DistInc.isUsable() && "distribute inc expr was not built");
DistInc = SemaRef.BuildBinOp(CurScope, DistIncLoc, BO_Assign, IV.get(),
DistInc.get());
DistInc =
SemaRef.ActOnFinishFullExpr(DistInc.get(), /*DiscardedValue*/ false);
DistInc = SemaRef.ActOnFinishFullExpr(DistInc.get());
assert(DistInc.isUsable() && "distribute inc expr was not built");
// Build expression: UB = min(UB, prevUB) for #for in composite or combined
@ -5563,8 +5556,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
DistEUBLoc, DistEUBLoc, IsUBGreater.get(), PrevUB.get(), UB.get());
PrevEUB = SemaRef.BuildBinOp(CurScope, DistIncLoc, BO_Assign, UB.get(),
CondOp.get());
PrevEUB =
SemaRef.ActOnFinishFullExpr(PrevEUB.get(), /*DiscardedValue*/ false);
PrevEUB = SemaRef.ActOnFinishFullExpr(PrevEUB.get());
// Build IV <= PrevUB to be used in parallel for is in combination with
// a distribute directive with schedule(static, 1)
@ -5680,10 +5672,8 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
Built.IterationVarRef = IV.get();
Built.LastIteration = LastIteration.get();
Built.NumIterations = NumIterations.get();
Built.CalcLastIteration = SemaRef
.ActOnFinishFullExpr(CalcLastIteration.get(),
/*DiscardedValue*/ false)
.get();
Built.CalcLastIteration =
SemaRef.ActOnFinishFullExpr(CalcLastIteration.get()).get();
Built.PreCond = PreCond.get();
Built.PreInits = buildPreInits(C, Captures);
Built.Cond = Cond.get();
@ -10358,8 +10348,8 @@ OMPClause *Sema::ActOnOpenMPLastprivateClause(ArrayRef<Expr *> VarList,
PseudoDstExpr, PseudoSrcExpr);
if (AssignmentOp.isInvalid())
continue;
AssignmentOp =
ActOnFinishFullExpr(AssignmentOp.get(), ELoc, /*DiscardedValue*/ false);
AssignmentOp = ActOnFinishFullExpr(AssignmentOp.get(), ELoc,
/*DiscardedValue=*/true);
if (AssignmentOp.isInvalid())
continue;
@ -11357,8 +11347,7 @@ static bool actOnOMPReductionKindClause(
BO_Assign, LHSDRE, ConditionalOp);
}
if (ReductionOp.isUsable())
ReductionOp = S.ActOnFinishFullExpr(ReductionOp.get(),
/*DiscardedValue*/ false);
ReductionOp = S.ActOnFinishFullExpr(ReductionOp.get());
}
if (!ReductionOp.isUsable())
continue;
@ -11688,7 +11677,7 @@ OMPClause *Sema::ActOnOpenMPLinearClause(
buildDeclRefExpr(*this, SaveVar, StepExpr->getType(), StepLoc);
ExprResult CalcStep =
BuildBinOp(CurScope, StepLoc, BO_Assign, SaveRef.get(), StepExpr);
CalcStep = ActOnFinishFullExpr(CalcStep.get(), /*DiscardedValue*/ false);
CalcStep = ActOnFinishFullExpr(CalcStep.get());
// Warn about zero linear step (it would be probably better specified as
// making corresponding variables 'const').
@ -11776,7 +11765,7 @@ static bool FinishOpenMPLinearClause(OMPLinearClause &Clause, DeclRefExpr *IV,
else
Update = *CurPrivate;
Update = SemaRef.ActOnFinishFullExpr(Update.get(), DE->getBeginLoc(),
/*DiscardedValue*/ false);
/*DiscardedValue=*/true);
// Build final: Var = InitExpr + NumIterations * Step
ExprResult Final;
@ -11787,7 +11776,7 @@ static bool FinishOpenMPLinearClause(OMPLinearClause &Clause, DeclRefExpr *IV,
else
Final = *CurPrivate;
Final = SemaRef.ActOnFinishFullExpr(Final.get(), DE->getBeginLoc(),
/*DiscardedValue*/ false);
/*DiscardedValue=*/true);
if (!Update.isUsable() || !Final.isUsable()) {
Updates.push_back(nullptr);
@ -11955,7 +11944,7 @@ OMPClause *Sema::ActOnOpenMPCopyinClause(ArrayRef<Expr *> VarList,
if (AssignmentOp.isInvalid())
continue;
AssignmentOp = ActOnFinishFullExpr(AssignmentOp.get(), DE->getExprLoc(),
/*DiscardedValue*/ false);
/*DiscardedValue=*/true);
if (AssignmentOp.isInvalid())
continue;
@ -12063,8 +12052,8 @@ OMPClause *Sema::ActOnOpenMPCopyprivateClause(ArrayRef<Expr *> VarList,
DSAStack->getCurScope(), ELoc, BO_Assign, PseudoDstExpr, PseudoSrcExpr);
if (AssignmentOp.isInvalid())
continue;
AssignmentOp =
ActOnFinishFullExpr(AssignmentOp.get(), ELoc, /*DiscardedValue*/ false);
AssignmentOp = ActOnFinishFullExpr(AssignmentOp.get(), ELoc,
/*DiscardedValue=*/true);
if (AssignmentOp.isInvalid())
continue;

View File

@ -42,11 +42,12 @@
using namespace clang;
using namespace sema;
StmtResult Sema::ActOnExprStmt(ExprResult FE, bool DiscardedValue) {
StmtResult Sema::ActOnExprStmt(ExprResult FE) {
if (FE.isInvalid())
return StmtError();
FE = ActOnFinishFullExpr(FE.get(), FE.get()->getExprLoc(), DiscardedValue);
FE = ActOnFinishFullExpr(FE.get(), FE.get()->getExprLoc(),
/*DiscardedValue*/ true);
if (FE.isInvalid())
return StmtError();
@ -347,10 +348,6 @@ sema::CompoundScopeInfo &Sema::getCurCompoundScope() const {
return getCurFunction()->CompoundScopes.back();
}
bool Sema::isCurCompoundStmtAStmtExpr() const {
return getCurCompoundScope().IsStmtExpr;
}
StmtResult Sema::ActOnCompoundStmt(SourceLocation L, SourceLocation R,
ArrayRef<Stmt *> Elts, bool isStmtExpr) {
const unsigned NumElts = Elts.size();
@ -373,6 +370,14 @@ StmtResult Sema::ActOnCompoundStmt(SourceLocation L, SourceLocation R,
Diag(D->getLocation(), diag::ext_mixed_decls_code);
}
}
// Warn about unused expressions in statements.
for (unsigned i = 0; i != NumElts; ++i) {
// Ignore statements that are last in a statement expression.
if (isStmtExpr && i == NumElts - 1)
continue;
DiagnoseUnusedExprResult(Elts[i]);
}
// Check for suspicious empty body (null statement) in `for' and `while'
// statements. Don't do anything for template instantiations, this just adds
@ -464,12 +469,15 @@ Sema::ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHSVal,
/// ActOnCaseStmtBody - This installs a statement as the body of a case.
void Sema::ActOnCaseStmtBody(Stmt *S, Stmt *SubStmt) {
DiagnoseUnusedExprResult(SubStmt);
cast<CaseStmt>(S)->setSubStmt(SubStmt);
}
StmtResult
Sema::ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc,
Stmt *SubStmt, Scope *CurScope) {
DiagnoseUnusedExprResult(SubStmt);
if (getCurFunction()->SwitchStack.empty()) {
Diag(DefaultLoc, diag::err_default_not_in_switch);
return SubStmt;
@ -563,6 +571,9 @@ StmtResult Sema::BuildIfStmt(SourceLocation IfLoc, bool IsConstexpr,
if (IsConstexpr || isa<ObjCAvailabilityCheckExpr>(Cond.get().second))
setFunctionHasBranchProtectedScope();
DiagnoseUnusedExprResult(thenStmt);
DiagnoseUnusedExprResult(elseStmt);
return IfStmt::Create(Context, IfLoc, IsConstexpr, InitStmt, Cond.get().first,
Cond.get().second, thenStmt, ElseLoc, elseStmt);
}
@ -1290,6 +1301,8 @@ StmtResult Sema::ActOnWhileStmt(SourceLocation WhileLoc, ConditionResult Cond,
!Diags.isIgnored(diag::warn_comma_operator, CondVal.second->getExprLoc()))
CommaVisitor(*this).Visit(CondVal.second);
DiagnoseUnusedExprResult(Body);
if (isa<NullStmt>(Body))
getCurCompoundScope().setHasEmptyLoopBodies();
@ -1309,7 +1322,7 @@ Sema::ActOnDoStmt(SourceLocation DoLoc, Stmt *Body,
return StmtError();
Cond = CondResult.get();
CondResult = ActOnFinishFullExpr(Cond, DoLoc, /*DiscardedValue*/ false);
CondResult = ActOnFinishFullExpr(Cond, DoLoc);
if (CondResult.isInvalid())
return StmtError();
Cond = CondResult.get();
@ -1319,6 +1332,8 @@ Sema::ActOnDoStmt(SourceLocation DoLoc, Stmt *Body,
!Diags.isIgnored(diag::warn_comma_operator, Cond->getExprLoc()))
CommaVisitor(*this).Visit(Cond);
DiagnoseUnusedExprResult(Body);
return new (Context) DoStmt(Body, Cond, DoLoc, WhileLoc, CondRParen);
}
@ -1763,6 +1778,11 @@ StmtResult Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
CommaVisitor(*this).Visit(Second.get().second);
Expr *Third = third.release().getAs<Expr>();
DiagnoseUnusedExprResult(First);
DiagnoseUnusedExprResult(Third);
DiagnoseUnusedExprResult(Body);
if (isa<NullStmt>(Body))
getCurCompoundScope().setHasEmptyLoopBodies();
@ -1782,7 +1802,7 @@ StmtResult Sema::ActOnForEachLValueExpr(Expr *E) {
if (result.isInvalid()) return StmtError();
E = result.get();
ExprResult FullExpr = ActOnFinishFullExpr(E, /*DiscardedValue*/ false);
ExprResult FullExpr = ActOnFinishFullExpr(E);
if (FullExpr.isInvalid())
return StmtError();
return StmtResult(static_cast<Stmt*>(FullExpr.get()));
@ -1936,8 +1956,7 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc,
if (CollectionExprResult.isInvalid())
return StmtError();
CollectionExprResult =
ActOnFinishFullExpr(CollectionExprResult.get(), /*DiscardedValue*/ false);
CollectionExprResult = ActOnFinishFullExpr(CollectionExprResult.get());
if (CollectionExprResult.isInvalid())
return StmtError();
@ -2574,8 +2593,7 @@ StmtResult Sema::BuildCXXForRangeStmt(SourceLocation ForLoc,
if (!NotEqExpr.isInvalid())
NotEqExpr = CheckBooleanCondition(ColonLoc, NotEqExpr.get());
if (!NotEqExpr.isInvalid())
NotEqExpr =
ActOnFinishFullExpr(NotEqExpr.get(), /*DiscardedValue*/ false);
NotEqExpr = ActOnFinishFullExpr(NotEqExpr.get());
if (NotEqExpr.isInvalid()) {
Diag(RangeLoc, diag::note_for_range_invalid_iterator)
<< RangeLoc << 0 << BeginRangeRef.get()->getType();
@ -2598,7 +2616,7 @@ StmtResult Sema::BuildCXXForRangeStmt(SourceLocation ForLoc,
// co_await during the initial parse.
IncrExpr = ActOnCoawaitExpr(S, CoawaitLoc, IncrExpr.get());
if (!IncrExpr.isInvalid())
IncrExpr = ActOnFinishFullExpr(IncrExpr.get(), /*DiscardedValue*/ false);
IncrExpr = ActOnFinishFullExpr(IncrExpr.get());
if (IncrExpr.isInvalid()) {
Diag(RangeLoc, diag::note_for_range_invalid_iterator)
<< RangeLoc << 2 << BeginRangeRef.get()->getType() ;
@ -2853,7 +2871,7 @@ Sema::ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc,
return StmtError();
}
ExprResult ExprRes = ActOnFinishFullExpr(E, /*DiscardedValue*/ false);
ExprResult ExprRes = ActOnFinishFullExpr(E);
if (ExprRes.isInvalid())
return StmtError();
E = ExprRes.get();
@ -3203,8 +3221,7 @@ Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
ExpressionEvaluationContext::DiscardedStatement &&
(HasDeducedReturnType || CurCap->HasImplicitReturnType)) {
if (RetValExp) {
ExprResult ER =
ActOnFinishFullExpr(RetValExp, ReturnLoc, /*DiscardedValue*/ false);
ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
if (ER.isInvalid())
return StmtError();
RetValExp = ER.get();
@ -3331,8 +3348,7 @@ Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
}
if (RetValExp) {
ExprResult ER =
ActOnFinishFullExpr(RetValExp, ReturnLoc, /*DiscardedValue*/ false);
ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
if (ER.isInvalid())
return StmtError();
RetValExp = ER.get();
@ -3562,8 +3578,7 @@ StmtResult Sema::BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
ExpressionEvaluationContext::DiscardedStatement &&
FnRetType->getContainedAutoType()) {
if (RetValExp) {
ExprResult ER =
ActOnFinishFullExpr(RetValExp, ReturnLoc, /*DiscardedValue*/ false);
ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
if (ER.isInvalid())
return StmtError();
RetValExp = ER.get();
@ -3657,8 +3672,7 @@ StmtResult Sema::BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
}
if (RetValExp) {
ExprResult ER =
ActOnFinishFullExpr(RetValExp, ReturnLoc, /*DiscardedValue*/ false);
ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
if (ER.isInvalid())
return StmtError();
RetValExp = ER.get();
@ -3737,8 +3751,7 @@ StmtResult Sema::BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
}
if (RetValExp) {
ExprResult ER =
ActOnFinishFullExpr(RetValExp, ReturnLoc, /*DiscardedValue*/ false);
ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
if (ER.isInvalid())
return StmtError();
RetValExp = ER.get();
@ -3791,7 +3804,7 @@ StmtResult Sema::BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw) {
if (Result.isInvalid())
return StmtError();
Result = ActOnFinishFullExpr(Result.get(), /*DiscardedValue*/ false);
Result = ActOnFinishFullExpr(Result.get());
if (Result.isInvalid())
return StmtError();
Throw = Result.get();
@ -3863,7 +3876,7 @@ Sema::ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand) {
}
// The operand to @synchronized is a full-expression.
return ActOnFinishFullExpr(operand, /*DiscardedValue*/ false);
return ActOnFinishFullExpr(operand);
}
StmtResult

View File

@ -328,7 +328,7 @@ class TreeTransform {
/// other mechanism.
///
/// \returns the transformed statement.
StmtResult TransformStmt(Stmt *S, bool DiscardedValue = false);
StmtResult TransformStmt(Stmt *S);
/// Transform the given statement.
///
@ -3269,8 +3269,8 @@ class TreeTransform {
bool DeducibleTSTContext);
};
template <typename Derived>
StmtResult TreeTransform<Derived>::TransformStmt(Stmt *S, bool DiscardedValue) {
template<typename Derived>
StmtResult TreeTransform<Derived>::TransformStmt(Stmt *S) {
if (!S)
return S;
@ -3294,7 +3294,7 @@ StmtResult TreeTransform<Derived>::TransformStmt(Stmt *S, bool DiscardedValue) {
if (E.isInvalid())
return StmtError();
return getSema().ActOnExprStmt(E, DiscardedValue);
return getSema().ActOnExprStmt(E);
}
}
@ -4715,8 +4715,7 @@ TreeTransform<Derived>::TransformVariableArrayType(TypeLocBuilder &TLB,
}
if (SizeResult.isInvalid())
return QualType();
SizeResult =
SemaRef.ActOnFinishFullExpr(SizeResult.get(), /*DiscardedValue*/ false);
SizeResult = SemaRef.ActOnFinishFullExpr(SizeResult.get());
if (SizeResult.isInvalid())
return QualType();
@ -6521,9 +6520,7 @@ TreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S,
bool SubStmtChanged = false;
SmallVector<Stmt*, 8> Statements;
for (auto *B : S->body()) {
StmtResult Result =
getDerived().TransformStmt(B, !IsStmtExpr || B != S->body_back());
StmtResult Result = getDerived().TransformStmt(B);
if (Result.isInvalid()) {
// Immediately fail if this was a DeclStmt, since it's very
// likely that this will cause problems for future statements.

View File

@ -154,6 +154,32 @@ const Expr *bugreporter::getDerefExpr(const Stmt *S) {
return E;
}
/// Comparing internal representations of symbolic values (via
/// SVal::operator==()) is a valid way to check if the value was updated,
/// unless it's a LazyCompoundVal that may have a different internal
/// representation every time it is loaded from the state. In this function we
/// do an approximate comparison for lazy compound values, checking that they
/// are the immediate snapshots of the tracked region's bindings within the
/// node's respective states but not really checking that these snapshots
/// actually contain the same set of bindings.
bool hasVisibleUpdate(const ExplodedNode *LeftNode, SVal LeftVal,
const ExplodedNode *RightNode, SVal RightVal) {
if (LeftVal == RightVal)
return true;
const auto LLCV = LeftVal.getAs<nonloc::LazyCompoundVal>();
if (!LLCV)
return false;
const auto RLCV = RightVal.getAs<nonloc::LazyCompoundVal>();
if (!RLCV)
return false;
return LLCV->getRegion() == RLCV->getRegion() &&
LLCV->getStore() == LeftNode->getState()->getStore() &&
RLCV->getStore() == RightNode->getState()->getStore();
}
//===----------------------------------------------------------------------===//
// Definitions for bug reporter visitors.
//===----------------------------------------------------------------------===//
@ -1188,7 +1214,7 @@ FindLastStoreBRVisitor::VisitNode(const ExplodedNode *Succ,
if (Succ->getState()->getSVal(R) != V)
return nullptr;
if (Pred->getState()->getSVal(R) == V) {
if (hasVisibleUpdate(Pred, Pred->getState()->getSVal(R), Succ, V)) {
Optional<PostStore> PS = Succ->getLocationAs<PostStore>();
if (!PS || PS->getLocationValue() != R)
return nullptr;
@ -1209,6 +1235,7 @@ FindLastStoreBRVisitor::VisitNode(const ExplodedNode *Succ,
// UndefinedVal.)
if (Optional<CallEnter> CE = Succ->getLocationAs<CallEnter>()) {
if (const auto *VR = dyn_cast<VarRegion>(R)) {
const auto *Param = cast<ParmVarDecl>(VR->getDecl());
ProgramStateManager &StateMgr = BRC.getStateManager();

16
test/Analysis/PR40625.cpp Normal file
View File

@ -0,0 +1,16 @@
// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,alpha.core.CallAndMessageUnInitRefArg %s -verify
void f(const int *end);
void g(const int (&arrr)[10]) {
f(arrr+sizeof(arrr)); // expected-warning{{1st function call argument is a pointer to uninitialized value}}
// FIXME: This is a false positive that should be fixed. Until then this
// tests the crash fix in FindLastStoreBRVisitor (beside
// uninit-vals.m).
}
void h() {
int arr[10];
g(arr);
}

View File

@ -394,11 +394,11 @@ void testSmallStructBitfieldsFirstUnnamed() {
struct {
int : 4;
int y : 4;
} a, b, c;
} a, b, c; // expected-note{{'c' initialized here}}
a.y = 2;
b = a; // expected-note{{Value assigned to 'c'}}
b = a;
clang_analyzer_eval(b.y == 2); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
@ -411,11 +411,11 @@ void testSmallStructBitfieldsSecondUnnamed() {
struct {
int x : 4;
int : 4;
} a, b, c;
} a, b, c; // expected-note{{'c' initialized here}}
a.x = 1;
b = a; // expected-note{{Value assigned to 'c'}}
b = a;
clang_analyzer_eval(b.x == 1); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}

View File

@ -1,5 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s
// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -std=c++1z -Wc++14-compat -verify %s -DCPP17
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -std=c++1z -Wc++14-compat -verify %s -DCPP17
int f();
@ -71,6 +71,7 @@ void whileInitStatement() {
// last loop above. It would be nice to remove this.
void whileInitStatement2() {
while (; false) {} // expected-error {{expected expression}}
// expected-error@-1 {{expected ';' after expression}}
// expected-error@-2 {{expected expression}}
// expected-warning@-1 {{expression result unused}}
// expected-error@-2 {{expected ';' after expression}}
// expected-error@-3 {{expected expression}}
}

View File

@ -12,7 +12,7 @@ void completeParam(int param) {
void completeParamPragmaError(int param) {
Outer(__extension__({ _Pragma(2) })); // expected-error {{_Pragma takes a parenthesized string literal}}
param; // expected-warning {{expression result unused}}
param;
}
// RUN: %clang_cc1 -fsyntax-only -verify -code-completion-at=%s:16:1 %s | FileCheck %s

View File

@ -23,88 +23,112 @@
#define ARM64_TPIDRRO_EL0 ARM64_SYSREG(3,3,13, 0,3) // Thread ID Register, User Read Only [CP15_TPIDRURO]
#define ARM64_TPIDR_EL1 ARM64_SYSREG(3,0,13, 0,4) // Thread ID Register, Privileged Only [CP15_TPIDRPRW]
void check_ReadWriteStatusReg(int v) {
int ret;
// From intrin.h
__int64 _ReadStatusReg(int);
void _WriteStatusReg(int, __int64);
void check_ReadWriteStatusReg(__int64 v) {
__int64 ret;
ret = _ReadStatusReg(ARM64_CNTVCT);
// CHECK-ASM: mrs x8, CNTVCT_EL0
// CHECK-IR: call i64 @llvm.read_register.i64(metadata ![[MD2:.*]])
// CHECK-ASM: mrs x0, CNTVCT_EL0
// CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2:.*]])
// CHECK-IR-NEXT: store i64 %[[VAR]]
ret = _ReadStatusReg(ARM64_PMCCNTR_EL0);
// CHECK-ASM: mrs x8, PMCCNTR_EL0
// CHECK-IR: call i64 @llvm.read_register.i64(metadata ![[MD3:.*]])
// CHECK-ASM: mrs x0, PMCCNTR_EL0
// CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD3:.*]])
// CHECK-IR-NEXT: store i64 %[[VAR]]
ret = _ReadStatusReg(ARM64_PMSELR_EL0);
// CHECK-ASM: mrs x8, PMSELR_EL0
// CHECK-IR: call i64 @llvm.read_register.i64(metadata ![[MD4:.*]])
// CHECK-ASM: mrs x0, PMSELR_EL0
// CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD4:.*]])
// CHECK-IR-NEXT: store i64 %[[VAR]]
ret = _ReadStatusReg(ARM64_PMXEVCNTR_EL0);
// CHECK-ASM: mrs x8, PMXEVCNTR_EL0
// CHECK-IR: call i64 @llvm.read_register.i64(metadata ![[MD5:.*]])
// CHECK-ASM: mrs x0, PMXEVCNTR_EL0
// CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD5:.*]])
// CHECK-IR-NEXT: store i64 %[[VAR]]
ret = _ReadStatusReg(ARM64_PMXEVCNTRn_EL0(0));
// CHECK-ASM: mrs x8, PMEVCNTR0_EL0
// CHECK-IR: call i64 @llvm.read_register.i64(metadata ![[MD6:.*]])
// CHECK-ASM: mrs x0, PMEVCNTR0_EL0
// CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD6:.*]])
// CHECK-IR-NEXT: store i64 %[[VAR]]
ret = _ReadStatusReg(ARM64_PMXEVCNTRn_EL0(1));
// CHECK-ASM: mrs x8, PMEVCNTR1_EL0
// CHECK-IR: call i64 @llvm.read_register.i64(metadata ![[MD7:.*]])
// CHECK-ASM: mrs x0, PMEVCNTR1_EL0
// CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD7:.*]])
// CHECK-IR-NEXT: store i64 %[[VAR]]
ret = _ReadStatusReg(ARM64_PMXEVCNTRn_EL0(30));
// CHECK-ASM: mrs x8, PMEVCNTR30_EL0
// CHECK-IR: call i64 @llvm.read_register.i64(metadata ![[MD8:.*]])
// CHECK-ASM: mrs x0, PMEVCNTR30_EL0
// CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD8:.*]])
// CHECK-IR-NEXT: store i64 %[[VAR]]
ret = _ReadStatusReg(ARM64_TPIDR_EL0);
// CHECK-ASM: mrs x8, TPIDR_EL0
// CHECK-IR: call i64 @llvm.read_register.i64(metadata ![[MD9:.*]])
// CHECK-ASM: mrs x0, TPIDR_EL0
// CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD9:.*]])
// CHECK-IR-NEXT: store i64 %[[VAR]]
ret = _ReadStatusReg(ARM64_TPIDRRO_EL0);
// CHECK-ASM: mrs x8, TPIDRRO_EL0
// CHECK-IR: call i64 @llvm.read_register.i64(metadata ![[MD10:.*]])
// CHECK-ASM: mrs x0, TPIDRRO_EL0
// CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD10:.*]])
// CHECK-IR-NEXT: store i64 %[[VAR]]
ret = _ReadStatusReg(ARM64_TPIDR_EL1);
// CHECK-ASM: mrs x8, TPIDR_EL1
// CHECK-IR: call i64 @llvm.read_register.i64(metadata ![[MD11:.*]])
// CHECK-ASM: mrs x0, TPIDR_EL1
// CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD11:.*]])
// CHECK-IR-NEXT: store i64 %[[VAR]]
_WriteStatusReg(ARM64_CNTVCT, v);
// CHECK-ASM: msr S3_3_C14_C0_2, x8
// CHECK-IR: call void @llvm.write_register.i64(metadata ![[MD2:.*]], i64 {{%.*}})
// CHECK-ASM: msr S3_3_C14_C0_2, x0
// CHECK-IR: %[[VAR:.*]] = load i64,
// CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD2:.*]], i64 %[[VAR]])
_WriteStatusReg(ARM64_PMCCNTR_EL0, v);
// CHECK-ASM: msr PMCCNTR_EL0, x8
// CHECK-IR: call void @llvm.write_register.i64(metadata ![[MD3:.*]], i64 {{%.*}})
// CHECK-ASM: msr PMCCNTR_EL0, x0
// CHECK-IR: %[[VAR:.*]] = load i64,
// CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD3:.*]], i64 %[[VAR]])
_WriteStatusReg(ARM64_PMSELR_EL0, v);
// CHECK-ASM: msr PMSELR_EL0, x8
// CHECK-IR: call void @llvm.write_register.i64(metadata ![[MD4:.*]], i64 {{%.*}})
// CHECK-ASM: msr PMSELR_EL0, x0
// CHECK-IR: %[[VAR:.*]] = load i64,
// CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD4:.*]], i64 %[[VAR]])
_WriteStatusReg(ARM64_PMXEVCNTR_EL0, v);
// CHECK-ASM: msr PMXEVCNTR_EL0, x8
// CHECK-IR: call void @llvm.write_register.i64(metadata ![[MD5:.*]], i64 {{%.*}})
// CHECK-ASM: msr PMXEVCNTR_EL0, x0
// CHECK-IR: %[[VAR:.*]] = load i64,
// CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD5:.*]], i64 %[[VAR]])
_WriteStatusReg(ARM64_PMXEVCNTRn_EL0(0), v);
// CHECK-ASM: msr PMEVCNTR0_EL0, x8
// CHECK-IR: call void @llvm.write_register.i64(metadata ![[MD6:.*]], i64 {{%.*}})
// CHECK-ASM: msr PMEVCNTR0_EL0, x0
// CHECK-IR: %[[VAR:.*]] = load i64,
// CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD6:.*]], i64 %[[VAR]])
_WriteStatusReg(ARM64_PMXEVCNTRn_EL0(1), v);
// CHECK-ASM: msr PMEVCNTR1_EL0, x8
// CHECK-IR: call void @llvm.write_register.i64(metadata ![[MD7:.*]], i64 {{%.*}})
// CHECK-ASM: msr PMEVCNTR1_EL0, x0
// CHECK-IR: %[[VAR:.*]] = load i64,
// CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD7:.*]], i64 %[[VAR]])
_WriteStatusReg(ARM64_PMXEVCNTRn_EL0(30), v);
// CHECK-ASM: msr PMEVCNTR30_EL0, x8
// CHECK-IR: call void @llvm.write_register.i64(metadata ![[MD8:.*]], i64 {{%.*}})
// CHECK-ASM: msr PMEVCNTR30_EL0, x0
// CHECK-IR: %[[VAR:.*]] = load i64,
// CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD8:.*]], i64 %[[VAR]])
_WriteStatusReg(ARM64_TPIDR_EL0, v);
// CHECK-ASM: msr TPIDR_EL0, x8
// CHECK-IR: call void @llvm.write_register.i64(metadata ![[MD9:.*]], i64 {{%.*}})
// CHECK-ASM: msr TPIDR_EL0, x0
// CHECK-IR: %[[VAR:.*]] = load i64,
// CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD9:.*]], i64 %[[VAR]])
_WriteStatusReg(ARM64_TPIDRRO_EL0, v);
// CHECK-ASM: msr TPIDRRO_EL0, x8
// CHECK-IR: call void @llvm.write_register.i64(metadata ![[MD10:.*]], i64 {{%.*}})
// CHECK-ASM: msr TPIDRRO_EL0, x0
// CHECK-IR: %[[VAR:.*]] = load i64,
// CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD10:.*]], i64 %[[VAR]])
_WriteStatusReg(ARM64_TPIDR_EL1, v);
// CHECK-ASM: msr TPIDR_EL1, x8
// CHECK-IR: call void @llvm.write_register.i64(metadata ![[MD11:.*]], i64 {{%.*}})
// CHECK-ASM: msr TPIDR_EL1, x0
// CHECK-IR: %[[VAR:.*]] = load i64,
// CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD11:.*]], i64 %[[VAR]])
}
// CHECK-IR: ![[MD2]] = !{!"3:3:14:0:2"}

View File

@ -6,3 +6,6 @@ TooLargeAlignment TooBig;
// CHECK: @TooBig = dso_local global <16 x float> zeroinitializer, align 64
NormalAlignment JustRight;
// CHECK: @JustRight = common dso_local global <1 x float> zeroinitializer, align 4
TooLargeAlignment *IsAPointer;
// CHECK: @IsAPointer = common dso_local global <16 x float>* null, align 8

View File

@ -1,4 +1,6 @@
// RUN: %clang_cc1 -triple powerpc-unknown-freebsd -emit-llvm -o - %s| FileCheck -check-prefix=SVR4-CHECK %s
// RUN: %clang_cc1 -triple powerpc-unknown-netbsd -emit-llvm -o - %s| FileCheck -check-prefix=SVR4-CHECK %s
// RUN: %clang_cc1 -triple powerpc-unknown-openbsd -emit-llvm -o - %s| FileCheck -check-prefix=SVR4-CHECK %s
#include <stdarg.h>

View File

@ -0,0 +1,11 @@
// RUN: %clang_cc1 -triple wasm32-unknown-unknown-wasm -emit-llvm -o - %s | FileCheck %s
void __attribute__((import_module("bar"))) foo(void);
void call(void) {
foo();
}
// CHECK: declare void @foo() [[A:#[0-9]+]]
// CHECK: attributes [[A]] = {{{.*}} "wasm-import-module"="bar" {{.*}}}

View File

@ -0,0 +1,11 @@
// RUN: %clang_cc1 -triple wasm32-unknown-unknown-wasm -emit-llvm -o - %s | FileCheck %s
void __attribute__((import_name("bar"))) foo(void);
void call(void) {
foo();
}
// CHECK: declare void @foo() [[A:#[0-9]+]]
// CHECK: attributes [[A]] = {{{.*}} "wasm-import-name"="bar" {{.*}}}

View File

@ -30,6 +30,32 @@ void test_block() {
used(block);
}
// Using the variable being initialized is typically UB in C, but for blocks we
// can be nice: they imply extra book-keeping and we can do the auto-init before
// any of said book-keeping.
//
// UNINIT-LABEL: test_block_self_init(
// ZERO-LABEL: test_block_self_init(
// ZERO: %block = alloca <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i8* }>, align 8
// ZERO: %captured1 = getelementptr inbounds %struct.__block_byref_captured, %struct.__block_byref_captured* %captured, i32 0, i32 4
// ZERO-NEXT: store %struct.XYZ* null, %struct.XYZ** %captured1, align 8
// ZERO: %call = call %struct.XYZ* @create(
// PATTERN-LABEL: test_block_self_init(
// PATTERN: %block = alloca <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i8* }>, align 8
// PATTERN: %captured1 = getelementptr inbounds %struct.__block_byref_captured, %struct.__block_byref_captured* %captured, i32 0, i32 4
// PATTERN-NEXT: store %struct.XYZ* inttoptr (i64 -6148914691236517206 to %struct.XYZ*), %struct.XYZ** %captured1, align 8
// PATTERN: %call = call %struct.XYZ* @create(
void test_block_self_init() {
using Block = void (^)();
typedef struct XYZ {
Block block;
} * xyz_t;
extern xyz_t create(Block block);
__block xyz_t captured = create(^() {
(void)captured;
});
}
// This type of code is currently not handled by zero / pattern initialization.
// The test will break when that is fixed.
// UNINIT-LABEL: test_goto_unreachable_value(

View File

@ -178,6 +178,10 @@
// Oy_2: -momit-leaf-frame-pointer
// Oy_2: -O2
// RUN: %clang_cl --target=aarch64-pc-windows-msvc -Werror /Oy- /O2 -### -- %s 2>&1 | FileCheck -check-prefix=Oy_aarch64 %s
// Oy_aarch64: -mdisable-fp-elim
// Oy_aarch64: -O2
// RUN: %clang_cl --target=i686-pc-win32 -Werror /O2 /O2 -### -- %s 2>&1 | FileCheck -check-prefix=O2O2 %s
// O2O2: "-O2"

View File

@ -94,6 +94,7 @@
// CHECK-NEXT: ObjCBridge (SubjectMatchRule_record, SubjectMatchRule_type_alias)
// CHECK-NEXT: ObjCBridgeMutable (SubjectMatchRule_record)
// CHECK-NEXT: ObjCBridgeRelated (SubjectMatchRule_record)
// CHECK-NEXT: ObjCDesignatedInitializer (SubjectMatchRule_objc_method)
// CHECK-NEXT: ObjCException (SubjectMatchRule_objc_interface)
// CHECK-NEXT: ObjCExplicitProtocolImpl (SubjectMatchRule_objc_protocol)
// CHECK-NEXT: ObjCExternallyRetained (SubjectMatchRule_variable_not_is_parameter, SubjectMatchRule_function, SubjectMatchRule_block, SubjectMatchRule_objc_method)
@ -136,6 +137,8 @@
// CHECK-NEXT: WarnUnusedResult (SubjectMatchRule_objc_method, SubjectMatchRule_enum, SubjectMatchRule_record, SubjectMatchRule_hasType_functionType)
// CHECK-NEXT: Weak (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record)
// CHECK-NEXT: WeakRef (SubjectMatchRule_variable, SubjectMatchRule_function)
// CHECK-NEXT: WebAssemblyImportModule (SubjectMatchRule_function)
// CHECK-NEXT: WebAssemblyImportName (SubjectMatchRule_function)
// CHECK-NEXT: WorkGroupSizeHint (SubjectMatchRule_function)
// CHECK-NEXT: XRayInstrument (SubjectMatchRule_function, SubjectMatchRule_objc_method)
// CHECK-NEXT: XRayLogArgs (SubjectMatchRule_function, SubjectMatchRule_objc_method)

View File

@ -13,9 +13,9 @@ int f() {
if (T(n) = 0; n) {}
// init-statement expressions
if (T{f()}; f()) {} // expected-warning {{expression result unused}}
if (T{f()}, g, h; f()) {} // expected-warning 2{{unused}} expected-warning {{expression result unused}}
if (T(f()), g, h + 1; f()) {} // expected-warning 2{{unused}} expected-warning {{expression result unused}}
if (T{f()}; f()) {}
if (T{f()}, g, h; f()) {} // expected-warning 2{{unused}}
if (T(f()), g, h + 1; f()) {} // expected-warning 2{{unused}}
// condition declarations
if (T(n){g}) {}
@ -35,7 +35,7 @@ int f() {
// Likewise for 'switch'
switch (int n; n) {}
switch (g; int g = 5) {} // expected-warning {{expression result unused}}
switch (g; int g = 5) {}
if (int a, b; int c = a) { // expected-note 6{{previous}}
int a; // expected-error {{redefinition}}

View File

@ -105,7 +105,7 @@ void test9(int x) { // expected-note {{'x' declared here}}
expected-error {{expected expression}}
8:: x; // expected-error {{expected ';' after expression}} \
expected-error {{no member named 'x' in the global namespace; did you mean simply 'x'?}} \
expected-warning {{expression result unused}}
expected-warning 2 {{expression result unused}}
9:: :y; // expected-error {{expected ';' after expression}} \
expected-error {{expected unqualified-id}} \
expected-warning {{expression result unused}}

View File

@ -1,5 +1,5 @@
// RUN: %clang_cc1 -std=c++1z -Wno-unused-value -verify %s
// RUN: %clang_cc1 -std=c++17 -Wno-unused-value -verify %s
// RUN: %clang_cc1 -std=c++1z -verify %s
// RUN: %clang_cc1 -std=c++17 -verify %s
void testIf() {
int x = 0;
@ -12,7 +12,7 @@ void testIf() {
int x = 0; // expected-error {{redefinition of 'x'}}
if (x; int a = 0) ++a;
if (x, +x; int a = 0) // expected-note 2 {{previous definition is here}}
if (x, +x; int a = 0) // expected-note 2 {{previous definition is here}} expected-warning {{unused}}
int a = 0; // expected-error {{redefinition of 'a'}}
else
int a = 0; // expected-error {{redefinition of 'a'}}
@ -48,7 +48,7 @@ void testSwitch() {
++a;
}
switch (x, +x; int a = 0) { // expected-note {{previous definition is here}}
switch (x, +x; int a = 0) { // expected-note {{previous definition is here}} expected-warning {{unused}}
case 0:
int a = 0; // expected-error {{redefinition of 'a'}} // expected-note {{previous definition is here}}
case 1:

View File

@ -244,7 +244,7 @@ void foo ()
{
int b = 1, a[b];
a[0] = 0;
[&] { for (int c : a) 0; } (); // expected-warning {{expression result unused}}
[&] { for (int c : a) 0; } ();
}

View File

@ -44,17 +44,17 @@ void Convert(float f, double d, long double ld) {
void CompoundAssignment() {
int x = 3;
x += 1.234; //expected-warning{{conversion}}
x -= -0.0; //expected-warning{{conversion}}
x *= 1.1f; //expected-warning{{conversion}}
x /= -2.2f; //expected-warning{{conversion}}
x += 1.234; // expected-warning {{implicit conversion turns floating-point number into integer: 'double' to 'int'}}
x -= -0.0; // expected-warning {{implicit conversion turns floating-point number into integer: 'double' to 'int'}}
x *= 1.1f; // expected-warning {{implicit conversion turns floating-point number into integer: 'float' to 'int'}}
x /= -2.2f; // expected-warning {{implicit conversion turns floating-point number into integer: 'float' to 'int'}}
int y = x += 1.4f; //expected-warning{{conversion}}
int y = x += 1.4f; // expected-warning {{implicit conversion turns floating-point number into integer: 'float' to 'int'}}
float z = 1.1f;
double w = -2.2;
y += z + w; //expected-warning{{conversion}}
y += z + w; // expected-warning {{implicit conversion turns floating-point number into integer: 'double' to 'int'}}
}
# 1 "foo.h" 3

View File

@ -33,36 +33,6 @@ void test() {
const S &s4 = g1();
}
void testSubstmts(int i) {
switch (i) {
case 0:
f(); // expected-warning {{ignoring return value}}
default:
f(); // expected-warning {{ignoring return value}}
}
if (i)
f(); // expected-warning {{ignoring return value}}
else
f(); // expected-warning {{ignoring return value}}
while (i)
f(); // expected-warning {{ignoring return value}}
do
f(); // expected-warning {{ignoring return value}}
while (i);
for (f(); // expected-warning {{ignoring return value}}
;
f() // expected-warning {{ignoring return value}}
)
f(); // expected-warning {{ignoring return value}}
f(), // expected-warning {{ignoring return value}}
(void)f();
}
struct X {
int foo() __attribute__((warn_unused_result));
};
@ -236,13 +206,3 @@ void f() {
(void)++p;
}
} // namespace
namespace PR39837 {
[[clang::warn_unused_result]] int f(int);
void g() {
int a[2];
for (int b : a)
f(b); // expected-warning {{ignoring return value}}
}
} // namespace PR39837

View File

@ -3,7 +3,7 @@
#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
#define NS_UNAVAILABLE __attribute__((unavailable))
void fnfoo(void) NS_DESIGNATED_INITIALIZER; // expected-error {{only applies to init methods of interface or class extension declarations}}
void fnfoo(void) NS_DESIGNATED_INITIALIZER; // expected-error {{'objc_designated_initializer' attribute only applies to Objective-C methods}}
@protocol P1
-(id)init NS_DESIGNATED_INITIALIZER; // expected-error {{only applies to init methods of interface or class extension declarations}}
@ -428,3 +428,16 @@ __attribute__((objc_root_class))
@interface CategoryForMissingInterface(Cat) // expected-error{{cannot find interface declaration}}
- (instancetype)init NS_DESIGNATED_INITIALIZER; // expected-error{{only applies to init methods of interface or class extension declarations}}
@end
@interface TwoAttrs
-(instancetype)foo
__attribute__((objc_designated_initializer))
__attribute__((objc_method_family(init)));
-(instancetype)bar
__attribute__((objc_method_family(init)))
__attribute__((objc_designated_initializer));
-(instancetype)baz
__attribute__((objc_designated_initializer, objc_method_family(init)));
-(instancetype)quux
__attribute__((objc_method_family(init), objc_designated_initializer));
@end

View File

@ -14,4 +14,11 @@ void radar14415662(RDar14415662 *f, char x, int y) {
x = y; // expected-warning {{implicit conversion loses integer precision: 'int' to 'char'}}
}
__attribute__((objc_root_class)) @interface DoubleProp
@property double d;
@end
void use_double_prop(DoubleProp *dp) {
double local = 42;
dp.d += local; // no warning
}

View File

@ -2,12 +2,14 @@
// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown
// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown
// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
// RUN: %clang_cc1 -x cl -cl-std=c++ %s -verify -triple spir-unknown-unknown
// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
// RUN: %clang_cc1 -x cl -cl-std=c++ %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
#if __OPENCL_C_VERSION__ >= 200 && ! defined TEST_CORE_FEATURES
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) && !defined(TEST_CORE_FEATURES)
// expected-no-diagnostics
#endif
@ -47,44 +49,44 @@
#ifndef cl_khr_byte_addressable_store
#error "Missing cl_khr_byte_addressable_store define"
#endif
#pragma OPENCL EXTENSION cl_khr_byte_addressable_store: enable
#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
// expected-warning@-2{{OpenCL extension 'cl_khr_byte_addressable_store' is core feature or supported optional core feature - ignoring}}
#endif
#ifndef cl_khr_global_int32_base_atomics
#error "Missing cl_khr_global_int32_base_atomics define"
#endif
#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics: enable
#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
// expected-warning@-2{{OpenCL extension 'cl_khr_global_int32_base_atomics' is core feature or supported optional core feature - ignoring}}
#endif
#ifndef cl_khr_global_int32_extended_atomics
#error "Missing cl_khr_global_int32_extended_atomics define"
#endif
#pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics: enable
#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
#pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics : enable
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
// expected-warning@-2{{OpenCL extension 'cl_khr_global_int32_extended_atomics' is core feature or supported optional core feature - ignoring}}
#endif
#ifndef cl_khr_local_int32_base_atomics
#error "Missing cl_khr_local_int32_base_atomics define"
#endif
#pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics: enable
#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
#pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics : enable
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
// expected-warning@-2{{OpenCL extension 'cl_khr_local_int32_base_atomics' is core feature or supported optional core feature - ignoring}}
#endif
#ifndef cl_khr_local_int32_extended_atomics
#error "Missing cl_khr_local_int32_extended_atomics define"
#endif
#pragma OPENCL EXTENSION cl_khr_local_int32_extended_atomics: enable
#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
#pragma OPENCL EXTENSION cl_khr_local_int32_extended_atomics : enable
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
// expected-warning@-2{{OpenCL extension 'cl_khr_local_int32_extended_atomics' is core feature or supported optional core feature - ignoring}}
#endif
#if (__OPENCL_C_VERSION__ < 110)
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 110)
// Deprecated abvoe 1.0
#ifndef cl_khr_select_fprounding_mode
#error "Missing cl_khr_select_fp_rounding_mode define"
@ -97,8 +99,8 @@
#ifndef cl_khr_fp64
#error "Missing cl_khr_fp64 define"
#endif
#pragma OPENCL EXTENSION cl_khr_fp64: enable
#if (__OPENCL_C_VERSION__ >= 120) && defined TEST_CORE_FEATURES
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120) && defined TEST_CORE_FEATURES
// expected-warning@-2{{OpenCL extension 'cl_khr_fp64' is core feature or supported optional core feature - ignoring}}
#endif
@ -106,131 +108,129 @@
#ifndef cl_khr_3d_image_writes
#error "Missing cl_khr_3d_image_writes define"
#endif
#pragma OPENCL EXTENSION cl_khr_3d_image_writes: enable
#if (__OPENCL_C_VERSION__ >= 200) && defined TEST_CORE_FEATURES
#pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) && defined TEST_CORE_FEATURES
// expected-warning@-2{{OpenCL extension 'cl_khr_3d_image_writes' is core feature or supported optional core feature - ignoring}}
#endif
#if (__OPENCL_C_VERSION__ >= 110)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110)
#ifndef cl_khr_gl_event
#error "Missing cl_khr_gl_event define"
#endif
#else
// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_gl_event' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_khr_gl_event: enable
#pragma OPENCL EXTENSION cl_khr_gl_event : enable
#if (__OPENCL_C_VERSION__ >= 110)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110)
#ifndef cl_khr_d3d10_sharing
#error "Missing cl_khr_d3d10_sharing define"
#endif
#else
// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_d3d10_sharing' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_khr_d3d10_sharing: enable
#pragma OPENCL EXTENSION cl_khr_d3d10_sharing : enable
#if (__OPENCL_C_VERSION__ >= 110)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110)
#ifndef cles_khr_int64
#error "Missing cles_khr_int64 define"
#endif
#else
// expected-warning@+2{{unsupported OpenCL extension 'cles_khr_int64' - ignoring}}
#endif
#pragma OPENCL EXTENSION cles_khr_int64: enable
#pragma OPENCL EXTENSION cles_khr_int64 : enable
#if (__OPENCL_C_VERSION__ >= 120)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
#ifndef cl_khr_context_abort
#error "Missing cl_context_abort define"
#endif
#else
// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_context_abort' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_khr_context_abort: enable
#pragma OPENCL EXTENSION cl_khr_context_abort : enable
#if (__OPENCL_C_VERSION__ >= 120)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
#ifndef cl_khr_d3d11_sharing
#error "Missing cl_khr_d3d11_sharing define"
#endif
#else
// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_d3d11_sharing' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_khr_d3d11_sharing: enable
#pragma OPENCL EXTENSION cl_khr_d3d11_sharing : enable
#if (__OPENCL_C_VERSION__ >= 120)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
#ifndef cl_khr_dx9_media_sharing
#error "Missing cl_khr_dx9_media_sharing define"
#endif
#else
// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_dx9_media_sharing' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_khr_dx9_media_sharing: enable
#pragma OPENCL EXTENSION cl_khr_dx9_media_sharing : enable
#if (__OPENCL_C_VERSION__ >= 120)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
#ifndef cl_khr_image2d_from_buffer
#error "Missing cl_khr_image2d_from_buffer define"
#endif
#else
// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_image2d_from_buffer' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_khr_image2d_from_buffer: enable
#pragma OPENCL EXTENSION cl_khr_image2d_from_buffer : enable
#if (__OPENCL_C_VERSION__ >= 120)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
#ifndef cl_khr_initialize_memory
#error "Missing cl_khr_initialize_memory define"
#endif
#else
// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_initialize_memory' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_khr_initialize_memory: enable
#pragma OPENCL EXTENSION cl_khr_initialize_memory : enable
#if (__OPENCL_C_VERSION__ >= 120)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
#ifndef cl_khr_gl_depth_images
#error "Missing cl_khr_gl_depth_images define"
#endif
#else
// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_gl_depth_images' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_khr_gl_depth_images: enable
#pragma OPENCL EXTENSION cl_khr_gl_depth_images : enable
#if (__OPENCL_C_VERSION__ >= 120)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
#ifndef cl_khr_gl_msaa_sharing
#error "Missing cl_khr_gl_msaa_sharing define"
#endif
#else
// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_gl_msaa_sharing' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing: enable
#pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable
#if (__OPENCL_C_VERSION__ >= 120)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
#ifndef cl_khr_spir
#error "Missing cl_khr_spir define"
#endif
#else
// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_spir' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_khr_spir: enable
#pragma OPENCL EXTENSION cl_khr_spir : enable
#if (__OPENCL_C_VERSION__ >= 200)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
#ifndef cl_khr_egl_event
#error "Missing cl_khr_egl_event define"
#endif
#else
// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_egl_event' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_khr_egl_event: enable
#pragma OPENCL EXTENSION cl_khr_egl_event : enable
#if (__OPENCL_C_VERSION__ >= 200)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
#ifndef cl_khr_egl_image
#error "Missing cl_khr_egl_image define"
#endif
#else
// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_egl_image' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_khr_egl_image: enable
#pragma OPENCL EXTENSION cl_khr_egl_image : enable
#if (__OPENCL_C_VERSION__ >= 200)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
#ifndef cl_khr_mipmap_image
#error "Missing cl_khr_mipmap_image define"
#endif
@ -240,18 +240,18 @@
#endif
// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_mipmap_image' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable
#pragma OPENCL EXTENSION cl_khr_mipmap_image : enable
#if (__OPENCL_C_VERSION__ >= 200)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
#ifndef cl_khr_srgb_image_writes
#error "Missing cl_khr_srgb_image_writes define"
#endif
#else
// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_srgb_image_writes' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_khr_srgb_image_writes: enable
#pragma OPENCL EXTENSION cl_khr_srgb_image_writes : enable
#if (__OPENCL_C_VERSION__ >= 200)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
#ifndef cl_khr_subgroups
#error "Missing cl_khr_subgroups define"
#endif
@ -261,9 +261,9 @@
#endif
// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroups' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_khr_subgroups: enable
#pragma OPENCL EXTENSION cl_khr_subgroups : enable
#if (__OPENCL_C_VERSION__ >= 200)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
#ifndef cl_khr_terminate_context
#error "Missing cl_khr_terminate_context define"
#endif
@ -280,9 +280,9 @@
#ifndef cl_amd_media_ops2
#error "Missing cl_amd_media_ops2 define"
#endif
#pragma OPENCL EXTENSION cl_amd_media_ops2: enable
#pragma OPENCL EXTENSION cl_amd_media_ops2 : enable
#if (__OPENCL_C_VERSION__ >= 120)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
#ifndef cl_khr_depth_images
#error "Missing cl_khr_depth_images define"
#endif
@ -292,9 +292,9 @@
#endif
// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_depth_images' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_khr_depth_images: enable
#pragma OPENCL EXTENSION cl_khr_depth_images : enable
#if (__OPENCL_C_VERSION__ >= 120)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
#ifndef cl_intel_subgroups
#error "Missing cl_intel_subgroups define"
#endif
@ -303,7 +303,7 @@
#endif
#pragma OPENCL EXTENSION cl_intel_subgroups : enable
#if (__OPENCL_C_VERSION__ >= 120)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
#ifndef cl_intel_subgroups_short
#error "Missing cl_intel_subgroups_short define"
#endif
@ -312,7 +312,7 @@
#endif
#pragma OPENCL EXTENSION cl_intel_subgroups_short : enable
#if (__OPENCL_C_VERSION__ >= 120)
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
#ifndef cl_intel_device_side_avc_motion_estimation
#error "Missing cl_intel_device_side_avc_motion_estimation define"
#endif

View File

@ -28,6 +28,7 @@
// enabled by default with -cl-std=CL2.0).
//
// RUN: %clang_cc1 %s -triple amdgcn-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL2.0 -finclude-default-header
// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=c++
#ifdef _OPENCL_H_
// expected-no-diagnostics
@ -37,7 +38,11 @@
// expected-no-diagnostics
#endif
#if __OPENCL_C_VERSION__ < 120
#ifdef __OPENCL_CPP_VERSION__
// expected-no-diagnostics
#endif
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 120)
void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
(void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
@ -89,7 +94,7 @@ void f2(void) {
// expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
#endif
#if __OPENCL_C_VERSION__ < 120
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 120)
void f3(void) {
double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
}