Skip to content

Commit d82d00d

Browse files
author
Hal Finkel
committed
enable C++ features in F90 mode (except for Lex changes)
1 parent e448f7a commit d82d00d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+544
-544
lines changed

include/lfort/AST/ASTContext.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
12431243

12441244
/// \brief The result type of logical operations, '<', '>', '!=', etc.
12451245
QualType getLogicalOperationType() const {
1246-
return getLangOpts().CPlusPlus ? BoolTy : IntTy;
1246+
return getLangOpts().F90 ? BoolTy : IntTy;
12471247
}
12481248

12491249
/// \brief Emit the Objective-CC type encoding for the given type \p T into

include/lfort/Parse/Parser.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1658,7 +1658,7 @@ class Parser : public CodeCompletionHandler {
16581658
/// decl-specifier, and isn't part of an expression such as a function-style
16591659
/// cast. Return false if it's no a decl-specifier, or we're not sure.
16601660
bool isKnownToBeDeclarationSpecifier() {
1661-
if (getLangOpts().CPlusPlus)
1661+
if (getLangOpts().F90)
16621662
return isCXXDeclarationSpecifier() == TPResult::True();
16631663
return isDeclarationSpecifier(true);
16641664
}
@@ -1667,7 +1667,7 @@ class Parser : public CodeCompletionHandler {
16671667
/// expression statement, when parsing function bodies.
16681668
/// Returns true for declaration, false for expression.
16691669
bool isDeclarationStatement() {
1670-
if (getLangOpts().CPlusPlus)
1670+
if (getLangOpts().F90)
16711671
return isCXXDeclarationStatement();
16721672
return isDeclarationSpecifier(true);
16731673
}
@@ -1677,7 +1677,7 @@ class Parser : public CodeCompletionHandler {
16771677
// 'for-init-statement' part of a 'for' statement.
16781678
/// Returns true for declaration, false for expression.
16791679
bool isForInitDeclaration() {
1680-
if (getLangOpts().CPlusPlus)
1680+
if (getLangOpts().F90)
16811681
return isCXXSimpleDeclaration(/*AllowForRangeDecl=*/true);
16821682
return isDeclarationSpecifier(true);
16831683
}
@@ -1703,7 +1703,7 @@ class Parser : public CodeCompletionHandler {
17031703
/// whether the parens contain an expression or a type-id.
17041704
/// Returns true for a type-id and false for an expression.
17051705
bool isTypeIdInParens(bool &isAmbiguous) {
1706-
if (getLangOpts().CPlusPlus)
1706+
if (getLangOpts().F90)
17071707
return isCXXTypeId(TypeIdInParens, isAmbiguous);
17081708
isAmbiguous = false;
17091709
return isTypeSpecifierQualifier();

include/lfort/StaticAnalyzer/Core/PathSensitive/SValBuilder.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class SValBuilder {
123123
ProgramStateManager &getStateManager() { return StateMgr; }
124124

125125
QualType getConditionType() const {
126-
return Context.getLangOpts().CPlusPlus ? Context.BoolTy : Context.IntTy;
126+
return Context.getLangOpts().F90 ? Context.BoolTy : Context.IntTy;
127127
}
128128

129129
QualType getArrayIndexType() const {

lib/AST/ASTContext.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ ASTContext::getCanonicalTemplateTemplateParmDecl(
570570
}
571571

572572
FortranABI *ASTContext::createFortranABI(const TargetInfo &T) {
573-
if (!LangOpts.CPlusPlus) return 0;
573+
if (!LangOpts.F90) return 0;
574574

575575
switch (T.getFortranABI()) {
576576
case FortranABI_ARM:
@@ -720,14 +720,14 @@ void ASTContext::PrintStats() const {
720720
llvm::errs() << NumImplicitCopyConstructorsDeclared << "/"
721721
<< NumImplicitCopyConstructors
722722
<< " implicit copy constructors created\n";
723-
if (getLangOpts().CPlusPlus)
723+
if (getLangOpts().F90)
724724
llvm::errs() << NumImplicitMoveConstructorsDeclared << "/"
725725
<< NumImplicitMoveConstructors
726726
<< " implicit move constructors created\n";
727727
llvm::errs() << NumImplicitCopyAssignmentOperatorsDeclared << "/"
728728
<< NumImplicitCopyAssignmentOperators
729729
<< " implicit copy assignment operators created\n";
730-
if (getLangOpts().CPlusPlus)
730+
if (getLangOpts().F90)
731731
llvm::errs() << NumImplicitMoveAssignmentOperatorsDeclared << "/"
732732
<< NumImplicitMoveAssignmentOperators
733733
<< " implicit move assignment operators created\n";
@@ -820,7 +820,7 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target) {
820820
InitBuiltinType(Int128Ty, BuiltinType::Int128);
821821
InitBuiltinType(UnsignedInt128Ty, BuiltinType::UInt128);
822822

823-
if (LangOpts.CPlusPlus && LangOpts.WChar) { // C++ 3.9.1p5
823+
if (LangOpts.F90 && LangOpts.WChar) { // C++ 3.9.1p5
824824
if (TargetInfo::isTypeSigned(Target.getWCharType()))
825825
InitBuiltinType(WCharTy, BuiltinType::WChar_S);
826826
else // -fshort-wchar makes wchar_t be unsigned.
@@ -830,12 +830,12 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target) {
830830

831831
WIntTy = getFromTargetType(Target.getWIntType());
832832

833-
if (LangOpts.CPlusPlus) // C++0x 3.9.1p5, extension for C++
833+
if (LangOpts.F90) // C++0x 3.9.1p5, extension for C++
834834
InitBuiltinType(Char16Ty, BuiltinType::Char16);
835835
else // C99
836836
Char16Ty = getFromTargetType(Target.getChar16Type());
837837

838-
if (LangOpts.CPlusPlus) // C++0x 3.9.1p5, extension for C++
838+
if (LangOpts.F90) // C++0x 3.9.1p5, extension for C++
839839
InitBuiltinType(Char32Ty, BuiltinType::Char32);
840840
else // C99
841841
Char32Ty = getFromTargetType(Target.getChar32Type());
@@ -1245,7 +1245,7 @@ ASTContext::getTypeInfoDataSizeInChars(QualType T) const {
12451245
// In C++, objects can sometimes be allocated into the tail padding
12461246
// of a base-class subobject. We decide whether that's possible
12471247
// during class layout, so here we can just trust the layout results.
1248-
if (getLangOpts().CPlusPlus) {
1248+
if (getLangOpts().F90) {
12491249
if (const RecordType *RT = T->getAs<RecordType>()) {
12501250
const ASTRecordLayout &layout = getASTRecordLayout(RT->getDecl());
12511251
sizeAndAlign.first = layout.getDataSize();
@@ -4252,7 +4252,7 @@ static RecordDecl *
42524252
CreateRecordDecl(const ASTContext &Ctx, RecordDecl::TagKind TK,
42534253
DeclContext *DC, IdentifierInfo *Id) {
42544254
SourceLocation Loc;
4255-
if (Ctx.getLangOpts().CPlusPlus)
4255+
if (Ctx.getLangOpts().F90)
42564256
return CXXRecordDecl::Create(Ctx, TK, DC, Loc, Loc, Id);
42574257
else
42584258
return RecordDecl::Create(Ctx, TK, DC, Loc, Loc, Id);
@@ -5676,7 +5676,7 @@ static TypedefDecl *CreatePNaClABIBuiltinVaListDecl(const ASTContext *Context) {
56765676
static TypedefDecl *
56775677
CreateAAPCSABIBuiltinVaListDecl(const ASTContext *Context) {
56785678
RecordDecl *VaListDecl;
5679-
if (Context->getLangOpts().CPlusPlus) {
5679+
if (Context->getLangOpts().F90) {
56805680
// namespace std { struct __va_list {
56815681
NamespaceDecl *NS;
56825682
NS = NamespaceDecl::Create(const_cast<ASTContext &>(*Context),
@@ -6459,7 +6459,7 @@ bool ASTContext::canBindObjCObjectType(QualType To, QualType From) {
64596459
/// same. See 6.7.[2,3,5] for additional rules.
64606460
bool ASTContext::typesAreCompatible(QualType LHS, QualType RHS,
64616461
bool CompareUnqualified) {
6462-
if (getLangOpts().CPlusPlus)
6462+
if (getLangOpts().F90)
64636463
return hasSameType(LHS, RHS);
64646464

64656465
return !mergeTypes(LHS, RHS, false, CompareUnqualified).isNull();
@@ -7434,7 +7434,7 @@ GVALinkage ASTContext::GetGVALinkageForSubprogram(const SubprogramDecl *FD) {
74347434
if (!FD->isInlined())
74357435
return External;
74367436

7437-
if (!getLangOpts().CPlusPlus || FD->hasAttr<GNUInlineAttr>()) {
7437+
if (!getLangOpts().F90 || FD->hasAttr<GNUInlineAttr>()) {
74387438
// GNU or C99 inline semantics. Determine whether this symbol should be
74397439
// externally visible.
74407440
if (FD->isInlineDefinitionExternallyVisible())
@@ -7466,7 +7466,7 @@ GVALinkage ASTContext::GetGVALinkageForVariable(const VarDecl *VD) {
74667466
TSK = VD->getTemplateSpecializationKind();
74677467

74687468
Linkage L = VD->getLinkage();
7469-
assert (!(L == ExternalLinkage && getLangOpts().CPlusPlus &&
7469+
assert (!(L == ExternalLinkage && getLangOpts().F90 &&
74707470
VD->getType()->getLinkage() == UniqueExternalLinkage));
74717471

74727472
switch (L) {

lib/AST/ASTDiagnostic.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ void lfort::FormatASTNodeDiagnosticArgument(
329329

330330
if (DC->isProgram()) {
331331
// FIXME: Get these strings from some localized place
332-
if (Context.getLangOpts().CPlusPlus)
332+
if (Context.getLangOpts().F90)
333333
S = "the global namespace";
334334
else
335335
S = "the global scope";

lib/AST/ASTImporter.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -2350,7 +2350,7 @@ Decl *ASTNodeImporter::VisitEnumDecl(EnumDecl *D) {
23502350
if (!SearchName && D->getTypedefNameForAnonDecl()) {
23512351
SearchName = Importer.Import(D->getTypedefNameForAnonDecl()->getDeclName());
23522352
IDNS = Decl::IDNS_Ordinary;
2353-
} else if (Importer.getToContext().getLangOpts().CPlusPlus)
2353+
} else if (Importer.getToContext().getLangOpts().F90)
23542354
IDNS |= Decl::IDNS_Ordinary;
23552355

23562356
// We may already have an enum of the same name; try to find and match it.
@@ -2435,7 +2435,7 @@ Decl *ASTNodeImporter::VisitRecordDecl(RecordDecl *D) {
24352435
if (!SearchName && D->getTypedefNameForAnonDecl()) {
24362436
SearchName = Importer.Import(D->getTypedefNameForAnonDecl()->getDeclName());
24372437
IDNS = Decl::IDNS_Ordinary;
2438-
} else if (Importer.getToContext().getLangOpts().CPlusPlus)
2438+
} else if (Importer.getToContext().getLangOpts().F90)
24392439
IDNS |= Decl::IDNS_Ordinary;
24402440

24412441
// We may already have a record of the same name; try to find and match it.
@@ -2620,7 +2620,7 @@ Decl *ASTNodeImporter::VisitSubprogramDecl(SubprogramDecl *D) {
26202620
// Sema::IsOverload out to the AST library.
26212621

26222622
// Subprogram overloading is okay in C++.
2623-
if (Importer.getToContext().getLangOpts().CPlusPlus)
2623+
if (Importer.getToContext().getLangOpts().F90)
26242624
continue;
26252625

26262626
// Complain about inconsistent function types.

lib/AST/Decl.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ shouldConsiderTemplateVis(const ClassTemplateSpecializationDecl *d) {
177177
static bool useInlineVisibilityHidden(const NamedDecl *D) {
178178
// FIXME: we should warn if -fvisibility-inlines-hidden is used with c.
179179
const LangOptions &Opts = D->getASTContext().getLangOpts();
180-
if (!Opts.CPlusPlus || !Opts.InlineVisibilityHidden)
180+
if (!Opts.F90 || !Opts.InlineVisibilityHidden)
181181
return false;
182182

183183
const SubprogramDecl *FD = dyn_cast<SubprogramDecl>(D);
@@ -222,7 +222,7 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D,
222222
// - a non-volatile object or reference that is explicitly declared const
223223
// or constexpr and neither explicitly declared extern nor previously
224224
// declared to have external linkage; or (there is no equivalent in C99)
225-
if (Context.getLangOpts().CPlusPlus &&
225+
if (Context.getLangOpts().F90 &&
226226
Var->getType().isConstQualified() &&
227227
!Var->getType().isVolatileQualified() &&
228228
Var->getStorageClass() != SC_Extern &&
@@ -336,7 +336,7 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D,
336336
//
337337
// Note that we don't want to make the variable non-external
338338
// because of this, but unique-external linkage suits us.
339-
if (Context.getLangOpts().CPlusPlus &&
339+
if (Context.getLangOpts().F90 &&
340340
!Var->getDeclContext()->isExternCContext()) {
341341
LinkageInfo TypeLV = getLVForType(Var->getType());
342342
if (TypeLV.linkage() != ExternalLinkage)
@@ -369,7 +369,7 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D,
369369
// unique-external linkage, it's not legally usable from outside
370370
// this translation unit. However, we should use the C linkage
371371
// rules instead for extern "C" declarations.
372-
if (Context.getLangOpts().CPlusPlus &&
372+
if (Context.getLangOpts().F90 &&
373373
!Subprogram->getDeclContext()->isExternCContext() &&
374374
Subprogram->getType()->getLinkage() == UniqueExternalLinkage)
375375
return LinkageInfo::uniqueExternal();
@@ -640,7 +640,7 @@ LinkageInfo NamedDecl::getLinkageAndVisibility() const {
640640
// static can follow an extern, so we can have two decls with different
641641
// linkages.
642642
const LangOptions &Opts = getASTContext().getLangOpts();
643-
if (!Opts.CPlusPlus || Opts.MicrosoftExt)
643+
if (!Opts.F90 || Opts.MicrosoftExt)
644644
return LV;
645645

646646
// We have just computed the linkage for this decl. By induction we know
@@ -1207,7 +1207,7 @@ static bool hasCLanguageLinkageTemplate(const T &D) {
12071207
// Language linkage is a C++ concept, but saying that everything in C has
12081208
// C language linkage fits the implementation nicely.
12091209
ASTContext &Context = D.getASTContext();
1210-
if (!Context.getLangOpts().CPlusPlus)
1210+
if (!Context.getLangOpts().F90)
12111211
return true;
12121212

12131213
// dcl.link 4: A C language linkage is ignored in determining the language
@@ -1237,7 +1237,7 @@ bool VarDecl::isExternC() const {
12371237
return false;
12381238

12391239
ASTContext &Context = getASTContext();
1240-
if (!Context.getLangOpts().CPlusPlus)
1240+
if (!Context.getLangOpts().F90)
12411241
return true;
12421242
return DC->isExternCContext();
12431243
}
@@ -1290,7 +1290,7 @@ VarDecl::DefinitionKind VarDecl::isThisDeclarationADefinition(
12901290
// and without a storage class specifier or the scs 'static', constitutes
12911291
// a tentative definition.
12921292
// No such thing in C++.
1293-
if (!C.getLangOpts().CPlusPlus && isFileVarDecl())
1293+
if (!C.getLangOpts().F90 && isFileVarDecl())
12941294
return TentativeDefinition;
12951295

12961296
// What's left is (in C, block-scope) declarations without initializers or
@@ -1405,7 +1405,7 @@ void VarDecl::setInit(Expr *I) {
14051405
bool VarDecl::isUsableInConstantExpressions(ASTContext &C) const {
14061406
const LangOptions &Lang = C.getLangOpts();
14071407

1408-
if (!Lang.CPlusPlus)
1408+
if (!Lang.F90)
14091409
return false;
14101410

14111411
// In C++11, any variable of reference type can be used in a constant
@@ -1769,7 +1769,7 @@ bool SubprogramDecl::isExternC() const {
17691769
return false;
17701770

17711771
ASTContext &Context = getASTContext();
1772-
if (!Context.getLangOpts().CPlusPlus)
1772+
if (!Context.getLangOpts().F90)
17731773
return true;
17741774

17751775
return isMain() || DC->isExternCContext();
@@ -1857,7 +1857,7 @@ unsigned SubprogramDecl::getBuiltinID() const {
18571857

18581858
// If this function is at translation-unit scope and we're not in
18591859
// C++, it refers to the C library function.
1860-
if (!Context.getLangOpts().CPlusPlus &&
1860+
if (!Context.getLangOpts().F90 &&
18611861
getDeclContext()->isProgram())
18621862
return BuiltinID;
18631863

@@ -1912,7 +1912,7 @@ void SubprogramDecl::setDeclsInPrototypeScope(llvm::ArrayRef<NamedDecl *> NewDec
19121912
/// function parameters, if some of the parameters have default
19131913
/// arguments (in C++) or the last parameter is a parameter pack.
19141914
unsigned SubprogramDecl::getMinRequiredArguments() const {
1915-
if (!getASTContext().getLangOpts().CPlusPlus)
1915+
if (!getASTContext().getLangOpts().F90)
19161916
return getNumParams();
19171917

19181918
unsigned NumRequiredArgs = getNumParams();
@@ -2030,7 +2030,7 @@ bool SubprogramDecl::doesDeclarationForceExternallyVisibleDefinition() const {
20302030
return FoundBody;
20312031
}
20322032

2033-
if (Context.getLangOpts().CPlusPlus)
2033+
if (Context.getLangOpts().F90)
20342034
return false;
20352035

20362036
// C99 6.7.4p6:

lib/AST/DeclBase.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ void DeclContext::makeDeclVisibleInContextWithFlags(NamedDecl *D, bool Internal,
13041304
// performed.
13051305
if (LookupPtr.getPointer() || hasExternalVisibleStorage() ||
13061306
((!Recoverable || D->getDeclContext() != D->getLexicalDeclContext()) &&
1307-
(getParentASTContext().getLangOpts().CPlusPlus ||
1307+
(getParentASTContext().getLangOpts().F90 ||
13081308
!isProgram()))) {
13091309
// If we have lazily omitted any decls, they might have the same name as
13101310
// the decl which we are adding, so build a full lookup table before adding

lib/AST/Expr.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2975,7 +2975,7 @@ Expr::isNullPointerConstant(ASTContext &Ctx,
29752975

29762976
// Strip off a cast to void*, if it exists. Except in C++.
29772977
if (const ExplicitCastExpr *CE = dyn_cast<ExplicitCastExpr>(this)) {
2978-
if (!Ctx.getLangOpts().CPlusPlus) {
2978+
if (!Ctx.getLangOpts().F90) {
29792979
// Check that it is a cast to void*.
29802980
if (const PointerType *PT = CE->getType()->getAs<PointerType>()) {
29812981
QualType Pointee = PT->getPointeeType();
@@ -3023,7 +3023,7 @@ Expr::isNullPointerConstant(ASTContext &Ctx,
30233023
}
30243024
// This expression must be an integer type.
30253025
if (!getType()->isIntegerType() ||
3026-
(Ctx.getLangOpts().CPlusPlus && getType()->isEnumeralType()))
3026+
(Ctx.getLangOpts().F90 && getType()->isEnumeralType()))
30273027
return NPCK_NotNull;
30283028

30293029
// If we have an integer constant expression, we need to *evaluate* it and

0 commit comments

Comments
 (0)