[tint] static_assert that C in Castable<C[, B]> is correct
Fix a bug this caught. Fixed: tint:1939 Change-Id: I61ea4eb66fe1f91b3bc17ba5d65aee7324aa555c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132621 Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: James Price <jrprice@google.com> Commit-Queue: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
6ac063d568
commit
b0726080f4
|
@ -133,7 +133,7 @@ class Statement : public utils::Castable<Statement, Node> {
|
||||||
|
|
||||||
/// CompoundStatement is the base class of statements that can hold other
|
/// CompoundStatement is the base class of statements that can hold other
|
||||||
/// statements.
|
/// statements.
|
||||||
class CompoundStatement : public utils::Castable<Statement, Statement> {
|
class CompoundStatement : public utils::Castable<CompoundStatement, Statement> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param declaration the AST node for this statement
|
/// @param declaration the AST node for this statement
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "src/tint/utils/crc32.h"
|
#include "src/tint/utils/crc32.h"
|
||||||
|
@ -73,7 +74,9 @@ static constexpr bool IsCastable =
|
||||||
tint::utils::TypeInfo::HashCodeOf<CLASS>(), \
|
tint::utils::TypeInfo::HashCodeOf<CLASS>(), \
|
||||||
tint::utils::TypeInfo::FullHashCodeOf<CLASS>(), \
|
tint::utils::TypeInfo::FullHashCodeOf<CLASS>(), \
|
||||||
}; \
|
}; \
|
||||||
TINT_CASTABLE_POP_DISABLE_WARNINGS()
|
TINT_CASTABLE_POP_DISABLE_WARNINGS(); \
|
||||||
|
static_assert(std::is_same_v<CLASS, CLASS::Base::Class>, \
|
||||||
|
#CLASS " does not derive from Castable<" #CLASS "[, BASE]>")
|
||||||
|
|
||||||
/// Bit flags that can be passed to the template parameter `FLAGS` of Is() and As().
|
/// Bit flags that can be passed to the template parameter `FLAGS` of Is() and As().
|
||||||
enum CastFlags {
|
enum CastFlags {
|
||||||
|
@ -414,14 +417,16 @@ class CastableBase {
|
||||||
template <typename CLASS, typename BASE = CastableBase>
|
template <typename CLASS, typename BASE = CastableBase>
|
||||||
class Castable : public BASE {
|
class Castable : public BASE {
|
||||||
public:
|
public:
|
||||||
/// A type alias for `CLASS` to easily access the `BASE` class members.
|
/// A type alias to this Castable. Commonly used in derived type constructors to forward
|
||||||
/// Base actually aliases to the Castable instead of `BASE` so that you can
|
/// constructor arguments to BASE.
|
||||||
/// use Base in the `CLASS` constructor.
|
|
||||||
using Base = Castable;
|
using Base = Castable;
|
||||||
|
|
||||||
/// A type alias for `BASE`.
|
/// A type alias for `BASE`.
|
||||||
using TrueBase = BASE;
|
using TrueBase = BASE;
|
||||||
|
|
||||||
|
/// A type alias for `CLASS`.
|
||||||
|
using Class = CLASS;
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param arguments the arguments to forward to the base class.
|
/// @param arguments the arguments to forward to the base class.
|
||||||
template <typename... ARGS>
|
template <typename... ARGS>
|
||||||
|
|
Loading…
Reference in New Issue