@@ -3083,7 +3083,6 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
30833083 Clause = ParseOpenMPSingleExprClause (CKind, WrongDirective);
30843084 break ;
30853085 case OMPC_fail:
3086- case OMPC_default:
30873086 case OMPC_proc_bind:
30883087 case OMPC_atomic_default_mem_order:
30893088 case OMPC_at:
@@ -3115,6 +3114,7 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
31153114 case OMPC_schedule:
31163115 case OMPC_dist_schedule:
31173116 case OMPC_defaultmap:
3117+ case OMPC_default:
31183118 case OMPC_order:
31193119 // OpenMP [2.7.1, Restrictions, p. 3]
31203120 // Only one schedule clause can appear on a loop directive.
@@ -3734,6 +3734,32 @@ OMPClause *Parser::ParseOpenMPSingleExprWithArgClause(OpenMPDirectiveKind DKind,
37343734 ConsumeAnyToken ();
37353735 if (Arg.back () == OMPC_DIST_SCHEDULE_static && Tok.is (tok::comma))
37363736 DelimLoc = ConsumeAnyToken ();
3737+ } else if (Kind == OMPC_default) {
3738+ // Get a default modifier
3739+ unsigned Modifier = getOpenMPSimpleClauseType (
3740+ Kind, Tok.isAnnotation () ? " " : PP.getSpelling (Tok), getLangOpts ());
3741+
3742+ Arg.push_back (Modifier);
3743+ KLoc.push_back (Tok.getLocation ());
3744+ if (Tok.isNot (tok::r_paren) && Tok.isNot (tok::comma) &&
3745+ Tok.isNot (tok::annot_pragma_openmp_end))
3746+ ConsumeAnyToken ();
3747+ // Parse ':'
3748+ if (Tok.is (tok::colon) && getLangOpts ().OpenMP >= 60 ) {
3749+ ConsumeAnyToken ();
3750+ // Get a variable-category attribute for default clause modifier
3751+ OpenMPDefaultClauseVariableCategory VariableCategory =
3752+ getOpenMPDefaultVariableCategory (
3753+ Tok.isAnnotation () ? " " : PP.getSpelling (Tok), getLangOpts ());
3754+ Arg.push_back (VariableCategory);
3755+ KLoc.push_back (Tok.getLocation ());
3756+ if (Tok.isNot (tok::r_paren) && Tok.isNot (tok::comma) &&
3757+ Tok.isNot (tok::annot_pragma_openmp_end))
3758+ ConsumeAnyToken ();
3759+ } else {
3760+ Arg.push_back (OMPC_DEFAULT_VC_all);
3761+ KLoc.push_back (SourceLocation ());
3762+ }
37373763 } else if (Kind == OMPC_defaultmap) {
37383764 // Get a defaultmap modifier
37393765 unsigned Modifier = getOpenMPSimpleClauseType (
@@ -3932,6 +3958,18 @@ OMPClause *Parser::ParseOpenMPSingleExprWithArgClause(OpenMPDirectiveKind DKind,
39323958 if (NeedAnExpression && Val.isInvalid ())
39333959 return nullptr ;
39343960
3961+ if (Kind == OMPC_default && getLangOpts ().OpenMP < 51 && Arg[0 ] &&
3962+ (static_cast <DefaultKind>(Arg[0 ]) == OMP_DEFAULT_private ||
3963+ static_cast <DefaultKind>(Arg[0 ]) == OMP_DEFAULT_firstprivate)) {
3964+ Diag (KLoc[0 ], diag::err_omp_invalid_dsa)
3965+ << getOpenMPClauseName (static_cast <DefaultKind>(Arg[0 ]) ==
3966+ OMP_DEFAULT_private
3967+ ? OMPC_private
3968+ : OMPC_firstprivate)
3969+ << getOpenMPClauseName (OMPC_default) << " 5.1" ;
3970+ return nullptr ;
3971+ }
3972+
39353973 if (ParseOnly)
39363974 return nullptr ;
39373975 return Actions.OpenMP ().ActOnOpenMPSingleExprWithArgClause (
0 commit comments