This adds diagnostic groups, command-line options, a language option,
and various other things required to support `-std=c++2d`. I haven’t
touched e.g. clang-tidy or clang-format, as I’m not really familiar w/
either. This is only meant to add the most necessary parts to support
C++29 mode.
I grepped for `CPlusPlus26`/`C++26`/`C++2c` and updated all places I
could find where we need to handle every language mode in some way or
another.
This patch is roughly based on b763d6a4ed.
58 lines
1.7 KiB
C++
58 lines
1.7 KiB
C++
//===- unittests/Basic/LangOptionsTest.cpp --------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "clang/Basic/LangOptions.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
using namespace llvm;
|
|
using namespace clang;
|
|
|
|
namespace {
|
|
TEST(LangOptsTest, CStdLang) {
|
|
LangOptions opts;
|
|
EXPECT_FALSE(opts.getCLangStd());
|
|
opts.GNUMode = 0;
|
|
opts.Digraphs = 1;
|
|
EXPECT_EQ(opts.getCLangStd(), 199409);
|
|
opts.C99 = 1;
|
|
EXPECT_EQ(opts.getCLangStd(), 199901);
|
|
opts.C11 = 1;
|
|
EXPECT_EQ(opts.getCLangStd(), 201112);
|
|
opts.C17 = 1;
|
|
EXPECT_EQ(opts.getCLangStd(), 201710);
|
|
opts.C23 = 1;
|
|
EXPECT_EQ(opts.getCLangStd(), 202311);
|
|
opts.C2y = 1;
|
|
EXPECT_EQ(opts.getCLangStd(), 202400);
|
|
|
|
EXPECT_FALSE(opts.getCPlusPlusLangStd());
|
|
}
|
|
|
|
TEST(LangOptsTest, CppStdLang) {
|
|
LangOptions opts;
|
|
EXPECT_FALSE(opts.getCPlusPlusLangStd());
|
|
opts.CPlusPlus = 1;
|
|
EXPECT_EQ(opts.getCPlusPlusLangStd(), 199711);
|
|
opts.CPlusPlus11 = 1;
|
|
EXPECT_EQ(opts.getCPlusPlusLangStd(), 201103);
|
|
opts.CPlusPlus14 = 1;
|
|
EXPECT_EQ(opts.getCPlusPlusLangStd(), 201402);
|
|
opts.CPlusPlus17 = 1;
|
|
EXPECT_EQ(opts.getCPlusPlusLangStd(), 201703);
|
|
opts.CPlusPlus20 = 1;
|
|
EXPECT_EQ(opts.getCPlusPlusLangStd(), 202002);
|
|
opts.CPlusPlus23 = 1;
|
|
EXPECT_EQ(opts.getCPlusPlusLangStd(), 202302);
|
|
opts.CPlusPlus26 = 1;
|
|
EXPECT_EQ(opts.getCPlusPlusLangStd(), 202400);
|
|
opts.CPlusPlus29 = 1;
|
|
EXPECT_EQ(opts.getCPlusPlusLangStd(), 202700);
|
|
|
|
EXPECT_FALSE(opts.getCLangStd());
|
|
}
|
|
} // namespace
|