summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-01-22 01:43:19 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-01-22 01:43:19 +0000
commitb63b6ee9a00ef0710d899df6cfda78a1b8bd762a (patch)
tree16d99f0325f0f71e8c08cdf731bf3631774be256 /clang/lib/Sema/SemaExpr.cpp
parent407e442245b5515c5f110f81b7c1e3f90c40c68c (diff)
downloadbcm5719-llvm-b63b6ee9a00ef0710d899df6cfda78a1b8bd762a.tar.gz
bcm5719-llvm-b63b6ee9a00ef0710d899df6cfda78a1b8bd762a.zip
Enforce restrictions that 'main' is not allowed to be deleted, or to be used by
the program, in C++. (We allow the latter as an extension, since we've always permitted it, and GCC does the same, and our supported C++ ABIs don't do anything special in main.) llvm-svn: 199782
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3640c5ad24b..ff54b6b24e4 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -264,13 +264,18 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc,
SmallVectorImpl<PartialDiagnosticAt> &Suppressed = Pos->second;
for (unsigned I = 0, N = Suppressed.size(); I != N; ++I)
Diag(Suppressed[I].first, Suppressed[I].second);
-
+
// Clear out the list of suppressed diagnostics, so that we don't emit
// them again for this specialization. However, we don't obsolete this
// entry from the table, because we want to avoid ever emitting these
// diagnostics again.
Suppressed.clear();
}
+
+ // C++ [basic.start.main]p3:
+ // The function 'main' shall not be used within a program.
+ if (cast<FunctionDecl>(D)->isMain())
+ Diag(Loc, diag::ext_main_used);
}
// See if this is an auto-typed variable whose initializer we are parsing.
OpenPOWER on IntegriCloud