@@ -346,11 +346,14 @@ static bool addExceptionArgs(const ArgList &Args, types::ID InputType,
346
346
bool EH = Args.hasFlag (options::OPT_fexceptions, options::OPT_fno_exceptions,
347
347
false );
348
348
349
- bool EHa = Args.hasFlag (options::OPT_fasync_exceptions,
350
- options::OPT_fno_async_exceptions, false );
351
- if (EHa) {
352
- CmdArgs.push_back (" -fasync-exceptions" );
353
- EH = true ;
349
+ // Async exceptions are Windows MSVC only.
350
+ if (Triple.isWindowsMSVCEnvironment ()) {
351
+ bool EHa = Args.hasFlag (options::OPT_fasync_exceptions,
352
+ options::OPT_fno_async_exceptions, false );
353
+ if (EHa) {
354
+ CmdArgs.push_back (" -fasync-exceptions" );
355
+ EH = true ;
356
+ }
354
357
}
355
358
356
359
// Obj-C exceptions are enabled by default, regardless of -fexceptions. This
@@ -8102,7 +8105,8 @@ struct EHFlags {
8102
8105
// / The 'a' modifier is unimplemented and fundamentally hard in LLVM IR.
8103
8106
// / - c: Assume that extern "C" functions are implicitly nounwind.
8104
8107
// / The default is /EHs-c-, meaning cleanups are disabled.
8105
- static EHFlags parseClangCLEHFlags (const Driver &D, const ArgList &Args) {
8108
+ static EHFlags parseClangCLEHFlags (const Driver &D, const ArgList &Args,
8109
+ bool isWindowsMSVC) {
8106
8110
EHFlags EH;
8107
8111
8108
8112
std::vector<std::string> EHArgs =
@@ -8112,8 +8116,15 @@ static EHFlags parseClangCLEHFlags(const Driver &D, const ArgList &Args) {
8112
8116
switch (EHVal[I]) {
8113
8117
case ' a' :
8114
8118
EH.Asynch = maybeConsumeDash (EHVal, I);
8115
- if (EH.Asynch )
8119
+ if (EH.Asynch ) {
8120
+ // Async exceptions are Windows MSVC only.
8121
+ if (!isWindowsMSVC) {
8122
+ EH.Asynch = false ;
8123
+ D.Diag (clang::diag::warn_drv_unused_argument) << " /EHa" << EHVal;
8124
+ continue ;
8125
+ }
8116
8126
EH.Synch = false ;
8127
+ }
8117
8128
continue ;
8118
8129
case ' c' :
8119
8130
EH.NoUnwindC = maybeConsumeDash (EHVal, I);
@@ -8177,7 +8188,8 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
8177
8188
8178
8189
const Driver &D = getToolChain ().getDriver ();
8179
8190
8180
- EHFlags EH = parseClangCLEHFlags (D, Args);
8191
+ bool IsWindowsMSVC = getToolChain ().getTriple ().isWindowsMSVCEnvironment ();
8192
+ EHFlags EH = parseClangCLEHFlags (D, Args, IsWindowsMSVC);
8181
8193
if (!isNVPTX && (EH.Synch || EH.Asynch )) {
8182
8194
if (types::isCXX (InputType))
8183
8195
CmdArgs.push_back (" -fcxx-exceptions" );
0 commit comments