Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: m-labs/clang-lm32
base: 3054358
...
head fork: m-labs/clang-lm32
compare: 4198b89
  • 3 commits
  • 6 files changed
  • 0 commit comments
  • 3 contributors
Commits on Jun 07, 2011
Douglas Gregor Downgrade the warning about the use of typedefs for class template
specializations within an explicit instantiation to default to off
(enabled by -pedantic). Nobody else seem to implement C++
[temp.explicit]p3. Fixes PR10093.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132704 91177308-0d34-0410-b5e6-96231b3b80d8
5b01b83
@nlewycky nlewycky The macros defined by the language standard are still available even …
…when the

-undef flag is passed in. Also __ASSEMBLER__ with -x assembler-with-cpp. (Don't
ask.)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132708 91177308-0d34-0410-b5e6-96231b3b80d8
a9c6441
@sbourdeauducq sbourdeauducq Basic LM32 info 4198b89
View
2  include/clang/Basic/DiagnosticSemaKinds.td
@@ -2047,7 +2047,7 @@ def note_explicit_instantiation_candidate : Note<
"explicit instantiation candidate function template here %0">;
def err_explicit_instantiation_inline : Error<
"explicit instantiation cannot be 'inline'">;
-def ext_explicit_instantiation_without_qualified_id : ExtWarn<
+def ext_explicit_instantiation_without_qualified_id : Extension<
"qualifier in explicit instantiation of %q0 requires a template-id "
"(a typedef is not permitted)">;
def err_explicit_instantiation_unqualified_wrong_namespace : Error<
View
88 lib/Basic/Targets.cpp
@@ -1056,6 +1056,91 @@ void MBlazeTargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases,
} // end anonymous namespace.
namespace {
+// Mico32 abstract base class
+class Mico32TargetInfo : public TargetInfo {
+ static const char * const GCCRegNames[];
+ static const TargetInfo::GCCRegAlias GCCRegAliases[];
+
+public:
+ Mico32TargetInfo(const std::string& triple) : TargetInfo(triple) {
+ DescriptionString = "E-p:32:32:32-i8:8:8-i16:16:16";
+ }
+
+ virtual void getTargetBuiltins(const Builtin::Info *&Records,
+ unsigned &NumRecords) const {
+ // FIXME: Implement.
+ Records = 0;
+ NumRecords = 0;
+ }
+
+ virtual void getTargetDefines(const LangOptions &Opts,
+ MacroBuilder &Builder) const;
+
+ virtual const char *getVAListDeclaration() const {
+ return "typedef char* __builtin_va_list;";
+ }
+ virtual const char *getTargetPrefix() const {
+ return "mico32";
+ }
+ virtual void getGCCRegNames(const char * const *&Names,
+ unsigned &NumNames) const;
+ virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
+ unsigned &NumAliases) const {
+ // No aliases.
+ Aliases = 0;
+ NumAliases = 0;
+ }
+ virtual bool validateAsmConstraint(const char *&Name,
+ TargetInfo::ConstraintInfo &Info) const {
+ switch (*Name) {
+ default: return false;
+ case 'O': // Zero
+ return true;
+ case 'b': // Base register
+ case 'f': // Floating point register
+ Info.setAllowsRegister();
+ return true;
+ }
+ }
+ virtual const char *getClobbers() const {
+ return "";
+ }
+};
+
+/// Mico32TargetInfo::getTargetDefines - Return a set of the Mico32-specific
+/// #defines that are not tied to a specific subtarget.
+void Mico32TargetInfo::getTargetDefines(const LangOptions &Opts,
+ MacroBuilder &Builder) const {
+ // Target identification.
+ Builder.defineMacro("__mico32__");
+ Builder.defineMacro("_ARCH_MICO32");
+ Builder.defineMacro("__MICO32__");
+
+ // Target properties.
+ Builder.defineMacro("_BIG_ENDIAN");
+ Builder.defineMacro("__BIG_ENDIAN__");
+
+ // Subtarget options.
+ Builder.defineMacro("__REGISTER_PREFIX__", "");
+}
+
+
+const char * const Mico32TargetInfo::GCCRegNames[] = {
+ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
+ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
+ "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
+ "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31"
+};
+
+void Mico32TargetInfo::getGCCRegNames(const char * const *&Names,
+ unsigned &NumNames) const {
+ Names = GCCRegNames;
+ NumNames = llvm::array_lengthof(GCCRegNames);
+}
+
+} // end anonymous namespace.
+
+namespace {
// Namespace for x86 abstract base class
const Builtin::Info BuiltinInfo[] = {
#define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, ALL_LANGUAGES, false },
@@ -2752,6 +2837,9 @@ static TargetInfo *AllocateTarget(const std::string &T) {
case llvm::Triple::mblaze:
return new MBlazeTargetInfo(T);
+
+ case llvm::Triple::mico32:
+ return new Mico32TargetInfo(T);
case llvm::Triple::sparc:
if (os == llvm::Triple::AuroraUX)
View
25 lib/CodeGen/TargetInfo.cpp
@@ -2853,6 +2853,28 @@ void MSP430TargetCodeGenInfo::SetTargetAttributes(const Decl *D,
}
//===----------------------------------------------------------------------===//
+// Mico32 ABI Implementation
+//===----------------------------------------------------------------------===//
+
+namespace {
+
+class Mico32TargetCodeGenInfo : public TargetCodeGenInfo {
+public:
+ Mico32TargetCodeGenInfo(CodeGenTypes &CGT)
+ : TargetCodeGenInfo(new DefaultABIInfo(CGT)) {}
+ void SetTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
+ CodeGen::CodeGenModule &M) const;
+};
+
+}
+
+void Mico32TargetCodeGenInfo::SetTargetAttributes(const Decl *D,
+ llvm::GlobalValue *GV,
+ CodeGen::CodeGenModule &M) const {
+}
+
+
+//===----------------------------------------------------------------------===//
// MIPS ABI Implementation. This works for both little-endian and
// big-endian variants.
//===----------------------------------------------------------------------===//
@@ -3006,6 +3028,9 @@ const TargetCodeGenInfo &CodeGenModule::getTargetCodeGenInfo() {
case llvm::Triple::mblaze:
return *(TheTargetCodeGenInfo = new MBlazeTargetCodeGenInfo(Types));
+
+ case llvm::Triple::mico32:
+ return *(TheTargetCodeGenInfo = new Mico32TargetCodeGenInfo(Types));
case llvm::Triple::msp430:
return *(TheTargetCodeGenInfo = new MSP430TargetCodeGenInfo(Types));
View
63 lib/Frontend/InitPreprocessor.cpp
@@ -221,6 +221,37 @@ static void DefineExactWidthIntType(TargetInfo::IntType Ty,
ConstSuffix);
}
+static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
+ const LangOptions &LangOpts,
+ const FrontendOptions &FEOpts,
+ MacroBuilder &Builder) {
+ if (!LangOpts.Microsoft && !LangOpts.TraditionalCPP)
+ Builder.defineMacro("__STDC__");
+ if (LangOpts.Freestanding)
+ Builder.defineMacro("__STDC_HOSTED__", "0");
+ else
+ Builder.defineMacro("__STDC_HOSTED__");
+
+ if (!LangOpts.CPlusPlus) {
+ if (LangOpts.C99)
+ Builder.defineMacro("__STDC_VERSION__", "199901L");
+ else if (!LangOpts.GNUMode && LangOpts.Digraphs)
+ Builder.defineMacro("__STDC_VERSION__", "199409L");
+ } else {
+ if (LangOpts.GNUMode)
+ Builder.defineMacro("__cplusplus");
+ else
+ // C++ [cpp.predefined]p1:
+ // The name_ _cplusplus is defined to the value 199711L when compiling a
+ // C++ translation unit.
+ Builder.defineMacro("__cplusplus", "199711L");
+ }
+
+ // Not "standard" per se, but available even with the -undef flag.
+ if (LangOpts.AsmPreprocessor)
+ Builder.defineMacro("__ASSEMBLER__");
+}
+
static void InitializePredefinedMacros(const TargetInfo &TI,
const LangOptions &LangOpts,
const FrontendOptions &FEOpts,
@@ -256,20 +287,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
// Initialize language-specific preprocessor defines.
- // These should all be defined in the preprocessor according to the
- // current language configuration.
- if (!LangOpts.Microsoft && !LangOpts.TraditionalCPP)
- Builder.defineMacro("__STDC__");
- if (LangOpts.AsmPreprocessor)
- Builder.defineMacro("__ASSEMBLER__");
-
- if (!LangOpts.CPlusPlus) {
- if (LangOpts.C99)
- Builder.defineMacro("__STDC_VERSION__", "199901L");
- else if (!LangOpts.GNUMode && LangOpts.Digraphs)
- Builder.defineMacro("__STDC_VERSION__", "199409L");
- }
-
// Standard conforming mode?
if (!LangOpts.GNUMode)
Builder.defineMacro("__STRICT_ANSI__");
@@ -277,11 +294,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
if (LangOpts.CPlusPlus0x)
Builder.defineMacro("__GXX_EXPERIMENTAL_CXX0X__");
- if (LangOpts.Freestanding)
- Builder.defineMacro("__STDC_HOSTED__", "0");
- else
- Builder.defineMacro("__STDC_HOSTED__");
-
if (LangOpts.ObjC1) {
Builder.defineMacro("__OBJC__");
if (LangOpts.ObjCNonFragileABI) {
@@ -324,13 +336,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
if (LangOpts.CPlusPlus) {
Builder.defineMacro("__GNUG__", "4");
Builder.defineMacro("__GXX_WEAK__");
- if (LangOpts.GNUMode)
- Builder.defineMacro("__cplusplus");
- else
- // C++ [cpp.predefined]p1:
- // The name_ _cplusplusis defined to the value 199711L when compiling a
- // C++ translation unit.
- Builder.defineMacro("__cplusplus", "199711L");
Builder.defineMacro("__private_extern__", "extern");
}
@@ -572,6 +577,12 @@ void clang::InitializePreprocessor(Preprocessor &PP,
InitializePredefinedMacros(PP.getTargetInfo(), PP.getLangOptions(),
FEOpts, Builder);
+ // Even with predefines off, some macros are still predefined.
+ // These should all be defined in the preprocessor according to the
+ // current language configuration.
+ InitializeStandardPredefinedMacros(PP.getTargetInfo(), PP.getLangOptions(),
+ FEOpts, Builder);
+
// Add on the predefines from the driver. Wrap in a #line directive to report
// that they come from the command line.
if (!PP.getLangOptions().AsmPreprocessor)
View
4 test/CXX/temp/temp.spec/temp.explicit/p2.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
// Example from the standard
template<class T> class Array { void mf() { } };
@@ -35,7 +35,7 @@ namespace N {
};
template<typename T>
- void f1(T) {}; // expected-note{{explicit instantiation refers here}}
+ void f1(T) {} // expected-note{{explicit instantiation refers here}}
}
using namespace N;
View
4 test/Frontend/undef.c
@@ -0,0 +1,4 @@
+// RUN: %clang -undef -x assembler-with-cpp -E %s
+#ifndef __ASSEMBLER__
+#error "Must be preprocessed as assembler."
+#endif

No commit comments for this range

Something went wrong with that request. Please try again.