Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  TestParamTraitsEnum.cpp

  Sprache: C
 

#include <cstdint>

typedef enum {
  BadFirst,
  BadSecond,
  BadThird
} BadEnum;

typedef enum {
  NestedFirst,
  NestedSecond
} NestedBadEnum;

typedef enum {
  GoodFirst,
  GoodSecond,
  GoodLast
} GoodEnum;

enum RawEnum {
  RawFirst,
  RawLast
};

enum class ClassEnum {
  ClassFirst,
  ClassLast
};

enum class TypedClassEnum : uint32_t {
  TypedFirst,
  TypedLast
};

enum class nsresult : uint32_t {
  NS_OK = 0
};

template <class P> struct ParamTraits;

// Simplified EnumSerializer etc. from IPCMessageUtils.h
template <typename E, typename EnumValidator>
struct EnumSerializer {
};

template <typename E,
          E MinLegal,
          E HighBound>
class ContiguousEnumValidator
{};

// Make sure the class derived from EnumSerializer doesn't error
template <typename E,
          E MinLegal,
          E HighBound>
struct ContiguousEnumSerializer
  : EnumSerializer<E,
                   ContiguousEnumValidator<E, MinLegal, HighBound>>
{};

// Typical ParamTraits implementation that should be avoided
template<>
struct ParamTraits<ClassEnum> // expected-error {{Custom ParamTraits implementation for an enum type}} expected-note {{Please use a helper class for example ContiguousEnumSerializer}}
{
  // Make sure the matcher doesn't need a typedef.
};

template<>
struct ParamTraits<TypedClassEnum> // expected-error {{Custom ParamTraits implementation for an enum type}} expected-note {{Please use a helper class for example ContiguousEnumSerializer}}
{
};

template<>
struct ParamTraits<enum RawEnum> // expected-error {{Custom ParamTraits implementation for an enum type}} expected-note {{Please use a helper class for example ContiguousEnumSerializer}}
{
};

// Make sure forward declarations are not flagged
template <> struct ParamTraits<BadEnum>;

struct SomeClass {
  enum FooBar {};
  enum class FooBarClass {};

  friend struct ParamTraits<FooBar>;
  friend struct ParamTraits<FooBarClass>;
};

template<>
struct ParamTraits<BadEnum> // expected-error {{Custom ParamTraits implementation for an enum type}} expected-note {{Please use a helper class for example ContiguousEnumSerializer}}
{
};

// Make sure the analysis catches nested typedefs
typedef NestedBadEnum NestedDefLevel1;
typedef NestedDefLevel1 NestedDefLevel2;

template<>
struct ParamTraits<NestedDefLevel2> // expected-error {{Custom ParamTraits implementation for an enum type}} expected-note {{Please use a helper class for example ContiguousEnumSerializer}}
{
};

// Make sure a non enum typedef is not accidentally flagged
typedef int IntTypedef;

template<>
struct ParamTraits<IntTypedef>
{
};

// Make sure ParamTraits using helper classes are not flagged
template<>
struct ParamTraits<GoodEnum>
: public ContiguousEnumSerializer<GoodEnum,
                                  GoodEnum::GoodFirst,
                                  GoodEnum::GoodLast>
{};

// nsresult has special handling via ParamTraitsMozilla and should be allowed
template<>
struct ParamTraits<nsresult>
{};

Messung V0.5 in Prozent
C=92 H=88 G=89

¤ Dauer der Verarbeitung: 0.2 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002